Aspose.Cell import object shuffles the data

in some random case for the same dataset after binding data to Excel using Aspose.Cells data is shuffled randomly , it’s not like data is shifted. But if we re-prepare the excel it looks fine. Below is the code snippet.

List baseList = originalList
.Select(x => new GSTR2BReconDataModelPR6
{
ReconciliationRemarks = x.ReconciliationRemarks,
SubStatus = x.SubStatus,
Gstin = x.Gstin,
PrPeriod = x.PrPeriod,
PrVendorGstin = x.PrVendorGstin,
PrDocumentType = x.PrDocumentType,
PrDocumentNumber = x.PrDocumentNumber,
PrDocumentDate = x.PrDocumentDate,
PrDocumentValue = x.PrDocumentValue,
PrTaxablevalue = x.PrTaxablevalue,
PrIgst = x.PrIgst,
PrCgst = x.PrCgst,
PrSgst = x.PrSgst,
PrCess = x.PrCess,
Period = x.Period,
G2bCtin = x.G2bCtin,
G2bDocumentType = x.G2bDocumentType,
G2bDocumentNumber = x.G2bDocumentNumber,
G2bDocumentDate = x.G2bDocumentDate,
G2bDocumentValue = x.G2bDocumentValue,
G2bTaxablevalue = x.G2bTaxablevalue,
G2bIgst = x.G2bIgst,
G2bCgst = x.G2bCgst,
G2bSgst = x.G2bSgst,
G2bCess = x.G2bCess,
DiffTaxVal = x.DiffTaxVal,
DiffIGST = x.DiffIGST,
DiffCGST = x.DiffCGST,
DiffSGST = x.DiffSGST,
DiffCess = x.DiffCess
})
.ToList();

ImportTableOptions options = new ImportTableOptions();
options.IsFieldNameShown = false;
worksheet.Cells.ImportCustomObjects(baseList, 1, 0, options);

We are running with aspose.cells version 22.9.0 and we r using licensed version also.
Please check and confirm asap.

@VenkateshBT

It seems you are experiencing an issue where the data is shuffled when importing a list of custom objects into an Excel worksheet using Aspose.Cells. This can sometimes occur due to the way the data is processed or the order in which it is being imported.

Here are a few suggestions to troubleshoot and potentially resolve the issue:

  1. Check the Original List Order: Ensure that the originalList is in the correct order before you create baseList. You can add a sorting step if necessary.

  2. Use a Different Import Method: Instead of ImportCustomObjects, consider using ImportArray or ImportDataTable if your data can be represented in those formats. This can sometimes yield better results in terms of maintaining order.

  3. Debugging: Add logging to check the order of items in baseList right before the import. This will help you confirm whether the shuffling occurs before or during the import process.

  4. Update Aspose.Cells: Since you are using version 22.9.0, consider updating to the latest version of Aspose.Cells, as there may have been bug fixes or improvements related to data import functionality.

Here’s a simple example of how you might sort the list before importing:

baseList = originalList
    .OrderBy(x => x.PrDocumentDate) // Sort by a relevant field
    .Select(x => new GSTR2BReconDataModelPR6
    {
        // Your property mappings
    })
    .ToList();

worksheet.Cells.ImportCustomObjects(baseList, 1, 0, options);

If the issue persists, you may want to reach out to the Aspose support forum with your specific case for more tailored assistance.

@VenkateshBT
We recommend you to kindly try using our latest version: Aspose.Cells for .NET 25.9.

If you still find the issue, kindly do share your complete sample (runnable) code and template Excel file (if any) to reproduce the issue on our end, we will check it soon.