The value of the cell C1 should not be a string value.

发布时间 2023-03-22 21:14:25作者: 剑仙也风流

Aspose.cells打开文件之后输出为DataTable,是将第一行作为数据类型判断,列具有混合数据集

错误代码

var cells = workbook.Worksheets[0].Cells;
var detailTable = cells.ExportDataTable(0, 0, cells.MaxRow + 1, cells.MaxColumn + 1, exportTableOptions);

正确代码

var cells = workbook.Worksheets[0].Cells;
var exportTableOptions = new ExportTableOptions { CheckMixedValueType = false, ExportColumnName = true, ExportAsString = true };
var detailTable = cells.ExportDataTable(0, 0, cells.MaxRow + 1, cells.MaxColumn + 1, exportTableOptions);