I'm using 1.5.1
I think there is a problem/bug in starting with a template and adding sheets to it.
Symptoms: When printing the resulting file, two separate print jobs are created.
THE PROBLEM IS: When I open the file in Excel and print it, two separate
jobs are output to the printer. The first job contains sheet 0, and the second
job contains all the other sheets. When I do Print in Excel and look at
the Print Preview, it looks correct. And, when I do Print in Excel the
popup page count window shows that I'm printing 3 pages. Evidently, there
is some character in the stream that my print company's print job control
system is interpreting as a "job separator".
A guess that a workaround would be to create a template with the extra
blank sheets that I may need, and delete the ones that I don't use.
Note: My template file does not contain graphics.
--Steve
------------------------------------------
In Excel, I create an excel .xls file with one worksheet and save it, to be used as a
template.
In POI API, I do:
POIFSFileSystem fs = new POIFSFileSystem(new FileInputStream("C:\\My
Documents\\Excel\\Template.xls"));
HSSFWorkbook wb = new HSSFWorkbook(fs);
I "get" the first sheet
HSSFSheet coverSheet = wb.getSheetAt(0);
and then I modify it by adding stuff to it.
Then, I add more sheets to the HSSFWorkbook wb, like this:
HSSFSheet summarySheet = wb.createSheet();
wb.setSheetName(1, "Summary");
addSheetTitle(summarySheet, "Summary");
I then write it out:
FileOutputStream fileOut = new FileOutputStream("PlanningReport.xls");
wb.write(fileOut);
fileOut.close();
---------------------