NOPI读取Excel2003、Excel2007或更高级的兼容性问题
出错提示:NPOI.POIFS.FileSystem.OfficeXmlFileException: The supplied data appears to be in the Office 2007+ XML. You are calling the part of POI that deals with OLE2 Office Documents. You need to call a different part of POI to process this data (eg XSSF instead of HSSF)
原因:这是因为NPOI读取2003时使用的是HSSFWorkbook,更高版本读取需要使用XSSFWorkbook
解决方式:
将代码中HSSFWorkbook修改为XSSFWorkbook,最好是导入文件时选择版本,这样处理更好
IWorkbook workbook = new XSSFWorkbook(file);