【发布时间】:2018-02-28 16:47:37
【问题描述】:
我使用 NPOI 读取 excel 文件。如果单元格是数字,则代码为
movie.YourRating = watchListSheet.GetRow(rowNumber).GetCell(newIMDBformat["Your Rating"], MissingCellPolicy.CREATE_NULL_AS_BLANK).NumericCellValue;
但是,如果单元格为空,则返回异常:
"Can not get numerical value from text cell."
NumericCellValue 改为 StringCellValue 后,同样返回异常。我想知道我应该用什么来阅读空单元格。 excel 文件由 SetCellValue() 编写。谢谢。
【问题讨论】:
-
你能贴出你用来创建excel文件的代码吗?我尝试了您在阅读我在 Excel 中创建的工作簿之前所做的操作,它运行良好:我没有收到异常并且返回的数值为零。