我正在尝试更改 .xls 文档中单元格的值。
在 .xls 文件中,我只有 1 个单元格 - A1,其中包含 abc
值。
我的代码:
File fo = new File("D:\\TMP\\Zeszyt1.xls");
HSSFWorkbook a = new HSSFWorkbook(new FileInputStream(fo));
HSSFSheet my_sheet = a.getSheetAt(0);
HSSFRow my_row = my_sheet.getRow(0);
HSSFCell myCell;
myCell = my_row.getCell(0);
myCell.setCellValue("NEW VALUE");
如何提交此更改?当我打开 .xls 文件时,A1 中仍然有 abc
值。
最佳答案
你必须write
到文件。
FileOutputStream outputStream = new FileOutputStream(new File("abc.xls"));
workbook.write(outputStream);
outputStream.close();//Close in finally if possible
关于java - 通过 apache-poi 更改 Excel 中单元格的值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24574490/