ExportDataTable Not Exporting Some Columns

Hi Everybody -


See the attached Sample xlsx. My issue is that ExportDataTable is not capturing all the columns on that spreadsheet. Everything after and including the “Account Name” column is not coming back in the DataTable result object.

Here’s the kicker - if I go and resize the “Account Name” column it then is included in the DataTable export correctly.

Has anybody run into this issue? I’ve tried a variety of Export and Load options and haven’t been able to figure it out.

Here is the code I’m using:

//setup export options
var etos = new ExportTableOptions();
etos.ExportAsString = false;

//setup the load options
var lo = new LoadOptions();
lo.LoadDataAndFormatting = false;

//get the workbook
var wb = new Workbook(fileBytes, lo);

//get the worksheet (always the first one)
var ws = wb.Worksheets[0];

//wipe out empty cols
ws.Cells.DeleteBlankColumns();

//wipe out empty rows
ws.Cells.DeleteBlankRows();

//export the worksheet to a DT
DataTable = ws.Cells.ExportDataTable(0, 0, ws.Cells.Rows.Count, ws.Cells.Columns.Count, etos);

Hi,


Well, the Cells.Rows/Columns.Count would only includes those cells which are initialized, the cells in rows/columns with default width won’t be included. Please use Cells.MaxDataRow and Cells.MaxDataColumn attributes instead. Please change the line of code:
i.e.,
//export the worksheet to a DT
DataTable = ws.Cells.ExportDataTable(0, 0, ws.Cells.Rows.Count, ws.Cells.Columns.Count, etos);

with:

//export the worksheet to a DT
DataTable = ws.Cells.ExportDataTable(0, 0, ws.Cells.MaxDataRow +1, ws.Cells.MaxDataColumn +1, etos);


Let us know if you still find any issue.

Thank you.

Perfect! Thanks for the help.

Hi,


Good to know that it figures out your issue now. Feel free to contact us any time if you need further help or have some other issue or queries, we will be happy to assist you soon.

Thank you.