You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@poi.apache.org by Raymond Cheng <ra...@hk-dttn.com> on 2007/09/25 08:11:15 UTC

Problem when I read a excel file "Unable to read entire block"

I find a problem about reading excel file content.

I have a excel file and I want to get its content by using POI.
>From the following error description, I find that the excel content may 
have some problem.

Is any method for me to get more detail about this problem?
As a user point of view, I cannot know where is the block of data that 
cannot be read.
It is more meaningful if the error can be described in terms of worksheet 
or cell location.


fis = new FileInputStream(input);
fs = new POIFSFileSystem(fis); <-- error is found here
wb = new HSSFWorkbook(fs);



java.io.IOException: Unable to read entire block; 72 bytes read; expected 
512 bytes
        at org.apache.poi.poifs.storage.RawDataBlock.<init>(
RawDataBlock.java:62)
        at org.apache.poi.poifs.storage.RawDataBlockList.<init>(
RawDataBlockList.java:51)
        at org.apache.poi.poifs.filesystem.POIFSFileSystem.<init>(
POIFSFileSystem.java:86)

Re: Problem when I read a excel file "Unable to read entire block"

Posted by Nick Burch <ni...@torchbox.com>.
On Tue, 25 Sep 2007, Raymond Cheng wrote:
> java.io.IOException: Unable to read entire block; 72 bytes read; expected
> 512 bytes
>        at org.apache.poi.poifs.storage.RawDataBlock.<init>(
> RawDataBlock.java:62)

This normally means that your file has been truncated, and the end of it 
is missing. Alternately, you might be using an unusual input stream (there 
has been some talk about poi making some incorrect assumptions on input 
streams, which only affects unusual ones)

I'd try checking that you have all the file, then try reading it into 
memory and passing a ByteArrayInputStream to POI, to see if that helps

Nick

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


Re: Problem when I read a excel file "Unable to read entire block"

Posted by Alan Oshry <al...@gmail.com>.
I have had success using a ByteArrayInputStream and adding null bytes
to the array to make the total bytes divisible by 512 for
POIFSFileSystem to work correctly...

On 9/25/07, Raymond Cheng <ra...@hk-dttn.com> wrote:
> I find a problem about reading excel file content.
>
> I have a excel file and I want to get its content by using POI.
> From the following error description, I find that the excel content may
> have some problem.
>
> Is any method for me to get more detail about this problem?
> As a user point of view, I cannot know where is the block of data that
> cannot be read.
> It is more meaningful if the error can be described in terms of worksheet
> or cell location.
>
>
> fis = new FileInputStream(input);
> fs = new POIFSFileSystem(fis); <-- error is found here
> wb = new HSSFWorkbook(fs);
>
>
>
> java.io.IOException: Unable to read entire block; 72 bytes read; expected
> 512 bytes
>         at org.apache.poi.poifs.storage.RawDataBlock.<init>(
> RawDataBlock.java:62)
>         at org.apache.poi.poifs.storage.RawDataBlockList.<init>(
> RawDataBlockList.java:51)
>         at org.apache.poi.poifs.filesystem.POIFSFileSystem.<init>(
> POIFSFileSystem.java:86)

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