I need to compare two spreadsheets in separate workbooks. The columns are in different orders though, so I thought I'd create a data table for each and then compare based on column header name. I tried the below code, but it's throwing an InvalidOperationException saying "Value cannot be null, row: 8, col: 56"
That cell is in fact blank, which is perfectly fine. It's also not the first cell on that line that is blank, so I'm not sure why it is bailing.
public DataTable Get(string path) {
using var package = new ExcelPackage(new FileInfo(@"....xlsx"));
var ws = package.Workbook.Worksheets[0];
var table = ws.Tables[0];
var opt = ToDataTableOptions.Create(x => {
x.ExcelErrorParsingStrategy = ExcelErrorParsingStrategy.HandleExcelErrorsAsBlankCells;
x.FirstRowIsColumnNames = true;
});
return table.ToDataTable(opt);
}
I need to compare two spreadsheets in separate workbooks. The columns are in different orders though, so I thought I'd create a data table for each and then compare based on column header name. I tried the below code, but it's throwing an
InvalidOperationExceptionsaying "Value cannot be null, row: 8, col: 56"That cell is in fact blank, which is perfectly fine. It's also not the first cell on that line that is blank, so I'm not sure why it is bailing.