I regard this as a bug in either your servlet engine or in the servlet api itself. Test this on tomcat or some other servlet engine and see if it will work. I don't want to allow corrupt bytes/bits at the end of the file to work around something that is a result if incorrectness elsewhere.
Anyone feel differently? An Feng-I Chen wrote: >Thanks for the help, Andy. > >About the extra byte, I suspect it comes from the html multi-part form type. >I got the file content (byte[]) from HttpServletRequest.getAttribute(). I >don't think it's my codes added the extra byte. So I wonder if POI wants to >handle this scenario or I have to change RawDataBlock locally. > >an > > > >-----Original Message----- >From: Andrew C. Oliver [mailto:[EMAIL PROTECTED]] >Sent: Thursday, May 09, 2002 10:27 AM >To: POI Users List >Subject: Re: got IOException from poi.poifs.storage.RawDataBlock.<init>( >R awDat aBlock.java:98) > > >An Feng-I Chen wrote: > > > >>Hi, >> >>I think I know why this problem occurs. >> >>The code RawDataBlock line 93 expects that each inputstream read should >>return 512 bytes, if is not eof. Otherwise exception will be thrown. >>However, my Excel file size is 13825. I tested to read my file, the last >>read returns 2 bytes. (1 + eof, my guess) >> >> >> >> >That extra EOF would be invalid. > > > >>Now my questions are: do you mean Excel always generates file with size X >>times 512 therefore POI expects that? If true, how my file ends up with one >>extra byte? For the same spreadsheet file, if I use FileInputStream, POI >>works fine, why is that? >> >> >> >> >I think you've got some kind of bug in your servlet. You should not >have an extra byte or two at the end. If you look under >jakarta.apache.org/poi/poifs it explains the structure of the OLE2CDF >wrapper. Excel files are written with a minimum of 1 big block (4k) and >the remainder small blocks (512). So if you've got extra stuff at the >end...well thats incorrect so far as we know. I've never seen a file as >you describe. > >Furthermore, we only support >= Biff8 (excel 97+) > >-Andy > > > >>Thanks. >> >>an >> >> >> >>-----Original Message----- >>From: An Feng-I Chen [mailto:[EMAIL PROTECTED]] >>Sent: Wednesday, May 08, 2002 5:43 PM >>To: 'POI Users List' >>Subject: RE: got IOException from poi.poifs.storage.RawDataBlock.<init>( >>R awDat aBlock.java:98) >> >> >>Actually the byte[] I got had content. I verified that by writing that >>byte[] back to an Excel and it looks the same as the file I read from. I >>tried both jakarta-poi-1.5.0-dev-20020427.jar and >>jakarta-poi-1.6.0-dev-20020508.jar. Same result. >> >> >>-----Original Message----- >>From: Andrew C. Oliver [mailto:[EMAIL PROTECTED]] >>Sent: Wednesday, May 08, 2002 5:10 PM >>To: POI Users List >>Subject: Re: got IOException from poi.poifs.storage.RawDataBlock.<init>( >>RawDat aBlock.java:98) >> >> >>So it looks like you've got null bytes right? >> >> >>On Wed, 2002-05-08 at 18:42, An Feng-I Chen wrote: >> >> >> >> >>>Hi, >>> >>>I constructed HSSFWorkwork passing in a ByteArrayInputStream but got this >>> >>> >>> >>> >>IO >> >> >> >> >>>exception. Tried both HSSFWorkbook(InputStream) and >>>HSSFWorkbook(POIFSFileSystem). My codes are below. Do I miss something? >>>Thanks. >>>an >>> >>> ByteArrayInputStream inputStream= null; >>> try { >>> byte[] data = xlsFile.getData(); >>> if (data != null) >>> System.out.println("***** file content size = " + >>>data.length); >>> else >>> System.out.println("***** file has no content!!!"); >>> inputStream = new ByteArrayInputStream(data); >>> //HSSFWorkbook workbook = new HSSFWorkbook(new >>>POIFSFileSystem(inputStream)); >>> HSSFWorkbook workbook = new HSSFWorkbook(inputStream); >>> >>>java.io.IOException: Unable to read entire block; 2 bytes read; expected >>> >>> >>> >>> >>512 >> >> >> >> >>>bytes >>> at >>>org.apache.poi.poifs.storage.RawDataBlock.<init>(RawDataBlock.java:98) >>> at >>> >>> >>> >>> >>> >>org.apache.poi.poifs.storage.RawDataBlockList.<init>(RawDataBlockList.java: >> >> >8 > > >> >> >> >> >>>8) >>> at >>> >>> >>> >>> >>> >>org.apache.poi.poifs.filesystem.POIFSFileSystem.<init>(POIFSFileSystem.java >> >> >: > > >> >> >> >> >>>123) >>> >>>or >>> >>>java.io.IOException: Unable to read entire block; 2 bytes read; expected >>> >>> >>> >>> >>512 >> >> >> >> >>>bytes >>> at >>>org.apache.poi.poifs.storage.RawDataBlock.<init>(RawDataBlock.java:98) >>> at >>> >>> >>> >>> >>> >>org.apache.poi.poifs.storage.RawDataBlockList.<init>(RawDataBlockList.java: >> >> >8 > > >> >> >> >> >>>8) >>> at >>> >>> >>> >>> >>> >>org.apache.poi.poifs.filesystem.POIFSFileSystem.<init>(POIFSFileSystem.java >> >> >: > > >> >> >> >> >>>123) >>> at >>>org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:190) >>> >>> >>> >>>-- >>>To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> >>>For additional commands, e-mail: <mailto:[EMAIL PROTECTED]> >>> >>> >>> >>> >>> > > > > >-- >To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> >For additional commands, e-mail: <mailto:[EMAIL PROTECTED]> > > > >-- >To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> >For additional commands, e-mail: <mailto:[EMAIL PROTECTED]> > > > > -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
