简体   繁体   English

从数据库PHPExcel类的数据中合并Excel工作表的单元格

[英]Merge cells of excel sheet from the data from database PHPExcel class

Im trying to format the excel sheet with PHPExcel class. 我试图用PHPExcel类格式化Excel工作表。 The scenario is i fetch data from the database and i want to merge the header cells according to the count of items. 场景是我从数据库中获取数据,并且我想根据项数合并标题单元格。

database output and the cell merging i need is shown in the image screenshot 图片截图显示了数据库输出和我需要的单元格合并

Use the worksheet's mergeCells() method: eg 使用工作表的mergeCells()方法:例如

`$objPHPExcel->getActiveSheet()->mergeCells('B1:B3');`

as shown in the examples such as 05featuredemo.php and described in the PHPExcel Documentation 如示例05featuredemo.php中所示,并在PHPExcel文档中进行了描述

But your code will have to keep track of the item headers that you're adding,an work out the range of cells that need merging 但是您的代码将必须跟踪要添加的项目标题,从而确定需要合并的单元格范围

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM