load($filepath );} catch ("/> load($filepath );} catch (">

Home  >  Article  >  Backend Development  >  Excel split cells PHPExcel method to merge and split cells

Excel split cells PHPExcel method to merge and split cells

WBOY
WBOYOriginal
2016-07-28 08:27:201438browse

The example in this article describes how to merge and split cells in PHPExcel. Share it with everyone 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 = "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);

Reference:

Merge cells in PHPExcel
PHPExcel: How to Merge Cells

Readers who are interested in more PHP-related content can check out this site's special topic: "php Summary of skills for operating office documents (including word, excel, access, ppt)", "Complete of PHP array (Array) operation skills", "Summary of PHP sorting algorithm", "Summary of PHP common traversal algorithms and skills", "PHP data structure and Algorithm Tutorial", "php Programming Algorithm Summary", "PHP Mathematical Operation Skills Summary", "php Regular Expression Usage Summary", "PHP Operations and Operator Usage Summary", "php String Usage Summary" and "A Summary of Common PHP Database Operation Skills"

I hope this article will be helpful to everyone in PHP programming.

The above introduces the method of splitting cells in excel and merging and splitting cells in PHPExcel, including the content of splitting cells in excel. I hope it will be helpful to friends who are interested in PHP tutorials.

Statement:
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