Discussion:
EXCEPTION : Invalid header signature
Bob Gosling
2010-09-02 04:50:49 UTC
Permalink
Details :
Java = jdk1.5.0_16
O/S = Linux x86_64
POI = 3.6

Downloaded Excel file from
http://www.bankofengland.co.uk/markets/money/eligiblesecurities.xls
This appears to be a valid spreadsheet and I can copy it ( in binary mode ) to
Windows and can open it in Excel (11.8320.8221 ) SP3

When I attempt to run my code I get the following :

EXCEPTION : Invalid header signature; read 0xE011BDBFEFBDBFEF, expected
0xE11AB1A1E011CFD0
java.io.IOException: Invalid header signature; read 0xE011BDBFEFBDBFEF,
expected 0xE11AB1A1E011CFD0
at org.apache.poi.poifs.storage.HeaderBlockReader.<init>
(HeaderBlockReader.java:107)
at org.apache.poi.poifs.filesystem.POIFSFileSystem.<init>
(POIFSFileSystem.java:151)
at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>
(HSSFWorkbook.java:317)
at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>
(HSSFWorkbook.java:298)
at com.scb.race.eligibilityreports.EligibilityReport.getBOEList
(EligibilityReport.java:128)
at com.scb.race.eligibilityreports.EligibilityReport.<init>
(EligibilityReport.java:42)
at com.scb.race.eligibilityreports.EligibilityReport.main
(EligibilityReport.java:32)

Here's an extract from my code ( line 128 is commented ) :

========================================================
try {
if ( DEBUG ) { System.out.println("Reading BOE file " +
m_boeFile); }
File f = new File(m_boeFile);
InputStream is = new FileInputStream(f);
//XSSFWorkbook wb = new XSSFWorkbook(is);
HSSFWorkbook wb = new HSSFWorkbook(is); // This is
line 128
//XSSFSheet sheet = wb.getSheetAt(0);
HSSFSheet sheet = wb.getSheetAt(0);
Iterator rows = sheet.rowIterator();
//XSSFRow row = null;
HSSFRow row = null;
//XSSFCell cell = null;
HSSFCell cell = null;
String isin = null;
int rcount = 0;
while ( rows.hasNext() ) {
if ( rcount > BOE_OFFSET ) {
//row = (XSSFRow)rows.next();
row = (HSSFRow)rows.next();
cell = row.getCell(1);
if ( cell.getStringCellValue() !=
null ) {
isin = cell.getStringCellValue
();
if ( DEBUG ) {
System.out.println("ISIN " + isin); }
m_boeList.add(isin);
rcount++;
}
}
}

=================================================================

As you can see, I've tried using XSSF instead of HSSF but that failed at a
later point and I've checked the file, it isn't XML it's binary. The file is
definately an OK Excel spreadsheet.

I am flummoxed! Any advice gratefully accepted.
Bob Gosling
2010-09-03 03:57:52 UTC
Permalink
Please ignore my error.

Problem was due to classic "copy from a to b then accidentally read c",
coupled with an error in the download program.

Doh!

I could go into detail but it's much too emabarrassing. Suffice to say , if
you get this error check you really can read the file with Excel - the one
you downloaded and not another good Excel file somewhere else .....
--
View this message in context: http://apache-poi.1045710.n5.nabble.com/EXCEPTION-Invalid-header-signature-tp2801693p2801704.html
Sent from the POI - User mailing list archive at Nabble.com.
Continue reading on narkive:
Loading...