You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@poi.apache.org by "William Lindner, III" <wl...@gmail.com> on 2010/02/19 16:49:45 UTC

Exception in thread "main" java.io.IOException: Could not find all blocks

I have an excel file that I can open in Excel, but when I attempt to
open as an input stream and read as a new
POIFSFileSystem(inputStream), I get the stack trace:

Exception in thread "main" java.io.IOException: Could not find all blocks
	at org.apache.poi.poifs.storage.BlockAllocationTableReader.<init>(BlockAllocationTableReader.java:139)
	at org.apache.poi.poifs.filesystem.POIFSFileSystem.<init>(POIFSFileSystem.java:164)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
	at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
	at org.codehaus.groovy.reflection.CachedConstructor.invoke(CachedConstructor.java:77)
	at org.codehaus.groovy.runtime.callsite.ConstructorSite$ConstructorSiteNoUnwrapNoCoerce.callConstructor(ConstructorSite.java:107)
	at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallConstructor(CallSiteArray.java:52)
	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:192)
	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:200)
	at com.william.Exporter.POI.<init>(POI.groovy:85)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
	at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
	at org.codehaus.groovy.reflection.CachedConstructor.invoke(CachedConstructor.java:77)
	at org.codehaus.groovy.runtime.callsite.ConstructorSite$ConstructorSiteNoUnwrapNoCoerce.callConstructor(ConstructorSite.java:107)
	at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallConstructor(CallSiteArray.java:52)
	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:192)
	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:200)
	at com.william.Exporter.Exporter$_run_closure4.doCall(Exporter.groovy:259)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:88)
	at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:233)
	at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:272)
	at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:886)
	at groovy.lang.Closure.call(Closure.java:276)
	at groovy.lang.Closure.call(Closure.java:289)
	at org.codehaus.groovy.runtime.DefaultGroovyMethods.each(DefaultGroovyMethods.java:1167)
	at org.codehaus.groovy.runtime.DefaultGroovyMethods.each(DefaultGroovyMethods.java:1143)
	at org.codehaus.groovy.runtime.dgm$108.invoke(Unknown Source)
	at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite$PojoMetaMethodSiteNoUnwrapNoCoerce.invoke(PojoMetaMethodSite.java:270)
	at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite.call(PojoMetaMethodSite.java:52)
	at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:40)
	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:117)
	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125)
	at com.william.Exporter.Exporter.run(Exporter.groovy:251)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:88)
	at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:233)
	at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1058)
	at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:886)
	at org.codehaus.groovy.runtime.InvokerHelper.invokePogoMethod(InvokerHelper.java:743)
	at org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper.java:726)
	at org.codehaus.groovy.runtime.InvokerHelper.runScript(InvokerHelper.java:386)
	at org.codehaus.groovy.runtime.InvokerHelper$runScript.call(Unknown Source)
	at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:40)
	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:117)
	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:129)
	at com.william.Exporter.Exporter.main(Exporter.groovy)

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


Re: Exception in thread "main" java.io.IOException: Could not find all blocks

Posted by Nick Burch <ni...@alfresco.com>.
On Fri, 19 Feb 2010, William Lindner, III wrote:
> The file was not originally written by Microsoft Excel, so I would 
> assume this is the problem.  Unfortunately, I do not have the ability to 
> change how the file is created.

You might be able to put a workaround into poifs. The place it's breaking 
is fairly hairy low-level code, but if you read the microsoft docs (and/or 
fat filesystem docs, as ole2 is similar), you might be able to work up a 
patch that handles this situation

> Is there any automatic/programmatic approach to "fixing" the file by 
> opening it in Excel and saving it?

Asking openoffice to do it for you is the usual way. You can control an 
openoffice instance from java, provided you put the appropriate 
synchronized blocks around it as you're basically just scripting the 
single threaded gui...

Nick

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


Re: Exception in thread "main" java.io.IOException: Could not find all blocks

Posted by "William Lindner, III" <wl...@gmail.com>.
First answer - Yes, I am using 3.6 from 15 December 2009

Second answer - Yes, I can open the file in Excel, then save it as another
file and POI reads it correctly.

The file was not originally written by Microsoft Excel, so I would assume
this is the problem.  Unfortunately, I do not have the ability to change how
the file is created.  Is there any automatic/programmatic approach to
"fixing" the file by opening it in Excel and saving it?

On Fri, Feb 19, 2010 at 11:08 AM, Nick Burch <ni...@alfresco.com>
wrote:
> On Fri, 19 Feb 2010, William Lindner, III wrote:
>>
>> I have an excel file that I can open in Excel, but when I attempt to
>> open as an input stream and read as a new
>> POIFSFileSystem(inputStream), I get the stack trace:
>
> First question - have you tried with the latest poi?
>
> Second question - if you load it in excel, save it as another file, can
poi
> open it?
>
> That exception is normally caused by a corrupt file, or a file written by
> something other than excel where they didn't quite read the spec properly
>
> Nick
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
> For additional commands, e-mail: user-help@poi.apache.org
>
>

Re: Exception in thread "main" java.io.IOException: Could not find all blocks

Posted by Nick Burch <ni...@alfresco.com>.
On Fri, 19 Feb 2010, William Lindner, III wrote:
> I have an excel file that I can open in Excel, but when I attempt to
> open as an input stream and read as a new
> POIFSFileSystem(inputStream), I get the stack trace:

First question - have you tried with the latest poi?

Second question - if you load it in excel, save it as another file, can 
poi open it?

That exception is normally caused by a corrupt file, or a file written by 
something other than excel where they didn't quite read the spec properly

Nick

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