Ms Excel无法打开从Apache POI创建的java文件Excel(文件已损坏)
我不知道为什么我用POI编写的文件不能被Ms Excel打开,但POI仍然可以读取该文件。(单元格值可以更改) 我使用ApachePOI3.10Final和JDK1.5
这是密码
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) 个答案