package com.test.java;

import java.io.FileInputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import org.apache.poi.xssf.usermodel.XSSFCell;
import org.apache.poi.xssf.usermodel.XSSFRow;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;

public class Main {

        /**
         * @param <E>
         * @param args
         * @throws IOException 
         */
        public static <E> void main(String[] args) throws IOException
        {
                //
                // An excel file name. You can create a file name with a full
                // path information.
                //
                        String fileName = "C:\\SampleData.xlsx";


                // Create an ArrayList to store the data read from excel sheet.
                //
                        List sheetData = new ArrayList();

                        FileInputStream fis = null;
                        try {
                //
                // Create a FileInputStream that will be use to read the
                // excel file.
                //
                            fis = new FileInputStream(fileName);

                //
                // Create an excel workbook from the file system.
                //
                            XSSFWorkbook workbook = new XSSFWorkbook(fis);
                //
                // Get the first sheet on the workbook.
                //
                            XSSFSheet sheet = workbook.getSheetAt(0);

                //
                // When we have a sheet object in hand we can iterator on
                // each sheet's rows and on each row's cells. We store the
                // data read on an ArrayList so that we can printed the
                // content of the excel to the console.
                //
                            Iterator<E> rows=(Iterator<E>) sheet.rowIterator();
                           // Iterator rows = sheet.rowIterator();
                            while (rows.hasNext()) {
                                XSSFRow row = (XSSFRow) rows.next();
                                Iterator cells = row.cellIterator();

                                List data = new ArrayList();
                                while (cells.hasNext()) {
                                    XSSFCell cell = (XSSFCell) cells.next();
                                    data.add(cell);
                                }

                                sheetData.add(data);
                            }
                        } catch (IOException e) {
                            e.printStackTrace();
                        } finally {
                            if (fis != null) {
                                fis.close();
                            }
                        }

                        showExelData(sheetData);
                    }

                    private static void showExelData(List sheetData) {
                //
                // Iterates the data and print it out to the console.
                //
                        for (int i = 0; i < sheetData.size(); i++) {
                            List list = (List) sheetData.get(i);
                            for (int j = 0; j < list.size(); j++) {
                                XSSFCell employeeid = (XSSFCell) list.get(j);
                               
System.out.print(employeeid.getRichStringCellValue().getString());
                                if (j < list.size() - 1) {
                                    System.out.print(", ");
                                }
                            }
                            System.out.println("");
                        }
                        }
                    }
                
This is my code.And the jar file which i have used in this code is  
1...dom4j-1.6.1.jar
2...ooxml-schemas-1.1.jar
3...poi-3.6-sources.jar
4...poi-3.6.jar
5...poi-ooxml-3.5-FINAL.jar
6...xmlbeans-2.3.0.jar.Zip

But I am geeting the  following error

Exception in thread "main" java.lang.NoClassDefFoundError:
org/apache/xmlbeans/XmlException
        at com.test.java.Main.main(Main.java:45)
Caused by: java.lang.ClassNotFoundException:
org.apache.xmlbeans.XmlException
        at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
        at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
        ... 1 more


How i can resolve my problem






--
View this message in context: 
http://apache-poi.1045710.n5.nabble.com/java-lang-NoClassDefFoundError-org-apache-xmlbeans-XmlException-tp5501612p5715421.html
Sent from the POI - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to