I am using PHPExcel to read a template, write and edit some things and then save it using a different name. Some of the rows in the template already have "wrap text" applied to them so that the row can auto adjust its height. The problem arise when I need to insert data to some row and then merge it with another row. From several experiment that I have done, the row seemed to automatically adjust its height based on my data, but then it will revert to its original height when I merge them with another row. Here is the snippet of the code that I use
$reader = PHPExcel_IOFactory::createReader('Excel2007');
$frTemplate = $reader->load("../modern/document/Template/FR-006
Template.xlsx");
$frTemplate->setActiveSheetIndex(1);
$highlightRow = 6+$t;
$frTemplate->getActiveSheet()->setCellValueExplicitByColumnAndRow(8, 6+$t,
$change['reference']);
$frTemplate->getActiveSheet()->setCellValueExplicitByColumnAndRow(9, 6+$t,
substr($change['argument'], 6));
$range = "I".$highlightRow.":"."I".($highlightRow+1);
$frTemplate->getActiveSheet()->mergeCells($range);
$range = "J".$highlightRow.":"."J".($highlightRow+1);
$frTemplate->getActiveSheet()->mergeCells($range);
I try to get the height of the row after auto resize, hoping that maybe I can resize it back after merging it, but I only get -1 as a return value. From what I understand, -1 is assigned to row height so that it can be auto resized.
So, basically I have two questions:
- Is the height of a row is reset after it is merged with another row? Or is there anything wrong with my code?
- Is there any way to get the height of a row after it is resized automatically?
Thanks