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导入功能时,发现导入的文件报错,代码中判断了文件类型:
// IO流读取文件
InputStream input = file.getInputStream();
//解析xls
HSSFWorkbook wb = new HSSFWorkbook(input);
//解析xlsx
XSSFWorkbook wbx = new XSSFWorkbook(input);
但是依旧报错:
org.apache.poi.openxml4j.exceptions.OLE2NotOfficeXmlFileException: 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)
网上查询也都是版本问题。
后来反复测试,发现xls导入没问题,但是将文件后缀直接改成xlsx导入就会报错。
将文件另存为xlsx后,再次导入,就不在报错了。
修改文件类型时最好使用另存为,避免出现版本问题。
ThesupplieddataappearstobeintheOLE2Format.YouarecallingthepartofPOIthatdealswithOOXML(OfficeOpenXML)Documents.YouneedtocalladifferentpartofPOItoprocessthisdata(egHSSFinsteadofXSSF)在做Excel导入功能时,发现导入的文件报错,代码中判断了文件类...
The
supplied
data
app
ear
s to be in the
OLE
2
Format
. You are calling the part of POI that deals with
The
supplied
data
app
ear
stobeinthe
OLE
2
Format
.YouarecallingthepartofPOIthatdealswithOOXML(OfficeOpenXML)Documents.YouneedtocalladifferentpartofPOItoprocessthis
data
(egHSSFinsteadofXSSF)
场景:easy
Excel
导入时报错,百度()之后发现是.xls文...
//获取
excel
文件流
POIFSFileSystem fileSystem = new POIFSFileSystem(myfile.getInputStream());
HSSFWorkbook workbook = new HSSFWorkbook(fileSystem);
问题出在.
今天在处理
Excel
文件时候,发现对于以xls和xlsx为后缀的文件,用以下的代码处理时候抛 The
supplied
data
app
ear
s to be in the
OLE
2
Format
.异常,百思不得其姐!!! 明明都判断类型对应的文件类型也没毛病啊!!
try {
if ((filename.endsWith(".xls"))) {
workbook = new HSSFWorkbook(inputStream);
刚开始使用new HSSFWorkbook(new FileInputStream(
excel
File))来读取Workbook,对
Excel
2003以前(包括2003)的版本没有问题,但读取
Excel
2007时发生如下异常:
org.apache.poi.poifs.filesystem.OfficeXmlFileException: The
supplied
data
app
ear
s to
function [seg] = character_segmentation(bw)
% character_segmentation: Returns the digit segments in the
supplied
binary image.
% The function uses the "segment" function, keeping only the seven
% segments in the result with largest area, and in case less than seven
% segments were found, it attempts to recall the function, making the
% separation between the already found segments cl
ear
er (by cleaning the
% bits which are there.
please read the following items before using:
1.本站仅对原软件包“依样”打包,未做过任何改动,但不保证所提供软件或程序的完整性和安全性。
1.Our website only pack up the original software without any altering, but we cannot
guarantee the integrality and safety of the software or program.
2. 请在使用前查毒 (这也是您使用其它网络资源所必须注意的) 。
2.please check the virus before using-that s what you must pay attention to while usingother net resources.
3. 由本站提供的程序对您的网站或计算机造成严重后果的本站概不负责。
3.we are not responsible for the severe result of your website or computer caused by the program
supplied
by our website.
4. 转载本站提供的资源请勿删除本说明文件。
4.when you transfer the resources of our website, please do not delete this instruction.
execl导入报错:The
supplied
data
app
ear
s to be in the Office 2007+ XML
是因为ecexl标的版本高于2007,程序不支持,需要将
HSSFWorkbook wb = new HSSFWorkbook(
excel
File);
中的HSSFWorkbook 修改为 XSSFWorkbook
XSSFWorkbook wb = new XSSF...
The
supplied
data
app
ear
s to be in the
OLE
2
Format
. You are calling the part of POI that deals with OOXML (Office Open XML) 是什么原因
这个错误通常是因为你尝试读取的 Word 文档不是 OOXML 格式(.docx),而是
OLE
2 格式(.doc)。Apache POI 库中的 `XWPFDocument` 类只能处理 OOXML 格式的文档。
如果你要读取
OLE
2 格式的 Word 文档,你可以使用 `HWPFDocument` 类。这是 Apache POI 库中处理旧版 Word 文档的类。以下是一个读取
OLE
2 格式文档的示例代码:
```
java
import org.apache.poi.hwpf.HWPFDocument;
import org.apache.poi.hwpf.extractor.WordExtractor;
import
java
.io.FileInputStream;
import
java
.io.IOException;
public class WordReader {
public static void main(String[] args) {
try {
FileInputStream file = new FileInputStream("path/to/your/doc/file.doc");
HWPFDocument doc = new HWPFDocument(file);
WordExtractor extractor = new WordExtractor(doc);
String text = extractor.getText();
System.out.println(text);
doc.close();
} catch (IOException e) {
e.printStackTrace();
请注意,在使用 `HWPFDocument` 时,你需要将文档的扩展名更改为 `.doc`,并且使用 `WordExtractor` 来提取文档的内容。
希望这次能够解决你的问题!如果还有其他疑问,请随时问我。