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: [email protected]
For additional commands, e-mail: [email protected]