我正在尝试更改 .xls 文档中单元格的值.
I'm trying to change value of cell in .xls document.
在 .xls 文件中,我只有 1 个单元格 - A1 里面有 abc 值.
In .xls file i have got only 1 cell - A1 with abc value inside.
我的代码:
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 值.
How to commit this changes? When i open .xls file i still have got abc value inside A1.
推荐答案你必须write 到文件中.
You have to write to the file.
FileOutputStream outputStream = new FileOutputStream(new File("abc.xls")); workbook.write(outputStream); outputStream.close();//Close in finally if possible