首页 > Web开发 > 详细

phpexcel 合并单元格后的动态行高

时间:2021-07-22 17:09:20      阅读:38      评论:0      收藏:0      [点我收藏+]

思路参考:https://www.it1352.com/1745868.html,如下所示:

You can also do it like this

  1. Merge cells you want, for example: A7:C7
  2. Copy context of it to one cell for instance Z7
  3. Set the width of the merged cells to Z7
  4. Apply Wrap Text to the Z7
  5. Make Z7 not visible

脚本实现:

        

$objActSheet->getColumnDimension(‘A‘)->setWidth(26);
        for($i=1;$i<14;$i++){
            $objActSheet->getColumnDimension($col_name[$i])->setWidth(17);
        }
        $objActSheet->getColumnDimension(‘Z‘)->setWidth(43);
        $objActSheet->getStyle(‘A:Z‘)->getAlignment()->setWrapText(true); //Adaptive line feed
......
$objActSheet->setCellValue(‘Z‘.$current_row,$val);
$objActSheet->getColumnDimension(‘Z‘)->setVisible(false);
......

 

phpexcel 合并单元格后的动态行高

原文:https://www.cnblogs.com/mianbaoshu/p/15044577.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!