Answer the question
In order to leave comments, you need to log in
PHPExcel how to insert an array via fromArray if template has merged cells?
There is a template in which some cells are merged. The script generates data and writes to the template. The problem with merged cells, when you insert an array, the data is written to the cells that are included in the merger and, accordingly, all this is displayed crookedly. How to skip such cells?
It is not known in advance which are combined and which are not (by rows or columns). The output of the block starts from the given coordinates.
Example:
....
$arr=[1,2,3,4,5,6,7,8,9,10];
$sheet->fromArray($arr, null, 'A1');
Answer the question
In order to leave comments, you need to log in
Write your own implementation of filling cells from an array based on the original - https://github.com/PHPOffice/PHPExcel/blob/1c8c237...
When filling, check if the cell is included in the merged list. If it enters, you skip it, except for the boundary cell.
An example of checking a cell for merging: stackoverflow.com/a/7299859/1559720
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question