You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@poi.apache.org by Barry Kern <bs...@gmail.com> on 2010/01/27 17:44:46 UTC

help with an example?

Hi,

I am trying to start working with poi and began by copy some code from (
http://svn.apache.org/repos/asf/poi/trunk/src/examples/src/org/apache/poi/hssf/usermodel/examples/HSSFReadWrite.java
)

In my build I have tried this code with POI version 3.6 and 3.5-FINAL.


I wrote a very small java class with a main method that takes an argument of
the workbook to work with. Then I try to run this code:

HSSFWorkbook wb = new HSSFWorkbook(new FileInputStream(fileName));

System.out.println("Data dump:\n");
 System.out.println("number of worksheets: " + wb.getNumberOfSheets());
HSSFSheet sheet = wb.getSheetAt(0);
 int rows = sheet.getPhysicalNumberOfRows();
System.out.println("number of rows: " + rows);

Exception in thread "main" java.lang.NoClassDefFoundError:
org/apache/poi/hssf/usermodel/HSSFWorkbook
Caused by: java.lang.ClassNotFoundException:
org.apache.poi.hssf.usermodel.HSSFWorkbook


Is this a bad example to follow? Any recommendations for pages to look at? I
want to read certain data from a workbook and then write out to a new csv
file.

Thanks,
Barry

Re: help with an example?

Posted by David Fisher <df...@jmlafferty.com>.
Hi -

NoClassDefFoundError:

This is almost always caused by a bad java classpath - missing the POI  
jar files. You should check your environment.

Regards,
Dave

On Jan 27, 2010, at 8:44 AM, Barry Kern wrote:

> Hi,
>
> I am trying to start working with poi and began by copy some code  
> from (
> http://svn.apache.org/repos/asf/poi/trunk/src/examples/src/org/apache/poi/hssf/usermodel/examples/HSSFReadWrite.java
> )
>
> In my build I have tried this code with POI version 3.6 and 3.5-FINAL.
>
>
> I wrote a very small java class with a main method that takes an  
> argument of
> the workbook to work with. Then I try to run this code:
>
> HSSFWorkbook wb = new HSSFWorkbook(new FileInputStream(fileName));
>
> System.out.println("Data dump:\n");
> System.out.println("number of worksheets: " + wb.getNumberOfSheets());
> HSSFSheet sheet = wb.getSheetAt(0);
> int rows = sheet.getPhysicalNumberOfRows();
> System.out.println("number of rows: " + rows);
>
> Exception in thread "main" java.lang.NoClassDefFoundError:
> org/apache/poi/hssf/usermodel/HSSFWorkbook
> Caused by: java.lang.ClassNotFoundException:
> org.apache.poi.hssf.usermodel.HSSFWorkbook
>
>
> Is this a bad example to follow? Any recommendations for pages to  
> look at? I
> want to read certain data from a workbook and then write out to a  
> new csv
> file.
>
> Thanks,
> Barry


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