Bug 51289 - inserting data to excel using xssfworkbook,no class def found error
Summary: inserting data to excel using xssfworkbook,no class def found error
Status: RESOLVED INVALID
Alias: None
Product: POI
Classification: Unclassified
Component: XSSF (show other bugs)
Version: 3.7-FINAL
Hardware: PC Windows XP
: P2 critical (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-05-29 17:34 UTC by shafiexp
Modified: 2011-05-29 17:36 UTC (History)
0 users



Attachments
No Cass Defination Found error (605 bytes, text/plain)
2011-05-29 17:34 UTC, shafiexp
Details

Note You need to log in before you can comment on or make changes to this bug.
Description shafiexp 2011-05-29 17:34:13 UTC
Created attachment 27088 [details]
No Cass Defination Found error

Hi,

I have written the below sample code using XSSFWorkbok,which insert the data into excel file.

But while running the program in Eclipse I'm getting the error which I'm attaching Here.

I have added all the Jars to the eclipse,even I'm getting the following error,
but in case of HSSFWorkbook there is no error.

Please Give me the Solution


package test.excel;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Date;

import org.apache.poi.hssf.util.HSSFColor;
import org.apache.poi.xssf.usermodel.XSSFCell;
import org.apache.poi.xssf.usermodel.XSSFCellStyle;
import org.apache.poi.xssf.usermodel.XSSFRow;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;

public class CreateXssf {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub

		System.out.println("Writing Data to Excel 2007");
		System.out.println(XSSFWorkbook.class.getClassLoader().getResource("org/apache/poi/xssf/usermodel/XSSFWorkbook.class"));
		try {
			FileOutputStream fileout=new FileOutputStream("XSSFtest.xlsx");
			XSSFWorkbook workbook=new XSSFWorkbook();
			XSSFSheet worksheet=workbook.createSheet("POI WorkSheet");
			XSSFRow row1=worksheet.createRow(0);
			
			XSSFCell cellA1=row1.createCell(0);
			cellA1.setCellValue("Hello");
			XSSFCellStyle cellstyle=workbook.createCellStyle();
			cellstyle.setFillForegroundColor(HSSFColor.GOLD.index);
			cellstyle.setFillPattern(XSSFCellStyle.SOLID_FOREGROUND);
			cellA1.setCellStyle(cellstyle);
			
			XSSFCell cellB1=row1.createCell(1);
			cellB1.setCellValue("Good Bye");
			cellstyle=workbook.createCellStyle();
			cellstyle.setFillForegroundColor(HSSFColor.LIGHT_CORNFLOWER_BLUE.index);
			cellstyle.setFillPattern(XSSFCellStyle.SOLID_FOREGROUND);
			cellB1.setCellStyle(cellstyle);
			
			XSSFCell cellC1=row1.createCell(2);
			cellC1.setCellValue(true);
			
			XSSFCell cellD1=row1.createCell(3);
			cellD1.setCellValue(new Date());
			cellstyle=workbook.createCellStyle();
			//cellstyle.setDataFormat(HSSFDataFormat.getBuiltinFormat("dd/m/yy h:mm"));
			cellD1.setCellStyle(cellstyle);
			
			workbook.write(fileout);
			fileout.flush();
			fileout.close();
			System.out.println("Data inserted Succesfully");
			
					
		} catch (FileNotFoundException fe) {
			// TODO: handle exception
			fe.printStackTrace();
		}
		 catch (IOException ie) {
			// TODO: handle exception
			ie.printStackTrace();
			
		}
		
	}
	}



Thanks,
Shafiulla
Comment 1 Nick Burch 2011-05-29 17:36:48 UTC
You've neglected to include the xmlbeans jar file. That's why you're getting an exception saying that xmlbeans can't be found.