poi-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "MaYong" <mayong801...@hotmail.com>
Subject org.apache.poi.openxml4j.exceptions.InvalidOperationException
Date Wed, 28 Oct 2009 09:56:23 GMT
Dear All:

when I used XSSF read Excel 2003 file, had a Exception.read Excel 2007,ok.
source:
       String excelFile = "newwork_workbook.xls";

        // XSSFWorkbook wb=new XSSFWorkbook();  
        XSSFWorkbook wb = wb = new XSSFWorkbook(excelFile);
 
        XSSFSheet sheet = wb.getSheetAt(0);
        XSSFRow row = sheet.getRow(2);
        XSSFCell cell = row.getCell(3);
        if (cell == null)
            cell = row.createCell(3);
        cell.setCellType(HSSFCell.CELL_TYPE_STRING);
        cell.setCellValue(new XSSFRichTextString("a test"));

        // Write the output to a file
        FileOutputStream fileOut = new FileOutputStream("2007excel.xls");
        wb.write(fileOut);
        fileOut.close();
Exction:
Exception in thread "main" org.apache.poi.openxml4j.exceptions.InvalidOperationException:
Can't open the specified file: 'newwork_workbook.xls'
 at org.apache.poi.openxml4j.opc.ZipPackage.<init>(ZipPackage.java:102)
 at org.apache.poi.openxml4j.opc.OPCPackage.open(OPCPackage.java:199)
 at org.apache.poi.openxml4j.opc.OPCPackage.open(OPCPackage.java:178)
 at org.apache.poi.POIXMLDocument.openPackage(POIXMLDocument.java:62)
 at org.apache.poi.xssf.usermodel.XSSFWorkbook.<init>(XSSFWorkbook.java:167)
 at PoiTest.readingAndRewritingWorkbooks(PoiTest.java:179)
 at PoiTest.main(PoiTest.java:57)

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message