使用Apache POI for Java在现有Excel工作簿中创建新工作表

use*_*176 5 java apache-poi

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

Gag*_*arr 7

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

 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();
Run Code Online (Sandbox Code Playgroud)