You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@poi.apache.org by bu...@apache.org on 2011/05/29 19:34:13 UTC

DO NOT REPLY [Bug 51289] New: inserting data to excel using xssfworkbook,no class def found error

https://issues.apache.org/bugzilla/show_bug.cgi?id=51289

             Bug #: 51289
           Summary: inserting data to excel using xssfworkbook,no class
                    def found error
           Product: POI
           Version: 3.7
          Platform: PC
        OS/Version: Windows XP
            Status: NEW
          Severity: critical
          Priority: P2
         Component: XSSF
        AssignedTo: dev@poi.apache.org
        ReportedBy: shafiexp@gmail.com
    Classification: Unclassified


Created attachment 27088
  --> https://issues.apache.org/bugzilla/attachment.cgi?id=27088
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

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

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


DO NOT REPLY [Bug 51289] inserting data to excel using xssfworkbook,no class def found error

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=51289

Nick Burch <ni...@alfresco.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |INVALID

--- Comment #1 from Nick Burch <ni...@alfresco.com> 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.

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

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