Nick,
Thanks for your reply.
As my sample code shows, I am not selecting the sheets anymore. Simply
creating three sheets with some data and selecting A4 paper size. 
    public static void main(String args[]) {
        HSSFWorkbook wb = new HSSFWorkbook();
        //Create 3 sheets with some numeric data and set paper size to A4
        for (int i = 0; i < 3; i++) {
            HSSFSheet sheet = wb.createSheet();
            fill(sheet);
            sheet.getPrintSetup().setPaperSize((short) 9); //A4
        }
        //Write to file
        try {
            FileOutputStream fileOut = new
FileOutputStream("threesheets-a4.xls");
            wb.write(fileOut);
            fileOut.close();
        } catch (Exception e) {
            System.out.println(e);
        }

    }

    private static void fill(HSSFSheet sheet) {
        for (int i = 0; i < 10; i++) {
            HSSFRow row = sheet.createRow(i);
            for (int c = 0; c < 5; c++) {
                HSSFCell cell = row.createCell((short) c);
                cell.setCellValue(c);
            }
        }
    }


I have also tried another variation. I didn't set the paper size from poi
then opened the file in excel, tried the print entire workbook and it
worked. Then I changed the paper size from excel and the bug was reproduced.


Regards
Tahir

> -----Original Message-----
> From: Nick Burch [mailto:[EMAIL PROTECTED]
> Sent: Thursday, June 14, 2007 3:45 PM
> To: POI Users List
> Subject: RE: Can't print entire workbook
> 
> On Wed, 13 Jun 2007, Tahir Akhtar wrote:
> > 1. Create a workbook from POI
> > 2. Add three sheets,
> > 3. Fill each sheet with some data
> > 4. Set paper size to A4
> > 5. Write to file
> 
> To narrow it down, could you try:
> 1. Create a workbook from POI
> 2. Add three sheets,
> 3. Fill each sheet with some data
> 4. Write to file
> 5. Open in excel
> 6. Change to A4, and save
> 7. Open in POI
> 8. Select all sheets
> 9. Write to new file
> 
> That'll allow us to know if the problem is selecting A4 sheets, or if it's
> setting the paper size to A4
> 
> Nick
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to