NPOI 无法识别文件结尾
NPOI does not recognized end of file
我正在使用 NPOI 库来读取 .xls 和 .xlsx 文件。
但是我遇到了这个问题,GetRow() 方法不会 return null 即使行是空的。
这是代码
int idx_row = 1;
IRow currentRow = sheet.GetRow(idx_row);
while (currentRow != null)
{
JObject jsonData = new JObject();
jsonData["a"] = sheet.GetRow(idx_row).GetCell(0).StringCellValue.Replace(" ", "");
// other similar code
jsonPlateData.Add(jsonData);
idx_row++;
currentRow = sheet.GetRow(idx_row);
}
检查 sheet.LastRowNum
的值,可能该行看起来是空的,但 excel 认为它已填满。如果是这样,请打开 excel 文件并删除 "empty".
的行
我正在使用 NPOI 库来读取 .xls 和 .xlsx 文件。
但是我遇到了这个问题,GetRow() 方法不会 return null 即使行是空的。
这是代码
int idx_row = 1;
IRow currentRow = sheet.GetRow(idx_row);
while (currentRow != null)
{
JObject jsonData = new JObject();
jsonData["a"] = sheet.GetRow(idx_row).GetCell(0).StringCellValue.Replace(" ", "");
// other similar code
jsonPlateData.Add(jsonData);
idx_row++;
currentRow = sheet.GetRow(idx_row);
}
检查 sheet.LastRowNum
的值,可能该行看起来是空的,但 excel 认为它已填满。如果是这样,请打开 excel 文件并删除 "empty".