Free Support Forum - aspose.com

ExportDataTable with ExportTableOptions.ExportColumnName = false doesn't work

Hello,

The following code works well if all data is double:
Range range = ws.Cells.CreateRange(ltCell,rbCell);
DataTable dataTable = ws.Cells.ExportDataTable(range.FirstRow, range.FirstColumn,
range.RowCount, range.ColumnCount, false);

Now I need to skip error values:
ExportTableOptions exportTableOptions = new ExportTableOptions();
exportTableOptions.ExportColumnName = false;
exportTableOptions.SkipErrorValue = true;

DataTable dataTable = ws.Cells.ExportDataTable(range.FirstRow, range.FirstColumn,
range.RowCount, range.ColumnCount, exportTableOptions);

And code doesn’t work.

If I change ExportColumnName to true than code works well but without first row.
exportTableOptions.ExportColumnName = true;

My test excel is simple:
A B C D

11 12 x 14
21 -
23 24



What should I do?

Paul




Hi,

For mixed values, you should use ExportDataTableAsString method instead.

Hi,

I any case I can use ExportArray method for my needs.

object[,] data = ws.Cells.ExportArray(range.FirstRow, range.FirstColumn, range.RowCount, range.ColumnCount);

for (int i = 0; i < range.RowCount; i++)
for (int j = 0; j < range.ColumnCount; j++)
{
if (data[i, j] is Double)
{
// do smth
}
else {}
}

Paul

Hi,

I any case I can use ExportArray method for my needs. Isn’t it?

object[,] data = ws.Cells.ExportArray(range.FirstRow, range.FirstColumn, range.RowCount, range.ColumnCount);

for (int i = 0; i < range.RowCount; i++)
for (int j = 0; j < range.ColumnCount; j++)
{
if (data[i, j] is Double)
{
// do smth
}
else {}
}

Paul

I do not need data as string. I need double values only. And I need to skip non-double values.

Hi,

I think, you are right in using object array then. The above code shared by you should work well.