I need to create excel file and write some sample data in it. I am using Apache POI for this. I have added following jars in the build path of eclipse:
poi-4.1.0.jar
poi-ooxml-4.1.0.jar
and imported those in my code. But whenever I create object of XSSFWorkbook and try to run the code I get run time error as :
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/xmlbeans/XmlObject
I have written whole program and whenever I run it, it gives me this error. So I just created one object and tried to run it but it is giving me the same error.
Code:
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;
public class CreateExcel {
public static void main(String[] args)
{
//Blank workbook
XSSFWorkbook workbook = new XSSFWorkbook();
}
}