POI:意外的记录类型 org.apache.poi.hssf.record.HyperlinkRecord [英] POI: Unexpected record type org.apache.poi.hssf.record.HyperlinkRecord

查看:43
本文介绍了POI:意外的记录类型 org.apache.poi.hssf.record.HyperlinkRecord的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在处理一项简单的任务:读取 Excel 文件并将其转换为对象.但是,我在读取 Excel 文件 (.xls) 时遇到了问题我将从外部系统接收它(也许他们会自动生成它).如果我打开它并进行简单的保存(无论是否更改 Excel 文件中的任何内容),我的解析器逻辑都可以正常工作.但是,如果我不编辑和保存文件并尝试按原样解析原始文件,则在加载 .xls 文件时我会在这一行出现异常:

I am working on a simple task: Reading an Excel file and converting it to an object. Though, I am facing a problem in reading the Excel file (.xls) I will receive it from an external system (maybe they autogenerated it). If I open it and just do a simple save (with or without changing anything in the Excel file), my parser logic works fine. But if I don't edit and save the file and try to parse the original file as is, I get an exception at this line while loading the .xls file:

HSSFWorkbook xlsWorkbook = new HSSFWorkbook(inputDocument);

以下是例外:

java.lang.RuntimeException: Unexpected record type (org.apache.poi.hssf.record.HyperlinkRecord)
at org.apache.poi.hssf.record.aggregates.RowRecordsAggregate.<init>(RowRecordsAggregate.java:97)
at org.apache.poi.hssf.model.InternalSheet.<init>(InternalSheet.java:217)
at org.apache.poi.hssf.model.InternalSheet.createSheet(InternalSheet.java:156)
at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:337)
at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:289)
at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:224)
at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:382)
at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:364)

我在谷歌上搜索了可能的解决方案;但从未发现任何!有人可以指导我解决问题吗?

I have googled for possible solutions; but never found any! Can somebody lead me a way to resolve it?

PS:我什至尝试用最新版本的 POI (3.12) 加载 .xls,但没有成功!

PS: I even tried loading .xls with the recent versions of POI (3.12) but with no success!

谢谢

推荐答案

讨论在 https://bz.apache.org/bugzilla/show_bug.cgi?id=52447 表示这可能是由 Microsoft Excel 似乎可以正常处理的非标准 Excel 文件引起的,但 Apache POI 可能会卡住.您可以尝试以下操作:

Discussion at https://bz.apache.org/bugzilla/show_bug.cgi?id=52447 indicates that this can be caused by non-standard Excel files that Microsoft Excel seems to handle gracefully, but Apache POI can choke on. You can try to following things:

  • 确保您使用最新版本的 POI (3.13),因为有许多可能与之相关的错误修正
  • 向生成文件的应用程序报告问题,以尝试使其以更标准的方式提供文件
  • 使用对您失败的示例文件向 Apache POI 报告问题

这篇关于POI:意外的记录类型 org.apache.poi.hssf.record.HyperlinkRecord的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆