Counting with rowHeight?

Topics: User Forum
Mar 8, 2011 at 6:39 AM
Edited Mar 8, 2011 at 9:00 AM

Dear community,

I got a small problem when automatically creating a multi-page survey with PHPExcel.

To achieve one questionwith its answers not being ripped in two pieces when being at the end of an Excel page, I want to count the rowHeights so it jumps to the whole question with answers next page automatically. However, this is not working correctly.


This is the code:

$row = 1;

$total = 0;

    $height = $objPHPExcel->getActiveSheet()->getRowDimension($row)->getRowHeight();

    $total += $height;
    echo "Height 1 ".$total;           // says 25

$row++;   // (2)

    $height = $objPHPExcel->getActiveSheet()->getRowDimension($row)->getRowHeight();

    $total += $height;
    echo "Height 2 ".$total;        // says -1 / 24


The first one shows me a correct "25". However, as soon as I increment the row variable, it only does -1 on and on. So the total variable decreases. If I have 25 rows, the last total echo says "0" instead of "625" or something. Does someone have solution for this tiny problem? Or is there any other way to check if a new page has to start?


Btw. I got PHPExcel V  1.7.4, WinXP and PHP V 5.3.1