Summary: | inserting data to excel using xssfworkbook,no class def found error | ||
---|---|---|---|
Product: | POI | Reporter: | shafiexp |
Component: | XSSF | Assignee: | POI Developers List <dev> |
Status: | RESOLVED INVALID | ||
Severity: | critical | ||
Priority: | P2 | ||
Version: | 3.7-FINAL | ||
Target Milestone: | --- | ||
Hardware: | PC | ||
OS: | Windows XP | ||
Attachments: | No Cass Defination Found error |
You've neglected to include the xmlbeans jar file. That's why you're getting an exception saying that xmlbeans can't be found. |
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