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
[email protected]
PAntes de imprimir este mensaje, asegúrese que
sea necesario. El medio ambiente está en nuestras manos.