Hi Folks,

I have a very interesting requirement, where I have a big excel file that is
required to be compared against a database. 

I have to build a java based web UI where the user will go and will provide
the excel file, system will compare the excel file and show in the JSP the
comparison. And system will also cache the Excel file for further
modification.

Now the user will modify the records using the web-based UI buttons and the
same changes should be reflected to the excel file via POI.



What I am going is do is to store the whole excel file as a byte array  in
the JVM cache, and the modify the POIFileSystem using that stream and then
storing it back to the JVM cache. 


SO whenever user want to download the file instead of getting it from the
filesystem, system will make the download available after reading the file
from the JVM Cache. 


The whole process has been done to avoid the file reading and writing on the
server. 


Following is the code scnipped. Where I read it from the byte array and
modify the excel file.


                //dataStream is referece to the cache class
            
            byte data[] = dataStream.getExcelFileAsBytes();
            System.out.println("Size before modification "+data.length);
            InputStream in = new ByteArrayInputStream(data);
            
            POIFSFileSystem fileSystem = new POIFSFileSystem(in);
    
            HSSFWorkbook      workBook = new HSSFWorkbook (fileSystem);
            HSSFSheet         sheet    = workBook.getSheetAt (0);//
Properties file
            
            HSSFRow row =
sheet.createRow(sheet.getPhysicalNumberOfRows()+1);
            HSSFCell cell =
row.getCell((short)MasterNodeListCompareConfig.getNodeCell());
            setCellValues(row,applicationRecord);




Following is the code where I get the error when I try to regenerate the
POIFIleSystem after modifying using the original POI byte streem using
above.

Following is the exception: 



java.io.IOException: Invalid header signature; read 1413971954370569,
expected -2226271756974174256




















---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to