You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@poi.apache.org by "Natu, Ashlesha [IT]" <as...@citigroup.com> on 2006/03/27 21:17:03 UTC

JakartaPOI - read excel file using HSSF

Hi, 
 
I am trying to read an Excel 2000 file using HSSF. If I hardcode the filename, the code reads it perfectly. But if I upload the file from the browser into a ServletInputStream, I get an IOException - Invalid Header signature.
 
My code is:
ServletInputStream is = request.getInputStream();
InputStream ins = (InputStream)is;
POIFSFileSystem fs = new POIFSFileSystem(ins);
HSSFWorkbook wb = new HSSFWorkbook(fs);
HSSFSheet sheet = wb.getSheetAt(0);
HSSFRow row = sheet.getRow(1);
HSSFCell cell = row.getCell((short)0);
String c1 = cell.getStringCellValue();
 
If I do 
POIFSFileSystem fs = new POIFSFileSystem(new FileInputStream("Test.xls")); 
instead, it reads the contents without errors. 
 
I am getting the following exception:
java.io.IOException: Invalid header signature; read 3255307777713450285, expected -2226271756974174256
 
Please help.
thanks, AN