user26944
user26944

Reputation: 1

PHPExcel Values get remove on merge row

In my application, I have a json file which holds products. In a loop I loop through every item and put them in cells.

$this->row = 4;
foreach ($this->json['products'] as $product) {
    $this->template->getActiveSheet()->setCellValueByColumnAndRow(6, $this->row, $product);
    $this->row++;
}

Afterwards, I am setting the style of the excel file

$this->template->getActiveSheet()->mergeCells('J6:K6');

Basically merging row J and K with each other but because of this the value of K gets removed. How can I set the value of K to the next row value dynamically after the merge of an inaccessible row?

Upvotes: 0

Views: 953

Answers (1)

Abhijit Jagtap
Abhijit Jagtap

Reputation: 2702

@jahmic gives answer here

//There is a specific method to do this:

$objPHPExcel->getActiveSheet()->mergeCells('J6:K6');
//You can also use:

$objPHPExcel->setActiveSheetIndex(0)->mergeCells('J6:K6');
//That should do the trick.

Link is Merge Cell values with PHPExcel - PHP

Upvotes: 1

Related Questions