cancel
Showing results for 
Search instead for 
Did you mean: 

How to set the header of the file to excel type when writing it?

Former Member
0 Kudos

Hello,

I am using POI API to read an excel file that I have previously written using Java, but not using POI (I've written the file using Microsoft office xml and then writing it using FileOutputStream with an xls extension).

The problem is that when I read back the file I am getting this error:

The system was unable to upload the file: Invalid header signature; read 7311066695147732796, expected -2226271756974174256.

which means that the header of the file is not excel typed.

If I manually open the file and save it as excel POI is able to read it but I don't want to do this as this entire process of writing/reading the file should be automated. I don't want to use POI for writing the file because POI cannot provide me everything that I need when Microsoft office xml can.

So, my question is simple: Is there a way, using java, to set the header of a file to excel so that POI will recognize it as such?

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

hi roy,

@see: http://poi.apache.org/hssf/index.html

"HSSF is the POI Project's pure Java implementation of the Excel '97(-2007) file format. It does not support the new Excel 2007 .xlsx OOXML file format, which is not OLE2 based."

maybe jexcelapi supports you in writing your xls:

http://jexcelapi.sourceforge.net/

hth, jens

Former Member
0 Kudos

Hi Jens,

Yes I've noticed this as well few days ago.

Thanks for the other link but this API does not support excel 2007 either.

I guess I will just use SAX/DOM to read the excel as xml...

Former Member
0 Kudos

hi roy,

well that's right: jexcelapi does not support xlsx, but is a stronger api than poi.

if you need an ooxml approach, that hope that ms does not change the specification and proceed with sax/ dom or jaxb, because as i know, there is no gnu-licensed api available for xlsx.

good luck,

regards, jens

Answers (0)