最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

通过apache

SEO心得admin29浏览0评论
本文介绍了通过apache-poi更改Excel中单元格的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在尝试更改 .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
发布评论

评论列表(0)

  1. 暂无评论