java用poi包导入excel时出现poi . Characters larger than 4 bytes are not supported: byte 0x88 implies a

作者: admin 分类: 异常处理 发布时间: 2018-12-13 13:15  阅读: 637 views
由于工作需要,处理20w条左右的数据
步骤:
1. 从线上拉取20w条记录为EXCEL格式 (5w记录/个)可以更多,
2. java读取EXCEL数据,进行解析并导入
3.文件格式是 excel 2007版本
有三个文件导入成功,还有一个一直无法读取文件。
报错如下:
org.apache.poi.POIXMLException: java.lang.reflect.InvocationTargetException
	at org.apache.poi.xssf.usermodel.XSSFFactory.createDocumentPart(XSSFFactory.java:62)
	at org.apache.poi.POIXMLDocumentPart.read(POIXMLDocumentPart.java:427)
	at org.apache.poi.POIXMLDocument.load(POIXMLDocument.java:156)
	at org.apache.poi.xssf.usermodel.XSSFWorkbook.<init>(XSSFWorkbook.java:254)
	at com.test.test.getWorkbok(test.java:55)
	at com.test.test.main(test.java:37)
Caused by: java.lang.reflect.InvocationTargetException
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
	at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
	at org.apache.poi.xssf.usermodel.XSSFFactory.createDocumentPart(XSSFFactory.java:60)
	... 5 more
Caused by: java.io.CharConversionException: Characters larger than 4 bytes are not supported: byte 0x88 implies a length of more than 4 bytes
	at org.apache.xmlbeans.impl.piccolo.xml.UTF8XMLDecoder.decode(UTF8XMLDecoder.java:162)
	at org.apache.xmlbeans.impl.piccolo.xml.XMLStreamReader$FastStreamDecoder.read(XMLStreamReader.java:762)
	at org.apache.xmlbeans.impl.piccolo.xml.XMLStreamReader.read(XMLStreamReader.java:162)
	at org.apache.xmlbeans.impl.piccolo.xml.PiccoloLexer.yy_refill(PiccoloLexer.java:3474)
	at org.apache.xmlbeans.impl.piccolo.xml.PiccoloLexer.yylex(PiccoloLexer.java:3958)
	at org.apache.xmlbeans.impl.piccolo.xml.Piccolo.yylex(Piccolo.java:1290)
	at org.apache.xmlbeans.impl.piccolo.xml.Piccolo.yyparse(Piccolo.java:1400)
	at org.apache.xmlbeans.impl.piccolo.xml.Piccolo.parse(Piccolo.java:714)
	at org.apache.xmlbeans.impl.store.Locale$SaxLoader.load(Locale.java:3439)
	at org.apache.xmlbeans.impl.store.Locale.parseToXmlObject(Locale.java:1270)
	at org.apache.xmlbeans.impl.store.Locale.parseToXmlObject(Locale.java:1257)
	at org.apache.xmlbeans.impl.schema.SchemaTypeLoaderBase.parse(SchemaTypeLoaderBase.java:345)
	at org.openxmlformats.schemas.spreadsheetml.x2006.main.SstDocument$Factory.parse(Unknown Source)
	at org.apache.poi.xssf.model.SharedStringsTable.readFrom(SharedStringsTable.java:115)
	at org.apache.poi.xssf.model.SharedStringsTable.<init>(SharedStringsTable.java:102)
	... 10 more
Exception in thread "main" java.lang.NullPointerException
	at com.test.test.main(test.java:38)

 

数据一直尝试未果。后台经过度娘,了解到是文件编码有问题,存在特殊字符。
但具体是哪里出现了问题,是什么格式的数据?表情符号导致这种情况,没有结论。
反复导出数据尝试,依然报错。
最后,将excel转换为2003版本的xls格式。大小翻了好几倍,居然成功了。
数据最终入库,但是原因不详,待查….

   原创文章,转载请标明本文链接: java用poi包导入excel时出现poi . Characters larger than 4 bytes are not supported: byte 0x88 implies a

如果觉得我的文章对您有用,请随意打赏。您的支持将鼓励我继续创作!

发表评论

电子邮件地址不会被公开。 必填项已用*标注

更多阅读