You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@poi.apache.org by mouss4rs <ou...@gmail.com> on 2012/02/21 09:56:22 UTC
java.lang.NoClassDefFoundError: org/apache/xmlbeans/XmlException
Hello,
I would like to read an .xlsx but i have this error:
Exception in thread "main" java.lang.NoClassDefFoundError:
org/apache/xmlbeans/XmlException
at Extraction.main(Extraction.java:135)
Caused by: java.lang.ClassNotFoundException:
org.apache.xmlbeans.XmlException
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
... 1 more
When i do this:
InputStream ist = new FileInputStream("Projection_2012_Eq2.xlsx"); //pour
ouvrir les fichiers xlsx de 2007
*XSSFWorkbook wb2 = new XSSFWorkbook(ist);* // il faut définir la
feuille qui sera alimenté
//si
XSSFSheet sheet2 = wb2.getSheetAt(0);
XSSFRow row2 = null;
XSSFCell cell2 = null;
//int n = 0;
//int i = 0;//compte le nombre d'agent
String prenom_proj;
Collator usCollator;
for (Iterator rowIt = sheet2.rowIterator(); rowIt.hasNext();){//boucle
de parcours du fichier de ligne en ligne
The bold ligne is the 135 ligne's.
Why i had this error ?
How to read a '.xlsx' file ?
Thanks
--
View this message in context: http://apache-poi.1045710.n5.nabble.com/java-lang-NoClassDefFoundError-org-apache-xmlbeans-XmlException-tp5501612p5501612.html
Sent from the POI - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org
Re: java.lang.NoClassDefFoundError:
org/apache/xmlbeans/XmlException
Posted by mouss4rs <ou...@gmail.com>.
So, where i can download ooxml-schemas-1.1.jar ??
The link in the FAQ is dead.
--
View this message in context: http://apache-poi.1045710.n5.nabble.com/java-lang-NoClassDefFoundError-org-apache-xmlbeans-XmlException-tp5501612p5502617.html
Sent from the POI - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org
RE: java.lang.NoClassDefFoundError: org/apache/xmlbeans/XmlException
Posted by "Allison, Timothy B." <ta...@mitre.org>.
http://poi.apache.org/faq.html#faq-N10025
might do the trick.
-----Original Message-----
From: kwokchunwa14@gmail.com [mailto:kwokchunwa14@gmail.com]
Sent: Wednesday, February 05, 2014 2:06 AM
To: user@poi.apache.org
Subject: Re: java.lang.NoClassDefFoundError: org/apache/xmlbeans/XmlException
i also having this error,
can you teach how to add the xmlBeans.jar to classpath?
this classpath should be set on my application project?
--
View this message in context: http://apache-poi.1045710.n5.nabble.com/java-lang-NoClassDefFoundError-org-apache-xmlbeans-XmlException-tp5501612p5714846.html
Sent from the POI - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org
Re: java.lang.NoClassDefFoundError: org/apache/xmlbeans/XmlException
Posted by Dominik Stadler <do...@gmx.at>.
Hi,
It depends on how you specify the jar files (scripts, IDE project
config, ...), but wherever you specify the poi-*.jar, you should also
define the xmlbeans-2.3.0.jar and the dom4j-1.6.1.jar file.
Thanks... Dominik.
On Wed, Feb 5, 2014 at 8:06 AM, kwokchunwa14@gmail.com
<kw...@gmail.com> wrote:
> i also having this error,
> can you teach how to add the xmlBeans.jar to classpath?
> this classpath should be set on my application project?
>
>
>
> --
> View this message in context: http://apache-poi.1045710.n5.nabble.com/java-lang-NoClassDefFoundError-org-apache-xmlbeans-XmlException-tp5501612p5714846.html
> Sent from the POI - User mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
> For additional commands, e-mail: user-help@poi.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org
Re: java.lang.NoClassDefFoundError:
org/apache/xmlbeans/XmlException
Posted by "kwokchunwa14@gmail.com" <kw...@gmail.com>.
i also having this error,
can you teach how to add the xmlBeans.jar to classpath?
this classpath should be set on my application project?
--
View this message in context: http://apache-poi.1045710.n5.nabble.com/java-lang-NoClassDefFoundError-org-apache-xmlbeans-XmlException-tp5501612p5714846.html
Sent from the POI - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org
Re: java.lang.NoClassDefFoundError:
org/apache/xmlbeans/XmlException
Posted by francisrobertm <fr...@gmail.com>.
Yes, i didn't have in my classpath : xmlbeans-2.3.0.jar.
So, it's good.
hi
where should i need to have this xmlbeans-2.3.0.jar.
please help me
--
View this message in context: http://apache-poi.1045710.n5.nabble.com/java-lang-NoClassDefFoundError-org-apache-xmlbeans-XmlException-tp5501612p5712043.html
Sent from the POI - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org
Re: java.lang.NoClassDefFoundError:
org/apache/xmlbeans/XmlException
Posted by mouss4rs <ou...@gmail.com>.
Yes, i didn't have in my classpath : xmlbeans-2.3.0.jar.
So, it's good.
Thank you very much Nick!
The code to read and write a .xlsx file it's:
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
import org.apache.poi.openxml4j.opc.OPCPackage;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.FormulaEvaluator;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.ss.usermodel.WorkbookFactory;
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 LireEcrire {
/**
* @param args
*/
public static void main(String[] args) {
try {
//pour ouvrir un .xlsx
InputStream is = new FileInputStream("workbook.xlsx");
OPCPackage opc=OPCPackage.open(is);
XSSFWorkbook wb= new XSSFWorkbook(opc);
XSSFSheet sheet = (XSSFSheet)wb.getSheetAt(0);//onglet 0
XSSFRow row = sheet.getRow(0);//ligne 0
XSSFCell cell = row.getCell(8);// colonne 8 (D)
//pour ouvrir un .xlsx
FormulaEvaluator evaluator =
wb.getCreationHelper().createFormulaEvaluator();
evaluator.evaluate(cell);
if (cell == null)
cell = row.createCell(8);
cell.setCellType(Cell.CELL_TYPE_STRING);
cell.setCellValue("sisi");
// Write the output to a file
FileOutputStream fileOut = new FileOutputStream("workbook.xlsx");
wb.write(fileOut);
fileOut.close();
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (InvalidFormatException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
--
View this message in context: http://apache-poi.1045710.n5.nabble.com/java-lang-NoClassDefFoundError-org-apache-xmlbeans-XmlException-tp5501612p5508583.html
Sent from the POI - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org
Re: java.lang.NoClassDefFoundError:
org/apache/xmlbeans/XmlException
Posted by Nick Burch <ni...@alfresco.com>.
On Wed, 22 Feb 2012, mouss4rs wrote:
> No, i have ooxml-schemas-1.1.jar and all .jar of poi in my path.
The exception you're getting is that xmlbeans is missing. Make sure that's
present and readable
Nick
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org
Re: java.lang.NoClassDefFoundError:
org/apache/xmlbeans/XmlException
Posted by mouss4rs <ou...@gmail.com>.
I read in the quickguide this:
InputStream inp = new FileInputStream("workbook.xlsx");
Workbook wb = WorkbookFactory.create(inp);
Sheet sheet = wb.getSheetAt(0);
Row row = sheet.getRow(2);
Cell cell = row.getCell(3);
if (cell == null)
cell = row.createCell(3);
cell.setCellType(Cell.CELL_TYPE_STRING);
cell.setCellValue("a test");
So, when i run this simple program:
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.ss.usermodel.WorkbookFactory;
public class LireEcrire {
/**
* @param args
*/
public static void main(String[] args) {
InputStream inp;
try {
inp = new FileInputStream("workbook.xlsx");
Workbook wb;
try {
wb = WorkbookFactory.create(inp);
Sheet sheet = wb.getSheetAt(0);//onglet 0
Row row = sheet.getRow(0);//ligne 0
Cell cell = row.getCell(8);// colonne 8 (D)
if (cell == null)
cell = row.createCell(8);
cell.setCellType(Cell.CELL_TYPE_STRING);
cell.setCellValue("i write in my sheet 'test'");
// Write the output to a file
FileOutputStream fileOut = new FileOutputStream("workbook.xlsx");
wb.write(fileOut);
fileOut.close();
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} catch (InvalidFormatException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
I have this error:
Exception in thread "main" java.lang.NoClassDefFoundError:
org/apache/xmlbeans/XmlOptions
at org.apache.poi.POIXMLDocumentPart.<clinit>(POIXMLDocumentPart.java:44)
at
org.apache.poi.ss.usermodel.WorkbookFactory.create(WorkbookFactory.java:62)
at LireEcrire.main(LireEcrire.java:27)
Caused by: java.lang.ClassNotFoundException: org.apache.xmlbeans.XmlOptions
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
... 3 more
So, it's not normal !!
I have all .jar of 3.7-20101029 poi's version.
--
View this message in context: http://apache-poi.1045710.n5.nabble.com/java-lang-NoClassDefFoundError-org-apache-xmlbeans-XmlException-tp5501612p5505242.html
Sent from the POI - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org
Re: java.lang.NoClassDefFoundError: org/apache/xmlbeans/XmlException
Posted by Lo...@log-net.com.
Take a look here: http://poi.apache.org/spreadsheet/quick-guide.html
mouss4rs <ou...@gmail.com> wrote on 02/22/2012 04:45:41 AM:
> mouss4rs <ou...@gmail.com>
> 02/22/2012 04:46 AM
>
> Please respond to
> "POI Users List" <us...@poi.apache.org>
>
> To
>
> user@poi.apache.org
>
> cc
>
> Subject
>
> Re: java.lang.NoClassDefFoundError: org/apache/xmlbeans/XmlException
>
> No, i have ooxml-schemas-1.1.jar and all .jar of poi in my path.
>
> wait one minute...
>
> Could you give me a code example to read .xlsx file?
>
> I think that i forget some think in my code.
>
> --
> View this message in context: http://apache-poi.
> 1045710.n5.nabble.com/java-lang-NoClassDefFoundError-org-apache-
> xmlbeans-XmlException-tp5501612p5504653.html
> Sent from the POI - User mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
> For additional commands, e-mail: user-help@poi.apache.org
>
Re: java.lang.NoClassDefFoundError:
org/apache/xmlbeans/XmlException
Posted by mouss4rs <ou...@gmail.com>.
No, i have ooxml-schemas-1.1.jar and all .jar of poi in my path.
wait one minute...
Could you give me a code example to read .xlsx file?
I think that i forget some think in my code.
--
View this message in context: http://apache-poi.1045710.n5.nabble.com/java-lang-NoClassDefFoundError-org-apache-xmlbeans-XmlException-tp5501612p5504653.html
Sent from the POI - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org
Re: java.lang.NoClassDefFoundError:
org/apache/xmlbeans/XmlException
Posted by Nick Burch <ni...@alfresco.com>.
On Tue, 21 Feb 2012, mouss4rs wrote:
> But, i have the same error:
> Exception in thread "main" java.lang.NoClassDefFoundError:
> org/apache/xmlbeans/XmlException
> at Extraction.main(Extraction.java:148)
> Caused by: java.lang.ClassNotFoundException:
> org.apache.xmlbeans.XmlException
This means you don't have xmlbeans on your classpath, or maybe one of its
dependencies (depends how useful your class loader is at giving error
messages).
Nick
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org
Re: java.lang.NoClassDefFoundError:
org/apache/xmlbeans/XmlException
Posted by mouss4rs <ou...@gmail.com>.
Ok, i found in this website:
http://mvnrepository.com/artifact/org.apache.poi/ooxml-schemas/1.1
http://mvnrepository.com/artifact/org.apache.poi/ooxml-schemas/1.1
But, i have the same error:
Exception in thread "main" java.lang.NoClassDefFoundError:
org/apache/xmlbeans/XmlException
at Extraction.main(Extraction.java:148)
Caused by: java.lang.ClassNotFoundException:
org.apache.xmlbeans.XmlException
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
... 1 more
caused by this line (in bold):
InputStream ist = new FileInputStream("Projection_2012_Eq2.xlsx"); //pour
ouvrir les fichiers xlsx de 2007
*XSSFWorkbook wb2 = new XSSFWorkbook(ist);* XSSFSheet sheet2 =
wb2.getSheetAt(0);
nbfeuille= wb2.getNumberOfSheets();//retourne le nombre de feuille
renseigné
XSSFRow row2 = null;
XSSFCell cell2 = null;
String prenom_proj;
Collator usCollator;
I don't understand why...
--
View this message in context: http://apache-poi.1045710.n5.nabble.com/java-lang-NoClassDefFoundError-org-apache-xmlbeans-XmlException-tp5501612p5502690.html
Sent from the POI - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org
Re: java.lang.NoClassDefFoundError: org/apache/xmlbeans/XmlException
Posted by Dave Fisher <da...@comcast.net>.
On Feb 21, 2012, at 5:28 AM, mouss4rs wrote:
> I have all .jar of poi in my build path:
>
> poi-3.7-20101029.jar
> poi-examples-3.7-20101029.jar
> poi-ooxml-3.7-20101029.jar
> poi-ooxml-schemas-3.7-20101029.jar
You need the full ooxml-schemas-1.1.jar instead of poi-ooxml-schemas
See http://poi.apache.org/faq.html#faq-N10025
Regards,
Dave
> poi-scratchpad-3.7-20101029.jar
> xmlbeans-2.3.0.jar
> geronimo-stax-api_1.0_spec-1.0.jar
> dom4j-1.6.1.jar
> commons-logging-1.1.jar
> junit-3.8.1.jar
> log4j-1.2.13.jar
>
> So, when i run my program, i have this error message:
> Exception in thread "main" java.lang.NoClassDefFoundError:
> org/apache/xmlbeans/XmlException
> at Extraction.main(Extraction.java:148)
> Caused by: java.lang.ClassNotFoundException:
> org.apache.xmlbeans.XmlException
> at java.net.URLClassLoader$1.run(Unknown Source)
> at java.security.AccessController.doPrivileged(Native Method)
> at java.net.URLClassLoader.findClass(Unknown Source)
> at java.lang.ClassLoader.loadClass(Unknown Source)
> at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
> at java.lang.ClassLoader.loadClass(Unknown Source)
> at java.lang.ClassLoader.loadClassInternal(Unknown Source)
> ... 1 more
>
> The error comes of (in bold):
> InputStream ist = new FileInputStream("Projection_2012_Eq2.xlsx"); //pour
> ouvrir les fichiers xlsx de 2007
> *XSSFWorkbook wb2 = new XSSFWorkbook(ist);* XSSFSheet sheet2 =
> wb2.getSheetAt(0);
> nbfeuille= wb2.getNumberOfSheets();//retourne le nombre de feuille
> renseigné
>
> XSSFRow row2 = null;
> XSSFCell cell2 = null;
>
>
>
>
> --
> View this message in context: http://apache-poi.1045710.n5.nabble.com/java-lang-NoClassDefFoundError-org-apache-xmlbeans-XmlException-tp5501612p5502179.html
> Sent from the POI - User mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
> For additional commands, e-mail: user-help@poi.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org
Re: java.lang.NoClassDefFoundError:
org/apache/xmlbeans/XmlException
Posted by mouss4rs <ou...@gmail.com>.
I have all .jar of poi in my build path:
poi-3.7-20101029.jar
poi-examples-3.7-20101029.jar
poi-ooxml-3.7-20101029.jar
poi-ooxml-schemas-3.7-20101029.jar
poi-scratchpad-3.7-20101029.jar
xmlbeans-2.3.0.jar
geronimo-stax-api_1.0_spec-1.0.jar
dom4j-1.6.1.jar
commons-logging-1.1.jar
junit-3.8.1.jar
log4j-1.2.13.jar
So, when i run my program, i have this error message:
Exception in thread "main" java.lang.NoClassDefFoundError:
org/apache/xmlbeans/XmlException
at Extraction.main(Extraction.java:148)
Caused by: java.lang.ClassNotFoundException:
org.apache.xmlbeans.XmlException
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
... 1 more
The error comes of (in bold):
InputStream ist = new FileInputStream("Projection_2012_Eq2.xlsx"); //pour
ouvrir les fichiers xlsx de 2007
*XSSFWorkbook wb2 = new XSSFWorkbook(ist);* XSSFSheet sheet2 =
wb2.getSheetAt(0);
nbfeuille= wb2.getNumberOfSheets();//retourne le nombre de feuille
renseigné
XSSFRow row2 = null;
XSSFCell cell2 = null;
--
View this message in context: http://apache-poi.1045710.n5.nabble.com/java-lang-NoClassDefFoundError-org-apache-xmlbeans-XmlException-tp5501612p5502179.html
Sent from the POI - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org
Re: java.lang.NoClassDefFoundError: org/apache/xmlbeans/XmlException
Posted by Oleg Rempel <Re...@managetopia.com>.
mouss4rs <oukna.mustapha <at> gmail.com> writes:
>
> Hello,
>
> I would like to read an .xlsx but i have this error:
>
> Exception in thread "main" java.lang.NoClassDefFoundError:
> org/apache/xmlbeans/XmlException
Hallo mouss4rs,
I think you have not all libraries on the build path.
I think you need five libraries (poi-3.7-20101029.jar, poi-ooxml-3.7-
20101029.jar, poi-ooxml-schemas-3.7-20101029.jar, dom4j-1.6.1.jar and xmlbeans-
2.3.0.jar) on the build path.
Oleg
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org
Re: java.lang.NoClassDefFoundError: org/apache/xmlbeans/XmlException
Posted by Sun Kefan <ca...@gmail.com>.
Did you include poi-ooxml jars in your project?
If not, this thread explains a bit about it:
http://stackoverflow.com/questions/5030892/issues-resolving-xssfworkbook-java-poi-jar
On Thu, Apr 10, 2014 at 2:00 AM, tarun <ta...@gmail.com> wrote:
>
> 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: user-unsubscribe@poi.apache.org
> For additional commands, e-mail: user-help@poi.apache.org
>
>
--
孙柯凡
Re: java.lang.NoClassDefFoundError:
org/apache/xmlbeans/XmlException
Posted by tarun <ta...@gmail.com>.
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: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org