首页新闻找找看学习计划

excel导入,本地windows环境可以,linux服务器失败

0
悬赏园豆:100 [已解决问题] 解决于 2019-07-30 15:19

报错信息如下:
Request processing failed; nested exception is org. apache poi poifs filesystem OfficeXmlFile Exception: 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)
描述服务器遇到一个意外的情况,阻止它完成请求
Exception
org. springframework. web. util. NestedServletException: Request processing failed; nested exception is org. apache poi. 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 Xss instead of HSSF
processReque
ework Servlet java: 973)
org. springframework. web. servlet Framework Servlet doPost(FrameworkServlet java: 863)
ax.servlet.httphttpServletservice(htt
let java: 660)
org. springframework. web. servlet Framework Servlet. service(FrameworkServlet java: 837)
org. apache tomcat websocket server. WsFilter do Filter(WsFilter, java: 53)
com. thetransactioncompany cors CORSFilter doFilter( CORSFilter,java: 195)
com. thetransactioncompany cors CORS Filter do Filter(CORSFilter java: 266)
org. apache poi. poifs filesystem OfficeXmlFile Exception: 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)
org. apache poi. poifs storage Header Block. <init>(Header Block java: 130)
org. apache poi. poifs storage Header Block. <init>(Header Block. java: 117)
org. apache poi. poifs. filesystem. POIFSFile System <init>(POIFSFile System java: 294)
org. apache poi hssf. usermodel HSSFWorkbook <init>(HSSFWorkbook, java: 382)
cn.cqsoft commons utils. ReadExcelUtil getWork Book(Read ExcelUtil java: 131)

River111的主页 River111 | 初学一级 | 园豆:110
提问于:2019-07-25 17:25

谢谢大家回复,我是判断了的
通过这个方法创建Workbook实例,这个方法是处理了xls,xlsx文件(即调用不同的api创建不相应文件的实例对象)
但是结果是:linux上导入数据就是报错(有日期数据的情况下).

River111 2个月前

/**
判断excel的版本,并根据文件流数据获取workbook
@throws IOException

/
public static Workbook getWorkBook(InputStream is,File file) throws Exception{

    Workbook workbook = null;
    if(file.getName().endsWith(EXCEL_XLS)){
        workbook = new HSSFWorkbook(is);
    }else if(file.getName().endsWith(EXCEL_XLSX)){
        workbook = new XSSFWorkbook(is);
    }
    
    return workbook;
}
River111 2个月前
< >
分享
最佳答案
0

谢谢大家了,问题找到了,我上传文件格式是xls格式,我后台有段死编码:读取文件是xlsx格式,因此报错!

River111 | 初学一级 |园豆:110 | 2019-07-30 15:14
其他回答(6)
0

You need to call a different part of poi to process this data(eg XSSF instead of HSSF)

试试看呀

收获园豆:25
czd890 | 园豆:7028 (大侠五级) | 2019-07-25 22:12
1
收获园豆:40
ycyzharry | 园豆:18380 (专家六级) | 2019-07-25 23:34
0

判断excel是.xls还是 .xlsx结尾 这个 是有区别的。用的api 不同的

收获园豆:20
^keepHungry$ | 园豆:610 (小虾三级) | 2019-07-26 09:37
0

你用的什么dll,两个系统的dll不一样吧

收获园豆:5
jqw2009 | 园豆:1836 (小虾三级) | 2019-07-26 17:06
0

系统之间配置文件问题

收获园豆:5
皮皮猪! | 园豆:213 (菜鸟二级) | 2019-07-27 09:09
0

使用aspose.excel插件。兼容 linux;

收获园豆:5
马玉溁 | 园豆:33 (初学一级) | 2019-07-28 17:43
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册