Save the xl sheet to a temp file (for example using the oreilly upload
servlet), and then read it in using a FileInputStream. That is much more
robust. 
-
Avik


On Tue, 2003-02-04 at 09:38, Vinit Khandelwal wrote:
> Please find the query description below:
> 
> I submit the excel file from the client using IE Explorer 5.5 by the code
> given 
> below:
> 
> <form action="http://xxx/POIExample"; method="post" enctype="multipart/form-
> data">
>   <input size="70" type="file" name="spreadsheet" />
>   <input type="submit" value="Upload File" />
> </form>
> 
> In the servlet (running in Weblogic 6.1) I remove the extra data which comes
> in 
> the HttpServletRequest and have the extract (only the content of the file)
> in 
> the String "file": 
> 
> Then I use the following code to create the workbook
> 
> //the parse method returns the content of the excel file which was uploaded
> 1. String file = parse(req.getInputStream(),req.getContentLength
> (),req.getContentType());
> 
> //this line creates the ByteArrayInputStream
> 2. ByteArrayInputStream is = new ByteArrayInputStream(file.getBytes());
> 
> //then try to create the workbook
> 3. HSSFWorkbook wb = new HSSFWorkbook(is);
> 
> If i upload the excel file from the client which is less than 64.5 kb, the 
> HSSFWorkbook gets created successfully and I am able to read data.
> 
> But if the excel file size is greater than 64.5 kb it throws an exception
> 
> java.io.IOException: block[ 63 ] already removed
>         at org.apache.poi.poifs.storage.BlockListImpl.remove
> (BlockListImpl.java:133)
>         at
> org.apache.poi.poifs.storage.BlockAllocationTableReader.fetchBlocks
> (BlockAllocationTableReader.java:227)
>         at org.apache.poi.poifs.storage.BlockListImpl.fetchBlocks
> (BlockListImpl.java:165)
>         at org.apache.poi.poifs.filesystem.POIFSFileSystem.processProperties
> (POIFSFileSystem.java:441)
>         at org.apache.poi.poifs.filesystem.POIFSFileSystem.<init>
> (POIFSFileSystem.java:139)
>         at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>
> (HSSFWorkbook.java:175)
>         at
> lehman.brokerlink.servlets.POIExample.doProcess(POIExample.java:88)
>         at lehman.brokerlink.servlets.POIExample.doPost(POIExample.java:26)
>         at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
>         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
>         at weblogic.servlet.internal.ServletStubImpl.invokeServlet
> (ServletStubImpl.java:265)
>         at weblogic.servlet.internal.ServletStubImpl.invokeServlet
> (ServletStubImpl.java:200)
>         at weblogic.servlet.internal.WebAppServletContext.invokeServlet
> (WebAppServletContext.java:2456)
>         at weblogic.servlet.internal.ServletRequestImpl.execute
> (ServletRequestImpl.java:2039)
>         at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:139)
>         at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120)
> 
> Please do let me know why this kind of exception may be getting thrown
>  and/or how to rectify this.
> 
> Thanks in advance.
> Vinit
> *********************************************************************
> Disclaimer: The information in this e-mail and any attachments is
> confidential / privileged. It is intended solely for the addressee or
> addressees. If you are not the addressee indicated in this message, you may
> not copy or deliver this message to anyone. In such case, you should destroy
> this message and kindly notify the sender by reply email. Please advise
> immediately if you or your employer does not consent to Internet email for
> messages of this kind.
> *********************************************************************
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 




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

Reply via email to