通过apache-poi更改Excel中单元格的值 [英] Changing value of cell in Excel via apache-poi
问题描述
在.xls文件中,我只有一个单元格 - A1与 abc
的值。
我的代码:
File fo = new File(D:\\TMP\\Zeszyt1.xls);
HSSFWorkbook a =新的HSSFWorkbook(新的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
值。
您必须 I'm trying to change value of cell in .xls document. In .xls file i have got only 1 cell - A1 with My code: How to commit this changes? When i open .xls file i still have got You have to
这篇关于通过apache-poi更改Excel中单元格的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
FileOutputStream outputStream = new FileOutputStream(new File(abc.xls));
workbook.write(outputStream);
outputStream.close(); //如果可能,最终关闭
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");
abc
value inside A1.write
to the file.FileOutputStream outputStream = new FileOutputStream(new File("abc.xls"));
workbook.write(outputStream);
outputStream.close();//Close in finally if possible