Limitation of number of rows or bug when saving as .ods

Hi!

Developed a report generation and use to work fine up to now but when tried generating with a greater number of rows on feed files client encountered the error “Invalid column index” when saving the workbook.
Tested and took out several rows from feed file until got a more accurate number of rows when hit the error. The number of rows on the current feed file is approx 18800, and tokk out until noticed at 14900 rows it stopped working and throwed error. at 14850 it works fine.
Mention that when changed the extension to save as .XLSX or .PDF the report generates ok.
Below is the source code minimised just to replicate the error, and on the thread attached also the feed files and screen shot with errors:

string sNewReport;
csvRepData = $“{pathToTemp}sched_report.csv”;
int counter;

TxtLoadOptions loadOptions = new TxtLoadOptions(LoadFormat.CSV);
loadOptions.Encoding = Encoding.UTF7;

Workbook book = new Workbook(csvRepData, loadOptions);

Worksheet worksheet = book.Worksheets[0];
Cells cells = worksheet.Cells;

DataTable dt = cells.ExportDataTable(0, 0, cells.MaxDataRow + 1, cells.MaxDataColumn + 1,
new ExportTableOptions() { ExportColumnName = true, ExportAsString = true });

cells.DeleteRows(0, cells.MaxDataRow + 1, true);

counter = 0;

foreach (var byParent in dt.AsEnumerable().GroupBy(x => x.Field(“order_ref”)))
{
counter++;
cells[counter, 0].PutValue($“LOCATION DESCRIPTIONS” +
$" FOR ITEMS IN ORDER: {byParent.Key}");
foreach (var byChild in byParent.GroupBy(x => x.Field(“schedule”)))
{
counter++;
int idxSt = counter;

    cells[counter, 0].PutValue($"");
    counter++;
    cells[counter, 0].PutValue($"Schedule Number: {byChild.Key}");
    cells[counter, 0].Characters(0, 15).Font.IsBold = true;

    foreach (var row in byChild)
    {
        string prevTtemVal = row.Field<string>("ItemNo");
        counter++;
        cells[counter, 0].PutValue($"\t\t{row.Field<string>("romans")}");
        cells[counter, 1].PutValue(row.Field<string>("Street_name"));
    }
}
worksheet.HorizontalPageBreaks.Add(counter + 1);
worksheet.VerticalPageBreaks.Add(counter + 1);

}

aspose support.zip (189.7 KB)

@Remus87

It appears you are encountering an “Invalid column index” error when attempting to save a workbook as .ods after reaching a certain number of rows. This issue may stem from the limitations of the ODS format, which typically supports a maximum of around 10,000 rows, unlike other formats such as XLSX or PDF that you mentioned are functioning correctly.

To troubleshoot this issue, consider the following steps:

  1. Check ODS Limitations: Verify that your data does not exceed the maximum row limit for the ODS format. If it does, this could be the source of the error.

  2. Reduce Data Size: If feasible, try to reduce the number of rows in your dataset or split your data across multiple sheets or files to stay within the ODS limits.

  3. Use Alternative Formats: If ODS is not a strict requirement, consider continuing to use formats like XLSX or PDF, which do not present this issue.

  4. Update Aspose.Cells: Ensure you are using the latest version of Aspose.Cells, as updates may include important bug fixes and enhancements related to file handling.

If you require further assistance, please provide a minimal code snippet that replicates the issue, and I will be glad to help you debug it.

i’ve added code snippet and samples

@Remus87,

Thanks for the sample CSV files and screenshots.

I reproduced the issue as you mentioned by using your sample code snippet with the template CSV file. I found an exception “Invalid column index” when saving to ODS file.

We require thorough evaluation of the issue. We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): CELLSNET-59077

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.

Thanks Amjad

@Remus87,

You are welcome. We will ensure to keep you informed with updates as soon as they become available regarding your issue.

@Remus87
Please remove the line worksheet.VerticalPageBreaks.Add(counter + 1); because the max column is 16384 in xlsx.
We will ignore the invalid vertical page breaks too when saving ods file.

Works great . Thanks Simon
Not sure why we’ve added the vertical page breaks command as we only needed horizontal page breaks to activate for each specific grouping. But i think would be good to be captured the error at that line instead of throwing it at runtime when saving the wbook.
Also testing on a bigger dataset than supplied and got the message: “The count of HPageBreaks cannot be larger than 1024” and because it pointed us to the right line of command we’ll just add a condition to overcome this if bigger than 1024.

@Remus87,

We are glad to hear that removing the suggested line of code resolves your issue. Additionally, as we mentioned, our upcoming release will automatically skip or ignore such invalid vertical page breaks when saving files.