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(); ---------------------
weird but too minor to hold up 2.0 -- put off till 3.0
Any chance of the template being attached to this bug report. You already have the code there. Jason
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
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.