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)