@brief Fit the printed area to a specific number of pages both vertically
and horizontally.
@param worksheet Pointer to a lxw_worksheet instance to be updated.
@param width Number of pages horizontally.
@param height Number of pages vertically.
The %worksheet_fit_to_pages() function is used to fit the printed area to
a specific number of pages both vertically and horizontally. If the printed
area exceeds the specified number of pages it will be scaled down to
fit. This ensures that the printed area will always appear on the specified
number of pages even if the page size or margins change:
@code
worksheet_fit_to_pages(worksheet1, 1, 1); // Fit to 1x1 pages.
worksheet_fit_to_pages(worksheet2, 2, 1); // Fit to 2x1 pages.
worksheet_fit_to_pages(worksheet3, 1, 2); // Fit to 1x2 pages.
@endcode
The print area can be defined using the worksheet_print_area() function
as described above.
A common requirement is to fit the printed output to n pages wide but
have the height be as long as necessary. To achieve this set the height
to zero:
@code
// 1 page wide and as long as necessary.
worksheet_fit_to_pages(worksheet, 1, 0);
@endcode
**Note**:
- Although it is valid to use both %worksheet_fit_to_pages() and
worksheet_set_print_scale() on the same worksheet Excel only allows one
of these options to be active at a time. The last function call made will
set the active option.
- The %worksheet_fit_to_pages() function will override any manual page
breaks that are defined in the worksheet.
- When using %worksheet_fit_to_pages() it may also be required to set the
printer paper size using worksheet_set_paper() or else Excel will
default to "US Letter".
@brief Fit the printed area to a specific number of pages both vertically and horizontally.
@param worksheet Pointer to a lxw_worksheet instance to be updated. @param width Number of pages horizontally. @param height Number of pages vertically.
The %worksheet_fit_to_pages() function is used to fit the printed area to a specific number of pages both vertically and horizontally. If the printed area exceeds the specified number of pages it will be scaled down to fit. This ensures that the printed area will always appear on the specified number of pages even if the page size or margins change:
@code worksheet_fit_to_pages(worksheet1, 1, 1); // Fit to 1x1 pages. worksheet_fit_to_pages(worksheet2, 2, 1); // Fit to 2x1 pages. worksheet_fit_to_pages(worksheet3, 1, 2); // Fit to 1x2 pages. @endcode
The print area can be defined using the worksheet_print_area() function as described above.
A common requirement is to fit the printed output to n pages wide but have the height be as long as necessary. To achieve this set the height to zero:
@code // 1 page wide and as long as necessary. worksheet_fit_to_pages(worksheet, 1, 0); @endcode
**Note**:
- Although it is valid to use both %worksheet_fit_to_pages() and worksheet_set_print_scale() on the same worksheet Excel only allows one of these options to be active at a time. The last function call made will set the active option.
- The %worksheet_fit_to_pages() function will override any manual page breaks that are defined in the worksheet.
- When using %worksheet_fit_to_pages() it may also be required to set the printer paper size using worksheet_set_paper() or else Excel will default to "US Letter".