Bug 24071

Summary: "Fit To" option in the Page Setup Properties not working
Product: POI Reporter: mjmoore
Component: HSSFAssignee: POI Developers List <dev>
Severity: normal CC: ramandeep21119
Priority: P3    
Version: 2.0-pre3   
Target Milestone: ---   
Hardware: PC   
OS: All   

Description mjmoore 2003-10-23 17:05:29 UTC
I am using the HSSFSheet class as well as the HSSFPrintSetup class to set some 
page setup properties for printing.  The properties I am trying to set are in 
the scaling section of the page setup form.  The second radio button of the 
scaling section is the "Fit to" radio button.  According to the java doc, I 
should be able to select that radio button and set the width of pages to fit to 
and height of pages to fit to using the HSSFPrintSetup class's methods of 
setFitWidth and setFitHeight.  

For example:

        this.sheet.getPrintSetup().setFitWidth((short) 1);
        this.sheet.getPrintSetup().setFitHeight((short) 26);

sets the values in the Width and Height properties of the scaling section, but 
it does not select the "Fit To" radio button, which is required to use these 

Upon further investigation, I found that he setScale method of the 
HSSFPrintSetup class selects the "Fit To" radio button when used alone, but 
when used in conjuction with the setHeight and setWidth methods, selects 
the "Adjust To" radio button in the scaling section.

For Example:
 this.sheet.getPrintSetup().setScale((short) 1);
 -Sets the "Fit To" radio button and sets the width and height values to 1.
  this.sheet.getPrintSetup().setScale((short) 1);
  this.sheet.getPrintSetup().setFitWidth((short) 1);
  this.sheet.getPrintSetup().setFitHeight((short) 26);
 -Selects the "Adjust To" option button and sets the value to 1, but sets the 
width and height values of the "Fit to" radio to the correct values of 1 and 

How can I set the values of the "Fit to" radio button as well as set the values 
to what I need?
Comment 1 Shawn Laubach 2003-10-23 17:17:06 UTC
If you look at the documentation at http://jakarta.apache.org/poi/hssf/quick-
guide.html#PrintArea you must also call sheet.setAutobreaks(true);

BTW, I'm renaming the header to Fit To