How to merge and split cells in PHPExcel

*文
Release: 2023-03-18 21:46:01
Original
6773 people have browsed it

How does PHPExcel merge and split cells? This article mainly introduces the method of merging and splitting cells in PHPExcel, involving the usage skills of setCellValue and mergeCells methods in PHPExcel. Friends in need can refer to it. I hope to be helpful.

$objPHPExcel;
$filepath="c:\temp.xlsx";
try {
  $objReader = PHPExcel_IOFactory::createReader('Excel2007');
  $objPHPExcel = $objReader->load($filepath);
} catch (Exception $e) {
  die();
}
$column_index = "A";
//清空要合并的首行单元格值,用于填充合并后的单元格值
$objPHPExcel->getActiveSheet()->setCellValue($column_index.''.$beginRow,'');
//合并单元格,值为''
$objPHPExcel->getActiveSheet()->mergeCells($column_index.''.$beginRow.":".$column_index.''.$endRow);
//拆分单元格,将清空合并前单元格的值并还原合并前单元格的样式
$objPHPExcel->getActiveSheet()->unmergeCells($column_index.''.$beginRow.":".$column_index.''.$endRow);
Copy after login

Related recommendations:

Example sharing of solving PHPExcel memory leaks

PHPExcel introduces the method of freezing and locking headers

How does phpexcel import excel to process big data code examples

The above is the detailed content of How to merge and split cells in PHPExcel. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!