Access to row created with insertNewRowBefore

Topics: Developer Forum, User Forum
Jul 27, 2009 at 9:52 AM

Hi everybody. Can you tell me one thing. Can I get access to newly created row with insertNewRowBefore?

Here my example:


header('Content-Type: application/vnd.openXMLformats-officedocument.spreadsheetml.sheet');
header('Content-Disposition: attachment;filename="myfile.xlsx"');
header('Cache-Control: max-age=0');

$objPHPExcel = PHPExcel_IOFactory::load('sample.xlsx');
$objWorksheet = $objPHPExcel->getActiveSheet();
$objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(1,6,'some data here');

$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');

Method setCellValueByColumnAndRow() inserts data into the cell of loaded file, not in newly created. I have to insert new empty row, save file, open it and fill data. Can I do this without saving temp file?



Jul 27, 2009 at 8:51 PM
Edited Jul 27, 2009 at 8:54 PM

>> Can I do this without saving temp file?

Hmm... I am not sure what you mean by saving a temp file.

Your current code works like this.

1. You open your template file sample.xlsx

2. Insert 1 row before row 7 and fill some text into cell (1,6) = B6

3. You save redirecting output to client browser

Now what is different from the expected? To me it looks like the code is doing exactly what it should?

Jul 27, 2009 at 9:48 PM

Thanx a lot. Yes, it works well. Those situation I can't repeat again.