I am getting exception while uploading the xlsxand csv file.
I have to use same upload functionality for all csv, xls and xlsx.
but HSSFWorkbook is throwing exceptions as bellow.
for csv: java.io.IOException: Unable to read entire header; 27 bytes read; expected 32 bytes
for xlsx: The supplied data appears to be in the Office 2007+ XML..
You are calling the part of POI that deals with OLE2 Office Documents.
You need to call a different part of POI to process this data (eg XSSF instead of HSSF)
for xls file its working fine.
can you please help me to handle these three types of file using HSSFWorkbook.
This has nothing to do with either the act of uploading files, nor with JSF. The reason is that apparently the code tries to open the file after uploading, and the library classes you're using (HSSF) simply can't handle XLSX files. The solution is to rewrite your code to handle both XLS and XLSX files by using the SS classes. This should help: http://poi.apache.org/spreadsheet/converting.html
Now I am able to manage xls and xlsx but I am not getting what to do for csv files.
could you please help me to get some idea.
Thanks and Regards,
Joined: Mar 22, 2005
What has the code previously been doing with CSV? I don't know what kind of support POI has for CSV; probably not much. But there are any number of libraries out there that can read CSVs. Given that it's a relatively simple format, those aren't hard to use.