You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@poi.apache.org by Dan C <dc...@ipswichengineering.com> on 2010/07/08 20:55:38 UTC

WorkbookFactory.create fails

Hello, I am trying to use the general xls/xlsx reader.
I have too files: one save in xls format, and one saved in xlsx.
They are identical files.

The xls file works just fine.  But the reading the xlsx file cause the program
to exit during the call to WorkbookFactory.create.  It enters the routine and
then the debugger says the "User Program Finished".

Here is my code:

   FileInputStream inp = null;

   inp = new FileInputStream("c:/temp/temp.xlsx");
   Workbook wb1=null;
   wb1 = WorkbookFactory.create(inp);
   Sheet sheet1 = null;
   sheet1 = wb1.getSheet("NB Model");
   Sheet sheet2 = null;
   sheet2 = wb1.getSheet("BB Model");

the same code works with a temp.xls file...

Any suggestions?


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


Re: WorkbookFactory.create fails

Posted by Dan Clapp <ip...@gmail.com>.
I never could catch any exception.  It just enters 
WorkbookFactory.create(filename) and mysteriously exits the program.

I also tried using version 3.5 of the POI library, and tried several 
multi-page exel files with xlsx extensions, all with the same result.

I needed to proceed, so I resorted to the XSSF reader, which seems to 
work just fine...

Thanks for your replies David.

cheers,

Dan

David Fisher wrote:
> On Jul 8, 2010, at 1:58 PM, Dan Clapp wrote:
>
>   
>> I tried adding a catch:
>>
>> try {
>>               wb1 = WorkbookFactory.create(inp);
>>           }
>>           catch(IOException e)
>>     
>
> Catch "Exception"
>
>
>   
>>           {
>>               System.out.println("Unable to Create Workbook" + e.getMessage());
>>           }
>>
>> but still enters WorkbookFactory and kills the program.
>>
>> I have poi-ooxml-3.6-20091214.jar, poi-3.6-20091214.jar as part of the project.
>>
>> I am working out of NetBeans 6.9.
>>
>> Any other suggestions?
>> Thanks!
>>
>> David Fisher wrote:
>>     
>>> You will want to use try / catch and print the exception.
>>>
>>> http://www.exampledepot.com/egs/Java%20Language/TryCatch.html
>>>
>>> I suspect that you are missing the ooxml jar and other dependencies.
>>>
>>> http://poi.apache.org/overview.html#components
>>>
>>> Regards,
>>> Dave
>>>
>>> On Jul 8, 2010, at 11:55 AM, Dan C wrote:
>>>
>>>  
>>>       
>>>> Hello, I am trying to use the general xls/xlsx reader.
>>>> I have too files: one save in xls format, and one saved in xlsx.
>>>> They are identical files.
>>>>
>>>> The xls file works just fine.  But the reading the xlsx file cause the program
>>>> to exit during the call to WorkbookFactory.create.  It enters the routine and
>>>> then the debugger says the "User Program Finished".
>>>>
>>>> Here is my code:
>>>>
>>>>  FileInputStream inp = null;
>>>>
>>>>  inp = new FileInputStream("c:/temp/temp.xlsx");
>>>>  Workbook wb1=null;
>>>>  wb1 = WorkbookFactory.create(inp);
>>>>  Sheet sheet1 = null;
>>>>  sheet1 = wb1.getSheet("NB Model");
>>>>  Sheet sheet2 = null;
>>>>  sheet2 = wb1.getSheet("BB Model");
>>>>
>>>> the same code works with a temp.xls file...
>>>>
>>>> Any suggestions?
>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
>>>> For additional commands, e-mail: user-help@poi.apache.org
>>>>
>>>>    
>>>>         
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
>>> For additional commands, e-mail: user-help@poi.apache.org
>>>
>>>
>>>  
>>>       
>> -- 
>> Ipswich Engineering Group
>> 2 Lakemans Lane
>> Ipswich, MA 01938
>>
>> 508-517-4058
>>
>> IpswichEG@gmail.com 
>>     
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
> For additional commands, e-mail: user-help@poi.apache.org
>
>
>   

-- 
Ipswich Engineering Group
2 Lakemans Lane
Ipswich, MA 01938

508-517-4058

IpswichEG@gmail.com 


Re: WorkbookFactory.create fails

Posted by David Fisher <df...@jmlafferty.com>.
On Jul 8, 2010, at 1:58 PM, Dan Clapp wrote:

> I tried adding a catch:
> 
> try {
>               wb1 = WorkbookFactory.create(inp);
>           }
>           catch(IOException e)

Catch "Exception"


>           {
>               System.out.println("Unable to Create Workbook" + e.getMessage());
>           }
> 
> but still enters WorkbookFactory and kills the program.
> 
> I have poi-ooxml-3.6-20091214.jar, poi-3.6-20091214.jar as part of the project.
> 
> I am working out of NetBeans 6.9.
> 
> Any other suggestions?
> Thanks!
> 
> David Fisher wrote:
>> You will want to use try / catch and print the exception.
>> 
>> http://www.exampledepot.com/egs/Java%20Language/TryCatch.html
>> 
>> I suspect that you are missing the ooxml jar and other dependencies.
>> 
>> http://poi.apache.org/overview.html#components
>> 
>> Regards,
>> Dave
>> 
>> On Jul 8, 2010, at 11:55 AM, Dan C wrote:
>> 
>>  
>>> Hello, I am trying to use the general xls/xlsx reader.
>>> I have too files: one save in xls format, and one saved in xlsx.
>>> They are identical files.
>>> 
>>> The xls file works just fine.  But the reading the xlsx file cause the program
>>> to exit during the call to WorkbookFactory.create.  It enters the routine and
>>> then the debugger says the "User Program Finished".
>>> 
>>> Here is my code:
>>> 
>>>  FileInputStream inp = null;
>>> 
>>>  inp = new FileInputStream("c:/temp/temp.xlsx");
>>>  Workbook wb1=null;
>>>  wb1 = WorkbookFactory.create(inp);
>>>  Sheet sheet1 = null;
>>>  sheet1 = wb1.getSheet("NB Model");
>>>  Sheet sheet2 = null;
>>>  sheet2 = wb1.getSheet("BB Model");
>>> 
>>> the same code works with a temp.xls file...
>>> 
>>> Any suggestions?
>>> 
>>> 
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
>>> For additional commands, e-mail: user-help@poi.apache.org
>>> 
>>>    
>> 
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
>> For additional commands, e-mail: user-help@poi.apache.org
>> 
>> 
>>  
> 
> -- 
> Ipswich Engineering Group
> 2 Lakemans Lane
> Ipswich, MA 01938
> 
> 508-517-4058
> 
> IpswichEG@gmail.com 


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


Re: WorkbookFactory.create fails

Posted by Dan Clapp <ip...@gmail.com>.
I tried adding a catch:

try {
                wb1 = WorkbookFactory.create(inp);
            }
            catch(IOException e)
            {
                System.out.println("Unable to Create Workbook" + 
e.getMessage());
            }

but still enters WorkbookFactory and kills the program.

I have poi-ooxml-3.6-20091214.jar, poi-3.6-20091214.jar as part of the 
project.

I am working out of NetBeans 6.9.

Any other suggestions?
Thanks!

David Fisher wrote:
> You will want to use try / catch and print the exception.
>
> http://www.exampledepot.com/egs/Java%20Language/TryCatch.html
>
> I suspect that you are missing the ooxml jar and other dependencies.
>
> http://poi.apache.org/overview.html#components
>
> Regards,
> Dave
>
> On Jul 8, 2010, at 11:55 AM, Dan C wrote:
>
>   
>> Hello, I am trying to use the general xls/xlsx reader.
>> I have too files: one save in xls format, and one saved in xlsx.
>> They are identical files.
>>
>> The xls file works just fine.  But the reading the xlsx file cause the program
>> to exit during the call to WorkbookFactory.create.  It enters the routine and
>> then the debugger says the "User Program Finished".
>>
>> Here is my code:
>>
>>   FileInputStream inp = null;
>>
>>   inp = new FileInputStream("c:/temp/temp.xlsx");
>>   Workbook wb1=null;
>>   wb1 = WorkbookFactory.create(inp);
>>   Sheet sheet1 = null;
>>   sheet1 = wb1.getSheet("NB Model");
>>   Sheet sheet2 = null;
>>   sheet2 = wb1.getSheet("BB Model");
>>
>> the same code works with a temp.xls file...
>>
>> Any suggestions?
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
>> For additional commands, e-mail: user-help@poi.apache.org
>>
>>     
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
> For additional commands, e-mail: user-help@poi.apache.org
>
>
>   

-- 
Ipswich Engineering Group
2 Lakemans Lane
Ipswich, MA 01938

508-517-4058

IpswichEG@gmail.com 


Re: WorkbookFactory.create fails

Posted by David Fisher <df...@jmlafferty.com>.
You will want to use try / catch and print the exception.

http://www.exampledepot.com/egs/Java%20Language/TryCatch.html

I suspect that you are missing the ooxml jar and other dependencies.

http://poi.apache.org/overview.html#components

Regards,
Dave

On Jul 8, 2010, at 11:55 AM, Dan C wrote:

> Hello, I am trying to use the general xls/xlsx reader.
> I have too files: one save in xls format, and one saved in xlsx.
> They are identical files.
> 
> The xls file works just fine.  But the reading the xlsx file cause the program
> to exit during the call to WorkbookFactory.create.  It enters the routine and
> then the debugger says the "User Program Finished".
> 
> Here is my code:
> 
>   FileInputStream inp = null;
> 
>   inp = new FileInputStream("c:/temp/temp.xlsx");
>   Workbook wb1=null;
>   wb1 = WorkbookFactory.create(inp);
>   Sheet sheet1 = null;
>   sheet1 = wb1.getSheet("NB Model");
>   Sheet sheet2 = null;
>   sheet2 = wb1.getSheet("BB Model");
> 
> the same code works with a temp.xls file...
> 
> Any suggestions?
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
> For additional commands, e-mail: user-help@poi.apache.org
> 


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