well i discovered where was the problem, it was in the file... something wrong with the macros..
thanks for all the help.

At 11:00 24/09/2010, you wrote:

I've been using XLSM files for a while now I think, using 3.7b1 now so it was supported at some point or maybe if you don't touch the macro part of it -- it has always worked.

I changed your code to use SS model and it works fine --

public static void main(final String[] args) throws InvalidFormatException, IOException {
        FileInputStream fileIn = null;
        FileOutputStream fileOut = null;
        final Workbook wb;

        try {

            fileIn = new FileInputStream("c:\\foo.xlsm");
            wb = WorkbookFactory.create(fileIn);
            final Sheet sheet = wb.getSheetAt(0);
            Row row = sheet.getRow(2);
            if (row == null)
                row = sheet.createRow(2);
            Cell cell = row.getCell(10);
            if (cell == null)
                cell = row.createCell(10);
            cell.setCellType(Cell.CELL_TYPE_STRING);
            cell.setCellValue("PABLOOOOOOOOOOOO");


            fileOut = new FileOutputStream("workbookout2.xlsm");
            wb.write(fileOut);

        } finally {
            if (fileOut != null)
                fileOut.close();
            if (fileIn != null)
                fileIn.close();
        }


    }

Aram

On 9/24/2010 11:49 AM, David Fisher wrote:
Hi Pablo,

I have not confirmed it, but I think that xlsm support is added with POI 3.7beta3. Apache POI 3.7beta3 is being released right now.

Please give it a try with this situation. If it fails with that then please submit a bugzilla and attach an example.

Regards,
Dave

On Sep 24, 2010, at 8:32 AM, Pablo Johnson wrote:

hi

i have this problem. I want to read a xlsm(2007) file and modify some things. Im using this code

    FileInputStream fileIn = null;
    FileOutputStream fileOut = null;
    XSSFWorkbook wb;

    try {

       fileIn = new FileInputStream("sistema_seguro_propuesto.xlsm");
       wb = new XSSFWorkbook(fileIn); // here is the problem
       Sheet sheet = wb.getSheetAt(0);
       Row row = sheet.getRow(2);
       if (row == null)
          row = sheet.createRow(2);
       Cell cell = row.getCell(10);
       if (cell == null)
          cell = row.createCell(10);
       cell.setCellType(XSSFCell.CELL_TYPE_STRING);
       cell.setCellValue("PABLOOOOOOOOOOOO");


       fileOut = new FileOutputStream("workbookout2.xlsm");
       wb.write(fileOut);

    } finally {
       if (fileOut != null)
          fileOut.close();
       if (fileIn != null)
          fileIn.close();
    }

but it throws me this message

Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
at org.apache.xmlbeans.impl.store.Cur$CurLoadContext.attr(Cur.java:3039) at org.apache.xmlbeans.impl.store.Cur$CurLoadContext.attr(Cur.java:3060) at org.apache.xmlbeans.impl.store.Locale$SaxHandler.startElement(Locale.java:3250) at org.apache.xmlbeans.impl.piccolo.xml.Piccolo.reportStartTag(Piccolo.java:1082) at org.apache.xmlbeans.impl.piccolo.xml.PiccoloLexer.parseAttributesNS(PiccoloLexer.java:1822) at org.apache.xmlbeans.impl.piccolo.xml.PiccoloLexer.parseOpenTagNS(PiccoloLexer.java:1521) at org.apache.xmlbeans.impl.piccolo.xml.PiccoloLexer.parseTagNS(PiccoloLexer.java:1362) at org.apache.xmlbeans.impl.piccolo.xml.PiccoloLexer.yylex(PiccoloLexer.java:4678) at org.apache.xmlbeans.impl.piccolo.xml.Piccolo.yylex(Piccolo.java:1290) at org.apache.xmlbeans.impl.piccolo.xml.Piccolo.yyparse(Piccolo.java:1400) at org.apache.xmlbeans.impl.piccolo.xml.Piccolo.parse(Piccolo.java:714) at org.apache.xmlbeans.impl.store.Locale$SaxLoader.load(Locale.java:3439) at org.apache.xmlbeans.impl.store.Locale.parseToXmlObject(Locale.java:1270) at org.apache.xmlbeans.impl.store.Locale.parseToXmlObject(Locale.java:1257) at org.apache.xmlbeans.impl.schema.SchemaTypeLoaderBase.parse(SchemaTypeLoaderBase.java:345) at org.openxmlformats.schemas.spreadsheetml.x2006.main.WorksheetDocument$Factory.parse(Unknown Source)
     at org.apache.poi.xssf.usermodel.XSSFSheet.read(XSSFSheet.java:170)
at org.apache.poi.xssf.usermodel.XSSFSheet.onDocumentRead(XSSFSheet.java:162) at org.apache.poi.xssf.usermodel.XSSFWorkbook.onDocumentRead(XSSFWorkbook.java:227)
     at org.apache.poi.POIXMLDocument.load(POIXMLDocument.java:190)
at org.apache.poi.xssf.usermodel.XSSFWorkbook.<init>(XSSFWorkbook.java:182)
     at pruebaexcel.xlsx.main(xlsx.java:27)
Java Result: 1

the file's size is about 1.4 kb.. i know it's a dummy code but i want to do more things with it and first i have to read de xlsm file. I have tried this code with a xlsx file ant it works fine but with xlsm don`t.
Maybe poi doesnt support xlsm files.. i dont know..
if there is another library it would be fine.

Thanks

          Pablo Johnson Rojas
Corporación Aceros Arequipa S.A.
    Departamento de Informática
        pjohn...@aasa.com.pe

PAntes de imprimir este mensaje, asegúrese que sea necesario. El medio ambiente está en nuestras manos.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@poi.apache.org
For additional commands, e-mail: user-h...@poi.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@poi.apache.org
For additional commands, e-mail: user-h...@poi.apache.org



__________ Information from ESET Mail Security, version of virus signature database 5476 (20100924) __________

The message was checked by ESET Mail Security.
http://www.eset.com



__________ Información de ESET NOD32 Antivirus, versión de la base de firmas de virus 5476 (20100924) __________

ESET NOD32 Antivirus ha comprobado este mensaje.

http://www.eset.com



          Pablo Johnson Rojas
Corporación Aceros Arequipa S.A.
    Departamento de Informática
        pjohn...@aasa.com.pe

PAntes de imprimir este mensaje, asegúrese que sea necesario. El medio ambiente está en nuestras manos.

Reply via email to