poi-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Scott Willson <sc...@butlerpress.com>
Subject RE: Unable to read entire block
Date Fri, 31 Oct 2003 00:21:02 GMT
Thought I would mention that I saw a similar 'unable to read entire block'
exception trying to read an Excel template from a jar using
getResourceAsStream(). I worked-around it by wrapping the input stream in a
BufferedInputStream, like so:

InputStream is =
getClass().getResourceAsStream("/reportTemplates/BonusDetailTemplate.xls");
_workbook = new HSSFWorkbook(new BufferedInputStream(is));

Scott


-----Original Message-----

THANKS!!!!
Your suggestions made me look at the ftp code in the servlet.
I was writing extra bytes at the end of the last line which seems to be the
cause of the problem.
I changed that code and the read of the Excel file seems to be working every
time now.
Should have thought of that myself but was convinced the problem was in the
read of the excel file instead of somewhere else...
Again thanks

Julio

-----Original Message-----
From: Avik Sengupta [mailto:[EMAIL PROTECTED]
Sent: Monday, August 11, 2003 10:06 AM
To: POI Users List
Subject: RE: Unable to read entire block


curiouser and curioser.. .to with due apologies to Lewis Caroll :)

Given that many people on this list use poi to read files on solaris and
other versions of unix everyday, you will understand why we cant have an
immediate solution to your problem :)

That being said, here are a  few suggestions to help debugging:

1. Are you  reading in Unix from an NFS mounted drive?
2. Which version of solaris/java?
3. Try it with buffered input stream... your code on that below doesnt
seem correct, in that in the regular case you are reading the file from
the passed in file/path name, while for bufferred input stream you are
reading the file from classpath (using class/getResourceAsStream..)..
why is that.. if the former works, the latter will not work. 
4. Have you tried a roundtrip? ie, ftp from win to unix, then ftp back
to win into a new file (all binary mode).. and then load on win using
poi. It will tell you if the file is being corrupted on transfer, or if
the problem is only in the unix environment. 
4. If all else fails, try attaching the spreadsheet you are trying to
read (if you can) into a bug in bugzilla. 

shout if you find anything else. 

HTH


On Mon, 2003-08-11 at 19:25, [EMAIL PROTECTED] wrote:
> I was doing the FTP in binary but tried ascii only after I received the
> errors.
> We are using Sun Solaris system running SunOS.
> I haven't tried the full memory model load because from looking at the
> example code the 'read' of the file is performed in the same way. My
> understanding is that on the read it is expecting 512 bytes and for some
> reason is finding less which throws the 'unable to read entire block'
> exception and exits. Am I wrong? 
> My confusion is why is this occurring with the same file on UNIX but not
on
> Windows?
> 
> 
> -----Original Message-----
> From: Danny Mui [mailto:[EMAIL PROTECTED]
> Sent: Monday, August 11, 2003 9:40 AM
> To: POI Users List
> Subject: Re: Unable to read entire block
> 
> 
> Have you tried the full memory model load?
> 
> You should probably have the file ftp'd as binary rather than ASCII.
> 
> Just curious, and what UNIX system are you trying here?
> 
> 
> [EMAIL PROTECTED] wrote:
> 
> >FYI
> >I tried using version '2.0 pre3' but same results.
> >I also tried the file FTP from the Windows system to the UNIX system in
> >binary and ascii.
> >The only difference was the number of bytes read on the error
> >"Unable to read entire block; 507 bytes read; expected 512 bytes" instead
> of
> >"Unable to read entire block; 88 bytes read; expected 512 bytes".
> >
> >Has anyone else experienced this problem and found a solution? 
> >I'm at the point of giving up using POI to read the Excel file.
> >Will have to come up with some other method of extracting the data from
the
> >file.
> >
> >Julio
> >
> >-----Original Message-----
> >From: [EMAIL PROTECTED]
> >[mailto:[EMAIL PROTECTED]
> >Sent: Monday, August 11, 2003 8:38 AM
> >To: [EMAIL PROTECTED]
> >Subject: RE: Unable to read entire block
> >
> >
> >Thanks for your reply.
> >I'm using the latest released version 1.5.1 Final.
> >If this was a problem fixed by a 'pre-release' version I am willing to
use
> >that version.
> >I don't think that I am hitting a concurrency bug because only 1 process
is
> >reading the file at a time.
> >My application flow is as follows:
> >1) Users logs onto the web site
> >2) User select some values and select an Excel file to upload
> >3) File is uploaded (using Struts tags) to the UNIX web server
> >4) After file is uploaded successfully another process is informed that
it
> >must process the file
> >5) The other process attempts to read the file using POI and processes
the
> >input.
> >
> >The reading of the file is accomplished using the event driven routine
from
> >my previous email.
> >The 'Unable to read entire block' error occurs on the read.
> >The odd part is that the same Excel file is process without any errors on
a
> >Windows system but not on the UNIX system.
> >Again any help you be appreciated.
> >
> >Julio
> >
> >-----Original Message-----
> >From: Andrew C. Oliver [mailto:[EMAIL PROTECTED]
> >Sent: Friday, August 08, 2003 4:18 PM
> >To: POI Users List
> >Subject: Re: Unable to read entire block
> >
> >
> >What version is this?  I think you're hitting the concurrency bug.  This
is
> >fixed in 2.0pre3.  We would do a 1.52 but we're so close to release time
> >that it seems silly to do so.
> >
> >I've patched this for 2 client thus far by grabbing the 1_5 branch and
> >replacing LittleEndian roughly with the one from the 2_0 branch.
> >
> >Theoretically this could also be a really slow filesystem (NFS)...
> >
> >-andy
> >
> >On 8/8/03 2:44 PM, "[EMAIL PROTECTED]"
> ><[EMAIL PROTECTED]> wrote:
> >
> >  
> >
> >>Hello,
> >>I am trying to use POI to read the an Excel spreadsheet on a UNIX
system.
> >>The following code works fine when run on Windows but when run on UNIX I
> >>receive an error.
> >>As a test I read the same file on both system. To get the file to the
UNIX
> >>system I ftp it in binary format from the Windows system.
> >>The error I receive is :
> >>"Unable to read entire block; 88 bytes read; expected 512 bytes
> >>at
org.apache.poi.poifs.storage.RawDataBlock.<init>(RawDataBlock.java:98)
> >>at
> >>
> >>    
> >>
>
>org.apache.poi.poifs.storage.RawDataBlockList.<ini>(RawDataBlockList.java:8
> 8
> >  
> >
> >>)
> >>at
> >>
> >>    
> >>
>
>org.apache.poi.poifs.filesstem.POIFSFileSystem.<init>(POIFSFileSystem.java:
> 1
> >  
> >
> >>23)
> >>...
> >>
> >>Code follows:
> >>
> >>public Collection readFile(String iFileName) throws IOException
> >>{
> >>  // create a new file input stream with the input file specified by
param
> >>iFileName
> >>  FileInputStream fin = new FileInputStream(iFileName);
> >>
> >>  // create a new org.apache.poi.poifs.filesystem.Filesystem
> >>  POIFSFileSystem poifs = new POIFSFileSystem(fin);
> >>
> >>  // get the Workbook (excel part) stream in a InputStream
> >>  InputStream din = poifs.createDocumentInputStream("Workbook");
> >>
> >>  // construct out HSSFRequest object
> >>  HSSFRequest req = new HSSFRequest();
> >>
> >>  // lazy listen for ALL records with the listener shown above
> >>  req.addListenerForAllRecords(this);
> >>
> >>  // create our event factory
> >>  HSSFEventFactory factory = new HSSFEventFactory();
> >>
> >>  // process events based on the document input stream
> >>  factory.processEvents(req, din);
> >>
> >>  // once all the events are processed close file input stream
> >>  fin.close();
> >>
> >>  // close document input stream
> >>  din.close();
> >>
> >>  return returnCol;
> >>}
> >>
> >>I also tried using the BufferedInputStream as suggested in the mail
> >>    
> >>
> >archives
> >  
> >
> >>but t does not find the file.
> >>  POIFSFileSystem poifs = null;
> >>  InputStream excel = getClass().getResourceAsStream(iFileName);
> >>  if (excel != null) {
> >>    try {
> >>      poifs = new POIFSFileSystem(new BufferedInputStream(excel));
> >>    } catch (IOException e) {
> >>      e.printStackTrace();
> >>      throw e;
> >>    }
> >>  }
> >>  else {
> >>    throw new IOException("Exception: could not read
> >>inputfile:"+iFileName);
> >>  }
> >>
> >>Any help would be MUCH APPRECIATED!!!!!
> >>
> >>Thanks,
> >>Julio
> >>
> >>
> >>---------------------------------------------------------------------
> >>To unsubscribe, e-mail: [EMAIL PROTECTED]
> >>Mailing List:     http://jakarta.apache.org/site/mail2.html#poi
> >>The Apache Jakarta Poi Project:  http://jakarta.apache.org/poi/
> >>
> >>    
> >>
> >
> >  
> >
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> Mailing List:     http://jakarta.apache.org/site/mail2.html#poi
> The Apache Jakarta Poi Project:  http://jakarta.apache.org/poi/
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> Mailing List:     http://jakarta.apache.org/site/mail2.html#poi
> The Apache Jakarta Poi Project:  http://jakarta.apache.org/poi/
> 
-- 
Avik Sengupta <[EMAIL PROTECTED]>

---------------------------------------------------------------------
To unsubscribe, e-mail: poi-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: poi-user-help@jakarta.apache.org


Mime
View raw message