previousWorksheet::printRowColHeaders (Previous) (Next) Worksheet::setHPagebreaksnext

View this page in Last updated: Sun, 18 Oct 2009
English | Brazilian Portuguese | Chinese | Dutch | French | German | Hungarian | Japanese | Polish | Russian | Spanish | Turkish

Worksheet::fitToPages

Worksheet::fitToPages – Store the vertical and horizontal number of pages that will define the

Synopsis

require_once "Spreadsheet/Excel/Writer.php";

void Worksheet::fitToPages ( integer $width , integer $height )

Description

Store the vertical and horizontal number of pages that will define the maximum area printed. It doesn't seem to work with OpenOffice.

Parameter

  • integer $width - Maximun width of printed area in pages

  • integer $height - Maximun heigth of printed area in pages

Note

This function can not be called statically.

Example

Using fitToPages()

<?php

?>
previousWorksheet::printRowColHeaders (Previous) (Next) Worksheet::setHPagebreaksnext

Download Documentation Last updated: Sun, 18 Oct 2009
Do you think that something on this page is wrong? Please file a bug report or add a note.
User Notes:
Note by: JohnE
Luis, thanks for the code to calculate number of pages. I just use:
$worksheet->fitToPages(1,0);

Is your code better for certain situations, or is it the same thing? Seems a lot simpler to me.
Note by: luis.sv@gmail.com
It is working for me in OpenOffice.org 2.3.1 and Excel 2007

I'm calculating the number of pages with this code:

//total_rows is the total number of rows that I'm going to have in the spreadsheet
//total_rows_per_page is the number of rows that I want to print in each page

$total_pages=ceil($total_rows/$total_rows_per_page);

$worksheet->fitToPages(1,$total_pages);
//I put "1" in the first parameter because I just want to have a horizontal page


Regards,
Luis Rodríguez