public static void InitializeWorkbook(Stream stream)
{
string fileExt = Path.GetExtension(filename)
switch (fileExt)
{
case ".xls":
workbook = new HSSFWorkbook(stream)
break
case ".xlsx":
workbook = new XSSFWorkbook(stream)
break
default:
break
}
}
The supplied data appears to be in the OLE2 Format. You are calling the part of POI that deals with OOXML (Office Open XML) Documents. You need to call a different part of POI to process this data (eg HSSF instead of XSSF)
发现这个文件的格式不是标准的excel文件(.xls或者.xlsx),
调用后报上面异常
XSSFWorkbook 读取文件转化成 HXSSFWorkbook 仔桥桐 就可以读取文件
上面的依赖解析表格自己定义解析 比较灵活,但是念坦自己写的内容消宏太多
<dependency>
<groupId>cn.afterturn</groupId>
<artifactId>easypoi-spring-boot-starter</artifactId>
<version>4.4.0</version>
</dependency>
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)