Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PhpExcel - How insert the same row after row N?

Tags:

php

phpexcel

I have php template. this is a empty table (T0 rows) with some footer at the bottom. From php i try to fill the table, but if i had T1 rows (T1 > T0) then trouble appers.

I beleve that empty table should contains one empty row. And we know this row number. Then we copy this row (insert the same rows) T1 times and fill empty table. Footer goes down. And everything will be ok

Give me an example, how i can do this. Thank you.

PhpExcel 1.7.6

like image 269
Luciuz Avatar asked Aug 22 '12 09:08

Luciuz


1 Answers

Just copying what @markBaker said (so that we can set the solution as an answer):

//Insert 10 new rows between rows 1 and 2 
$objPHPExcel->getActiveSheet()->insertNewRowBefore(2,10); 

Now applying the style of the row 2 to the inserted rows:

$objPHPExcel->getActiveSheet()->duplicateStyle($objPHPExcel->getActiveSheet()->getStyle('A1'),'A2:A10'); 
like image 167
sergioviniciuss Avatar answered Oct 02 '22 05:10

sergioviniciuss