什么样的标题签名是0x7473657571655220?

时间:2022-01-21 20:23:53

I'm trying to read an excel file with apache POI. However, at runtime i get a NotOLE2FileException. I've found this question, which is similar, but here the error is clearly that there is no file at all. I actually have a file, and have a signature, but I have no clue what kind of signature that is, or how I can read the file. Google yields no results.

我正在尝试用apache POI读取excel文件。但是,在运行时我得到一个NotOLE2FileException。我发现了这个类似的问题,但这里的错误显然是根本没有文件。我实际上有一个文件,并有一个签名,但我不知道是什么样的签名,或我如何读取文件。谷歌没有结果。

My Code:

我的代码:

File file = new File("mypath/myfile.xls");
if(!file.exists()){
    throw new IllegalArgumentException("File does not exist");
}   
try {
    Workbook wb = WorkbookFactory.create(file); //<--- throws exception

//etc...

Error:

错误:

org.apache.poi.poifs.filesystem.NotOLE2FileException: Invalid header signature; read 0x7473657571655220, expected 0xE11AB1A1E011CFD0 - Your file appears not to be a valid OLE2 document
    at org.apache.poi.poifs.storage.HeaderBlock.<init>(HeaderBlock.java:181)
    at org.apache.poi.poifs.storage.HeaderBlock.<init>(HeaderBlock.java:140)
    at org.apache.poi.poifs.filesystem.NPOIFSFileSystem.<init>(NPOIFSFileSystem.java:232)
    at org.apache.poi.poifs.filesystem.NPOIFSFileSystem.<init>(NPOIFSFileSystem.java:168)
    at org.apache.poi.ss.usermodel.WorkbookFactory.create(WorkbookFactory.java:250)
    at org.apache.poi.ss.usermodel.WorkbookFactory.create(WorkbookFactory.java:222)
    at org.apache.poi.ss.usermodel.WorkbookFactory.create(WorkbookFactory.java:201)
    at providers.ExcelFileReader.getRequestsFromExcelFile(ExcelFileReader.java:25)
    at Test.main(Test.java:13)

I just need to understand why my xls-file has a strange header, and what that means, to be able to solve this one. Does anyone know? Might there be any work arounds?

我只需要理解为什么我的xls文件有一个奇怪的标题,这意味着能够解决这个问题。有人知道吗?可能有任何工作吗?

Update: as far as I can see, it is a perfectly valid excel file: 什么样的标题签名是0x7473657571655220?

更新:据我所知,它是一个非常有效的excel文件:

1 个解决方案

#1


4  

The ASCII equivalent of 0x74736575716552 is "tseuqeR" ("Request" spelled backwards). It appears that you have a plain text file that you are asking POI to open as an Excel file.

ASCII等价物0x74736575716552是“tseuqeR”(“请求”拼写向后)。您似乎有一个纯文本文件要求POI作为Excel文件打开。

I checked Wikipedia's List of file signatures first and when I didn't find anything used an ASCII table (man ascii if you are on Linux, online here otherwise) to convert every 2 hexadecimal digits to the equivalent character.

我首先检查了*的文件签名列表,当我没有找到任何使用过的ASCII表(如果你在Linux上,则为ascii,在这里另有在线),将每2个十六进制数字转换为等效字符。

#1


4  

The ASCII equivalent of 0x74736575716552 is "tseuqeR" ("Request" spelled backwards). It appears that you have a plain text file that you are asking POI to open as an Excel file.

ASCII等价物0x74736575716552是“tseuqeR”(“请求”拼写向后)。您似乎有一个纯文本文件要求POI作为Excel文件打开。

I checked Wikipedia's List of file signatures first and when I didn't find anything used an ASCII table (man ascii if you are on Linux, online here otherwise) to convert every 2 hexadecimal digits to the equivalent character.

我首先检查了*的文件签名列表,当我没有找到任何使用过的ASCII表(如果你在Linux上,则为ascii,在这里另有在线),将每2个十六进制数字转换为等效字符。