How to use NPOI to read Excel spreadsheet that con

2020-02-27 11:05发布

When I read Excel worksheet using NPOI, empty cells are skipped. For example, it the row contains A, B, , C and I read it using

IRow row = sheet.GetRow(rowNb)

then row.Cells[1].ToString() will output B (as expected) but row.Cells[2].ToString() will output C instead of an empty string. Is there a way to keep empty cells? Thanks.

标签: c# excel npoi
1条回答
Luminary・发光体
2楼-- · 2020-02-27 11:20

Try the GetCell method with the MissingCellPolicy:

ICell cell = row.GetCell(2, MissingCellPolicy.RETURN_NULL_AND_BLANK);
查看更多
登录 后发表回答