Hi
I replied once yesterday and specifically removed avik's personal email
address that was automatically filled on the reply bar .. but since I didn't
get any postings I assumed that the msg didn't get anywhere.. so I am
sending again..
1. Is there any example of using BlockingInputStream ?
2. I tried using poi2.0 too and am encountering the same problem.
3. I tried using the event model too and used blocking input stream and read
one byte at a time and put them into a byte array and then created
poifsfilesystem from the byte array input stream and created a workbook from
that.. it works for some small xls files but fails when I send a file of
more than 6000 rows. Here is the code that I am using the struts action..
// get the file from form
FormFile prodFile = uploadForm.getFile();
String fileName = prodFile.getFileName();
log__.info("file name = " + fileName + "... fileSize = " +
prodFile.getFileSize());
// create hssf object from the input stream
POIFSFileSystem fs = null;
InputStream fin = null;
HSSFWorkbook wb = null;
try {
fin = prodFile.getInputStream();
BlockingInputStream bis = new BlockingInputStream(fin);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
int ch= -1;
while ((ch=bis.read()) > -1){
baos.write(ch);
}
byte[] inputBytes = baos.toByteArray();
//fs = new POIFSFileSystem(new BlockingInputStream(fin));
fs= new POIFSFileSystem(new ByteArrayInputStream(inputBytes));
log__.info("after poifs file system");
wb = new HSSFWorkbook(fs);
log__.info("After creating hssf workbook ");
if (wb != null)
log__.info("no. of rows = " +
wb.getSheetAt(0).getPhysicalNumberOfRows());
}
catch (Exception e){
e.printStackTrace();
}
finally {
fin.close();
}
thanks
Shyamala
-----Original Message-----
From: Avik Sengupta [mailto:[EMAIL PROTECTED]
Sent: Saturday, August 16, 2003 5:18 AM
To: POI Users List
Subject: Re: RE: hssf upload file issue
Our experience has been that reading an excel file works in one setup, and
not in another, its usually the case that the file has been corrupted in
transit. Thousands of files are read everyday by POI :)
That said, in the last two years, there have been only TWO bugs reported in
the basic reading code that can cause issues in one environment and not the
other. You need to check if one of them is hitting you
1. You are directly sending the stream you get from the form upload to POI.
Depending on how the form upload
servlet works, you might hit the slow input stream problem. To work around,
save the file to a temp directory, and
pass the file name to poi. Thats the best solution. Or else, there is a
bufferedinputstream in contrib, that you might want to check.
2. If you are using a version prior to 2.0pre2, you might be hitting the
concurrency bug if you are processing more than one workbook at a time.
Upgrade, or even backporting the patch is not difficult.
If you can conclusively rule out either of these, check out your form upload
code.. something is getting corrupted in the process.
-------Original Message-------
> From: Narasimhan, Shyamala <[EMAIL PROTECTED]>
> Subject: RE: hssf upload file issue
> Sent: 15 Aug 2003 23:21:33
>
> Also I get this error at times
>
> java.lang.ArrayIndexOutOfBoundsException
> at
org.apache.poi.util.LittleEndian.getNumber(LittleEndian.java:557)
> at
org.apache.poi.util.LittleEndian.getUShort(LittleEndian.java:102)
> at
>
org.apache.poi.hssf.record.SSTDeserializer.manufactureStrings(SSTDeserialize
> r.java:129)
> at
> org.apache.poi.hssf.record.SSTDeserializer.readStringRemainder(SSTDes
> erializer.java:359)
> at
> org.apache.poi.hssf.record.SSTDeserializer.processContinueRecord(SSTD
> eserializer.java:320)
> at
> org.apache.poi.hssf.record.SSTRecord.processContinueRecord(SSTRecord.
> java:539)
> at
> org.apache.poi.hssf.record.RecordFactory.createRecords(RecordFactory.
> java:218)
> at
> org.apache.poi.hssf.usermodel.HSSFWorkbook.(HSSFWorkbook.java:1
> 91)
> at
> org.apache.poi.hssf.usermodel.HSSFWorkbook.(HSSFWorkbook.java:1
> 58)
>
> -----Original Message-----
> From: Narasimhan, Shyamala
[mailto:[EMAIL PROTECTED]
> Sent: Friday, August 15, 2003 2:07 PM
> To: '[EMAIL PROTECTED]'
> Subject: hssf upload file issue
>
> Hi
>
> I am trying to convert (to hssf) an xls file uploaded through struts
on a
> weblogic server.. the file gets converted if I use a standalone java
> application but fails when uploaded through the web. The file contains
more
> than 2000 rows. This is the code that converts the file
>
>
>
> // get the file from form
>
> FormFile prodFile = uploadForm.getFile();
>
> String fileName = prodFile.getFileName();
>
> log__.info("file name = " + fileName + "... fileSize = " +
> prodFile.getFileSize());
>
> POIFSFileSystem fs = new
POIFSFileSystem(prodFile.getInputStream());
>
>
>
> HSSFWorkbook wb = null;
>
> try {
>
> wb = new HSSFWorkbook(fs);
>
> }
>
> catch (Exception e){
>
> e.printStackTrace();
>
> }
>
>
>
> This is the error that I am getting
>
> java.lang.NegativeArraySizeException
>
> at
> org.apache.poi.hssf.record.SSTDeserializer.readStringRemainder(SSTDes
>
> erializer.java:335)
>
> at
> org.apache.poi.hssf.record.SSTDeserializer.processContinueRecord(SSTD
>
> eserializer.java:320)
>
> at
> org.apache.poi.hssf.record.SSTRecord.processContinueRecord(SSTRecord.
>
> java:539)
>
> at
> org.apache.poi.hssf.record.RecordFactory.createRecords(RecordFactory.
>
> java:218)
>
> at
> org.apache.poi.hssf.usermodel.HSSFWorkbook.(HSSFWorkbook.java:1
>
> 91)
>
> at
> org.apache.poi.hssf.usermodel.HSSFWorkbook.(HSSFWorkbook.java:1
>
> 58)
>
> at
> com.om.client.ui.struts.action.pmf.supplierfeed.UploadProductListActi
>
> on.perform(UploadProductListAction.java:102)
>
>
>
> can anybody pls help.
>
> Thanks
>
> Shyamala.
-------Original Message-------