0

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?

RomanHotsiy
  • 4,978
  • 1
  • 25
  • 36
user26944
  • 1
  • 1

1 Answers1

1

@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

Community
  • 1
  • 1
Abhijit Jagtap
  • 2,740
  • 2
  • 29
  • 43
  • Maybe I wasn't clear. I don't want the 2 merged values in the same row. I want the second value in the row to the right of it. So I dont want to merge the values but rather put the second value in a row next to the merged rows. – user26944 Oct 12 '16 at 14:45