Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Struts
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Jeanne Boyarsky
Ron McLeod
Paul Clapham
Liutauras Vilda
Sheriffs:
paul wheaton
Rob Spoor
Devaka Cooray
Saloon Keepers:
Stephan van Hulst
Tim Holloway
Carey Brown
Frits Walraven
Tim Moores
Bartenders:
Mikalai Zaikin
Forum:
Struts
error : upload excel file
Rajni Patel
Ranch Hand
Posts: 85
posted 13 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Hi,
I want to upload excel file using struts1.
In my action class below code I have written,
Error is coming on line
fileSystem = new POIFSFileSystem(fs);
java.io.IOException: Invalid header signature; read 63361219987247567, expected
-2226271756974174256
I have find from some forum, because of Excel file format error is coming.
I have excel 2003 and just I create 2 rows and 2 column, simple excel file.
Please, could anybody can tell me , what's the problem?
thanks,
UploadExcelForm uploadExcel = (UploadExcelForm) form; FormFile excelFile = uploadExcel.getExcelFile(); FileInputStream fs = null; System.out.println("excelFile.getFileName() = " + excelFile.getFileName()); POIFSFileSystem fileSystem = null; try { fs = new FileInputStream("c:\\Temp\\temp.xls"); } catch (FileNotFoundException fe) { System.out.println("File not found in the specified path."); fe.printStackTrace(); } catch (Exception fe) { System.out.println("Exception File not found in the specified path."); fe.printStackTrace(); } try { System.out.println(" fs.toString() = " +fs.toString()); fileSystem = new POIFSFileSystem(fs); System.out.println("fileSystem = " + fileSystem); HSSFWorkbook workbook = new HSSFWorkbook(fileSystem); System.out.println("workbook = " + workbook); HSSFSheet sheet = workbook.getSheetAt(0); System.out.println("sheet = " + sheet.getLastRowNum()); } return mapping.findForward("add"); } catch (IOException ex) { System.out.println("IOException "); ex.printStackTrace(); return mapping.findForward("add"); }
Radovan Vukovic
Greenhorn
Posts: 19
posted 13 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
This error coming probably from your file, could be that is corrupted?
Or (I did not work with version after 3.5) i know that this version did not support excel autofilter. Can be that this is in your file?
Rajni Patel
Ranch Hand
Posts: 85
posted 13 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
just I did entry in 2 row & 2 column like name and no. and I close the file.
I have Excel 2003.
Please, Give me some suggestion.
Thanks
Radovan Vukovic
Greenhorn
Posts: 19
posted 13 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Why you are using POIFSFileSystem?
Only to create HSSFWorkbook?
If this is only reason then you can try and create
HSSFWorkbook
directly from InputStream
Check please
Rajni Patel
Ranch Hand
Posts: 85
posted 13 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Thanks for reply.
My intense is to read excel file, and insert into database. I have change in my code. but still same error is coming.
Invalid header.
try { fs = new FileInputStream("c:\\Temp\\report.xls"); System.out.println("fs.read = " + fs.read()); } catch (FileNotFoundException fe) { System.out.println("File not found in the specified path."); fe.printStackTrace(); } catch (Exception fe) { System.out.println("Exception File not found in the specified path."); fe.printStackTrace(); } try { HSSFWorkbook workbook = new HSSFWorkbook(fs); System.out.println("workbook = " + workbook); HSSFSheet sheet = workbook.getSheetAt(0); System.out.println("sheet = " + sheet.getLastRowNum()); } catch (IOException ex) { System.out.println("IOException "); ex.printStackTrace(); return mapping.findForward("add"); }
please guide me.
Thanks
Rajni Patel
Ranch Hand
Posts: 85
posted 13 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
I print message of getContenttype() for excel file. What it should come?
getContentType() = application/octet-stream or
getContentType() = application/vnd.ms-excel
Is it necessary t any fix contenttype?
thanks,
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
Unable to read entire block :202 bytes read;expected 512 bytes
Help Null Pointer Exception
How to read a txt file with space
Can we refresh the directory from middle of java code
How can I analize Excel file with Apache POI?
More...