Export to excel in d365fo using OfficeOpenXml

Hi, i'm using the OfficeOpenXml to export data to an excel sheet.

I copied the code MS is using in CustCollectionsExcelStatement class.

I was adding more columns and testing and at some point my working excel export failed:

"An unexpected error occurred while attempting to create the workbook that contains the selected transactions."

after debugging i found that when the number of columns is more than 40 the creation of a table range done in the code below messes up the worksheet when it is saved.

protected void setTransactionWorksheetTable(OfficeOpenXml.ExcelWorksheet _worksheet, OfficeOpenXml.ExcelRange _tableRange)
{
  var table = _worksheet.get_Tables().Add(_tableRange, _worksheet.get_Name());
  table.set_TableStyle(TableStyles::Light2);
  table.set_ShowTotal(false);
}

Anyone else seen this?

Related
Recommended