使用 Apache POI for Java 在现有 Excel 工作簿中创建新工作表 [英] Creating New Sheet In Existing Excel Workbook Using Apache POI for Java

查看:63
本文介绍了使用 Apache POI for Java 在现有 Excel 工作簿中创建新工作表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 apache POI for java 在现有的 excel 工作簿中创建一个新工作表,但到目前为止没有成功.谁能告诉我它是怎么做的?

I'm trying to create a new sheet in an existing excel workbook using apache POI for java but have been unsuccessful so far. Can anyone please tell me how it is done?

推荐答案

这很容易.这就像向新工作簿添加新工作表一样,只是从现有工作簿而不是新工作簿开始

It's very easy. It's just like adding a new sheet to a new workbook, only you start with the existing workbook rather than a new one

 Workbook wb = WorkbookFactory.create(new File("/path/to/existing"));
 Sheet s = wb.createSheet();

 // Do something with the new sheet

 FileOutputStream out = new FileOutputStream("/path/to/new/version");
 wb.write(out);
 out.close();

这篇关于使用 Apache POI for Java 在现有 Excel 工作簿中创建新工作表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆