. . . . I am using Codeigniter 3.1 and PHPExcel 1.8.
I have a function that creates a PHPExcel Object and returns it and the other function outputs the Excel to browser
Everything is working perfectly fine. Now on specific rows I need to add page breaks.
if($count == 4 || ($count > 4 && (($count - 4) % 6 == 0))){
//echo("A - $row <br>Count - $count<br><hr>");
$sheet->setBreak('A' . $row , PHPExcel_Worksheet::BREAK_ROW );
}
The echo is giving me my required rows, so the condition is working fine. The only issues is . . . . . page break not working. So any suggestions?
Following is the code used for generating the file
header("Content-Type: application/vnd.ms-excel");
header("Content-Disposition: attachment; filename=$file_name");
header("Cache-Control: max-age=0");
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, "Excel5");
$objWriter->save("php://output");
Problem solved. Initially I was using the setbreak function while inserting rows. and whenever the condition meets, call the function. I was going through the code, got an idea, implemented it and solved. Instead of calling the function setbreak during row generation, i stored the row reference in an array, and then after doing all page settings, at the end looped the array and called setbreak on the rows and it worked :). Thanks Mark as discussing with you has helped me twice now :)