Bug 17485

Summary: adding sheets to existing template results in 2 print jobs
Product: POI Reporter: Stephen <stephen>
Component: HSSFAssignee: POI Developers List <dev>
Status: RESOLVED WONTFIX    
Severity: major    
Priority: P3    
Version: 3.0-dev   
Target Milestone: ---   
Hardware: PC   
OS: All   

Description Stephen 2003-02-27 12:25:48 UTC
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();
---------------------
Comment 1 Andy Oliver 2003-07-24 15:52:03 UTC
weird but too minor to hold up 2.0 -- put off till 3.0
Comment 2 Jason Height 2004-10-15 04:45:47 UTC
Any chance of the template being attached to this bug report. You already have
the code there.

Jason
Comment 3 Yegor Kozlov 2008-12-29 09:38:45 UTC
Try the latest POI-3.5-beta4. If the problem persists, re-open this bug and
attach the problem file and sample code to reproduce it.

Yegor
Comment 4 David Fisher 2009-02-18 09:18:20 UTC
This bug was against the ancient 1.5.1.

If there is still trouble with 3.5 the OP or someone else can certainly submit a real example.