user3553866
user3553866

Reputation: 326

use activecell to go n rows below in PHPEXCEL

I would like to put a value in the cell B24

I'm using this code :

$active_cell = $objPHPExcel->getActiveSheet()->setSelectedCell('B'.(17+$arr_periodes[2]));

Then, I would like to go 4 lines below

How can I use $active_cell to go 4 rows below ?

I tried OFFSET, it doesn't work :

$objPHPExcel->getActiveSheet()->setSelectedCell($active_cell:OFFSET($arr_periodes[1]),'x');

Upvotes: 0

Views: 1636

Answers (2)

user3553866
user3553866

Reputation: 326

This is what I did, it's working :

$objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(($arr_periodes[2]+1),17+($arr_periodes[1]),'X');

Upvotes: 0

Mark Baker
Mark Baker

Reputation: 212412

To put a value in cell B24

$active_cell = $objPHPExcel->getActiveSheet()
    ->setCellValue('B24', 'Value that I want to put in the cell', true);

To set the active cell 4 cells below B24

$rc = PHPExcel_Cell:coordinateFromString($active_cell->getCoordinate());
$rc[1] += 4;
$objPHPExcel->getActiveSheet()
    ->setSelectedCell(
        implode($rc)
    );

Upvotes: 1

Related Questions