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?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
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();
回答2:
HSSFSheet sheet1= workBook.createSheet("sheet1");
HSSFSheet sheet2= workBook.createSheet("sheet2");
HSSFSheet sheet3= workBook.createSheet("sheet3");
回答3:
//we can create any number of sheets for single workbook
HSSFSheet sheet1= workBook.createSheet("sheet1");
HSSFSheet sheet2= workBook.createSheet("sheet2");
HSSFSheet sheet3= workBook.createSheet("sheet3");
回答4:
Check out this link it worked for me Add a sheet into existing excel file