Hi Ramon,

For OOXML you will need more jar files. See the maven artifacts listed towards 
the bottom of http://poi.apache.org/overview.html

Regards,
Dave

On Apr 21, 2010, at 4:40 PM, Ramon F Herrera wrote:

> 
> This is the error message:
> 
> ----------------------------------------------------------
> 
> Exception in thread "main" java.lang.NoClassDefFoundError: 
> org/openxmlformats/schemas/spreadsheetml/x2006/main/CTDxfs$1
>        at 
> org.openxmlformats.schemas.spreadsheetml.x2006.main.CTDxfs.<clinit>(Unknown 
> Source)
>        at 
> org.openxmlformats.schemas.spreadsheetml.x2006.main.CTDxfs$Factory.newInstance(Unknown
>  Source)
>        at org.apache.poi.xssf.model.StylesTable.writeTo(StylesTable.java:362)
>        at org.apache.poi.xssf.model.StylesTable.commit(StylesTable.java:377)
>        at 
> org.apache.poi.POIXMLDocumentPart.onSave(POIXMLDocumentPart.java:177)
>        at 
> org.apache.poi.POIXMLDocumentPart.onSave(POIXMLDocumentPart.java:181)
>        at org.apache.poi.POIXMLDocument.write(POIXMLDocument.java:214)
>        at 
> org.apache.poi.hssf.usermodel.examples.ReadWriteWorkbook.main(ReadWriteWorkbook.java:41)
> Caused by: java.lang.ClassNotFoundException: 
> org.openxmlformats.schemas.spreadsheetml.x2006.main.CTDxfs$1
>        at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
>        at java.security.AccessController.doPrivileged(Native Method)
>        at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
>        at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
>        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
>        at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
>        ... 8 more
> Java Result: 1
> BUILD SUCCESSFUL (total time: 1 second)
> ----------------------------------------------------------
> 
> TIA,
> 
> -Ramon
> 
> 
> 
> 
>> 
>> This is the modified version:
>> 
>> ------------------------------------
>> 
>> package org.apache.poi.hssf.usermodel.examples;
>> 
>> import org.apache.poi.xssf.usermodel.*;
>> import org.apache.poi.ss.usermodel.*;
>> 
>> import java.io.FileInputStream;
>> import java.io.FileOutputStream;
>> import java.io.IOException;
>> 
>> /**
>> * This example demonstrates opening a workbook, modifying
>> * it and writing the results back out.
>> * @author Glen Stampoultzis (glens at apache.org)
>> */
>> 
>> public class ReadWriteWorkbook {
>> 
>> public static void main(String[] args) throws IOException {
>> 
>> FileInputStream fileIn = null;
>> FileOutputStream fileOut = null;
>> XSSFWorkbook wb;
>> 
>> try {
>> 
>> fileIn = new FileInputStream("1-Tab.xlsx");
>> wb = new XSSFWorkbook(fileIn);
>> Sheet sheet = wb.getSheetAt(0);
>> Row row = sheet.getRow(2);
>> if (row == null)
>> row = sheet.createRow(2);
>> Cell cell = row.getCell(3);
>> if (cell == null)
>> cell = row.createCell(3);
>> cell.setCellType(XSSFCell.CELL_TYPE_STRING);
>> cell.setCellValue("a test");
>> 
>> // Write the output to a file
>> fileOut = new FileOutputStream("workbookout.xlsx");
>> wb.write(fileOut); // Crashes here, creating an empty file
>> 
>> } finally {
>> if (fileOut != null)
>> fileOut.close();
>> if (fileIn != null)
>> fileIn.close();
>> }
>> }
>> }
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
> 


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

Reply via email to