java - 在Apache POI JAVA中将单元格添加到Excel工作表的下一个空行
问题描述
我正在开发一个从 excel 文件导入信息然后将其保存在第二个文件中的项目。我得到以下变量,我需要将它们作为单独的单元格存储在新行中
userID = "" + importUsers.getSheetAt(0).getRow(counter).getCell(5);
computername = "" + importUsers.getSheetAt(0).getRow(counter).getCell(21);
location = "" + importUsers.getSheetAt(0).getRow(counter).getCell(14);
migID = "" + importUsers.getSheetAt(0).getRow(counter).getCell(0);
然后我创建一个 enterInfo.java 的实例
new enterInfo(userID, computername, location,migID,row);
这导致了这个类
public class enterInfo extends JFrame{
public enterInfo(String userID, String computername, String location, String migID, int row) throws InvalidFormatException, IOException {
System.out.println("adding...");
File workbookFile = new File("C:\\Users\\strinca1\\Decomp\\activeUsers.xlsx.xlsx");
FileInputStream file = new FileInputStream(workbookFile);
Workbook activeUsers = WorkbookFactory.create(file);
Row reihe = activeUsers.getSheetAt(0).createRow((short)row);
// Create a cell and put a value in it.
Cell cell = reihe.createCell(0);
cell.setCellValue(1);
}
}
然而,它并没有添加任何东西activeUsers.xlsx.xlsx
我找不到哪里出错了
感谢您提前提供任何帮助
解决方案
推荐阅读
- pine-script - 如何在收盘或 X 利润高于前高时平仓?
- ruby - 如何安装 ruby-augeas gem?(macOS 莫哈韦)
- c# - DbContext 正在跟踪对其他线程上正在处理的实体的更改
- python - 使用 VSCode、python 和绝对导入时未发现任何测试
- django - 登录django后重定向用户
- python-3.x - 如何使用 BeautifulSoup 解析嵌套的标签
- html - 带有 HTML 的 CSS 滑块不起作用 - 怎么办?
- javascript - 在更新状态之前需要调用两次 Redux 操作?
- php - 进入网站时看不到会话
- javascript - 将 JSON 对象从 python 发送到 javascript 以填充下拉列表