有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

Ms Excel无法打开从Apache POI创建的java文件Excel(文件已损坏)

我不知道为什么我用POI编写的文件不能被Ms Excel打开,但POI仍然可以读取该文件。(单元格值可以更改) 我使用ApachePOI3.10Final和JDK1.5

链接文件:http://www.corteconti.it/export/sites/portalecdc/_documenti/controllo/sez_autonomie/2016/schemi_di_bilancio_armonizzato_2015_ens_art_1_delibera_12_2016_sezaut_inpr.xls

这是密码

    String nomeFileArt1 = "schemi_di_bilancio_armonizzato_2015_ens_art_1_delibera_12_2016_sezaut_inpr.xls";
        NPOIFSFileSystem fs = new NPOIFSFileSystem(new File(System.getProperty("java.io.tmpdir") + nomeFileArt1));
        HSSFWorkbook wb = new HSSFWorkbook(fs.getRoot(), true);

        FileOutputStream stream = new FileOutputStream(System.getProperty("java.io.tmpdir") + "schemi_di_bilancio_armonizzato.xls");
        HSSFSheet sheet = wb.getSheet("Dati_Anagrafici");
        HSSFRow sheetrow = sheet.getRow(10);
        if (sheetrow == null) {
            sheetrow = sheet.createRow(10);
        }
        HSSFCell cell = sheetrow.getCell(0);
        if (cell == null) {
            cell = sheetrow.createCell(0);
            cell.setCellType(HSSFCell.CELL_TYPE_STRING);
        }
        cell.setCellValue("test");
        wb.write(stream);
        stream.close();

共 (0) 个答案