How to merge and split cells in PHPExcel: how to split cells in phpexcel
This document describes how to merge and split cells in PHPExcel. We will share this with you for your reference. The details are as follows:
$ ObjPHPExcel; $ filepath = "c: \ temp.xlsx"; try {$ objReader = PHPExcel_IOFactory: createReader ('excel2007 '); $ objPHPExcel = $ objReader-> load ($ filepath);} catch (Exception $ e) {die () ;}$ column_index = ""; // clear the cell value of the first row to be merged. It is used to fill in the merged cell value $ objPHPExcel-> getActiveSheet ()-> setCellValue ($ column_index. ''. $ beginRow, ''); // merge cells. The value is'' $ objPHPExcel-> getActiveSheet ()-> mergeCells ($ column_index. ''. $ beginRow. ":". $ column_index. ''. $ endRow); // split the cells, clear the values of the cells before the merge, and restore the style of the cells before the merge. $ objPHPExcel-> getActiveSheet ()-> unmergeCells ($ column_index. ''. $ beginRow. ":". $ column_index. ''. $ endRow );
Refer:
Merge cells in PHPExcel
PHPExcel: How to Merge Cells