/PHPWord/Style/Cell.php添加属性和方法

    private $_rowMerge = null;  private $_cellMerge = null;  public function getRowMerge()  {  return $this->_rowMerge;  }  public function setRowMerge($pValue = null)  {  $this->_rowMerge = $pValue;  return $this;  }  public function getCellMerge()  {  return $this->_cellMerge;  }  public function setCellValue($pValue = null)  {  $this->_cellMerge = $pValue;  return $this;  }  

/PHPWord/Writer/Word2007/base.php中_writeCellStyle方法添加

    $rowMerge = $style->getRowMerge();    $cellMerge = $style->getCellMerge();  

在同方法中修改styles(感谢网友提出,还真忘了加上这个),通过这个才能进入if(styles(感谢网友提出,还真忘了加上这个),通过这个才能进入if (styles)代码块里面:

    $styles = (!is_null($bgColor) || !is_null($valign) || !is_null($textDir)   || $borders || !is_null($rowMerge) || !is_null($cellMerge)) ? true : false;  

在同方法if ($styles)中添加

    if (!is_null($cellMerge))  {  //$objWriter->startElement('w:gridSpan');  $objWriter->startElement('w:hMerge');  if ((string)$cellMerge !== 'continue')  {   $objWriter->writeAttribute('w:val', $cellMerge);  }  $objWriter->endElement();  }  if (!is_null($rowMerge))  {  $objWriter->startElement('w:vMerge');  if ((string)$rowMerge !== 'continue')  {  $objWriter->writeAttribute('w:val', $rowMerge);  }  $objWriter->endElement();  }  

使用方法:

$styleTable = array('borderSize'=>6, 'borderColor'=>'000000', 'cellMargin'=>80);
$styleCell = array('valign'=>'center', 'align'=>'center');
$fontStyle = array('size'=>10 /*,'bold'=>true*/);
$PHPWord->addTableStyle('myOwnTableStyle', $styleTable, $fontStyle);
$table = $section->addTable('myOwnTableStyle');
$table->addRow();
$table->addCell(1600)->addText('分类', $fontStyle, $styleCell);
$table->addCell(1600)->addText('序号', $fontStyle, $styleCell);
$table->addCell(1600)->addText('制作项目', $fontStyle, $styleCell);
$table->addCell(2000)->addText('制作说明', $fontStyle, $styleCell);
$table->addCell(1600)->addText('采用技术', $fontStyle, $styleCell);
$table->addCell(1600)->addText('报价', $fontStyle, $styleCell);
$table->addCell(1600)->addText('数量', $fontStyle, $styleCell);
$table->addCell(1600)->addText('总价', $fontStyle, $styleCell);
$table->addCell(2600)->addText('备注', $fontStyle, $styleCell);  $table->addRow();
$table->addCell(600, array('rowMerge' => 'restart', 'valign' => "center"))->addText('内容部分');
$table->addCell(1600)->addText('1', $fontStyle, $styleCell);
$table->addCell(1600)->addText('片头LOGO演绎', $fontStyle, $styleCell);
$table->addCell(2000)->addText('10秒左右的视频制作', $fontStyle, $styleCell);
$table->addCell(1600)->addText('AE', $fontStyle, $styleCell);
$table->addCell(1600)->addText('2000元/个', $fontStyle, $styleCell);
$table->addCell(1600)->addText('1', $fontStyle, $styleCell);
$table->addCell(1600)->addText('', $fontStyle, $styleCell);
$table->addCell(2600)->addText('', $fontStyle, $styleCell);  $table->addRow();
$table->addCell(1600, array('rowMerge' => 'continue'));
$table->addCell(1600)->addText('2', $fontStyle, $styleCell);
$table->addCell(1600)->addText('UI界面设计', $fontStyle, $styleCell);
$table->addCell(2000)->addText('程序框架设计及动态交互设计', $fontStyle, $styleCell);
$table->addCell(1600)->addText('AI/PS', $fontStyle, $styleCell);
$table->addCell(1600)->addText('7000元/套', $fontStyle, $styleCell);
$table->addCell(1600)->addText('1', $fontStyle, $styleCell);
$table->addCell(1600)->addText('', $fontStyle, $styleCell);
$table->addCell(2600)->addText('', $fontStyle, $styleCell);  $table->addRow();
$table->addCell(1600, array('rowMerge' => 'continue'));
$table->addCell(1600)->addText('3', $fontStyle, $styleCell);
$table->addCell(1600)->addText('文案创意撰写', $fontStyle, $styleCell);
$table->addCell(2000)->addText('系统中要表现的项目内容的创意和文案撰写', $fontStyle, $styleCell);
$table->addCell(1600)->addText('文案策划创意', $fontStyle, $styleCell);
$table->addCell(1600)->addText('6000元/套', $fontStyle, $styleCell);
$table->addCell(1600)->addText('1', $fontStyle, $styleCell);
$table->addCell(1600)->addText('', $fontStyle, $styleCell);
$table->addCell(2600)->addText('建议不做', $fontStyle, $styleCell);  $table->addRow(400);
$table->addCell(1600, array('cellMerge' => 'restart', 'valign' => "center"))->addText('横向合并');
$table->addCell(1600, array('cellMerge' => 'continue'));
$table->addCell(1600, array('cellMerge' => 'continue'));
$table->addCell(1600, array('cellMerge' => 'continue')); 

PHPWord 表格居中和合并单元格相关推荐

  1. php word 合并单元格格式,PHPWord 表格居中和合并单元格

    /PHPWord/Style/Cell.php添加属性和方法 private $_rowMerge = null; private $_cellMerge = null; public functio ...

  2. PHPWord 表格居中和合并单元格

    /PHPWord/Style/Cell.php添加属性和方法 private $_rowMerge = null;private $_cellMerge = null;public function ...

  3. php word 合并单元格格式,PHPWord小记之表格居中和合并单元格

    和上篇一样,文章基于PHPword Beta 0.6.3,可能有些功能在PHPWord后续版本已经修正. 1.表格对齐和表格缩进 /PHPWord/Style/TableFull.php添加相关属性和 ...

  4. python pptx 关于在ppt里插入表格,调整合并单元格的问题

    python pptx 关于在ppt里插入表格,调整合并单元格的问题 需求 找到合并了的单元格 思路 判断是否是合并单元格 合并位置的记录 合并 代码 需求 首先我这是为了从word里面将内容导到pp ...

  5. PyQT5 (四十六) 在 QTableWidget 表格中设置合并单元格 的案例

    在 QTableWidget 表格中设置合并单元格 的案例 setSpan(row, col, 要合并的行数, 要合并的列数) import sysfrom PyQt5 import QtPrintS ...

  6. 动态处理表格多行合并单元格、同时解决hover错乱问题 - Vue Element Table

    简介: el-table单元格合并,处理hover错乱问题,自定义底部合计栏. 如图所示: 源码(复制另存txt,修改.html直接运行) <!DOCTYPE html> <html ...

  7. 用Xlsx xlsx-style 导出excel表格,附带合并单元格,文字居中,文字颜色字体大小等样式 (复制即可实现)

    提示:写完文章后,目录可以自动生成,如何生成可参考右边的帮助文档 文章目录 系列文章目录 前言 一.用Xlsx xlsx-style 导出excel表格 二.使用步骤 1.安装插件 2.引入 总结 前 ...

  8. java poi生成word 插入表格,图片,自动合并单元格,并且可以在已存在的word上追加

    poi版本选3.10以上的 要不然插入图片 word会打不开 <dependency><groupId>org.apache.poi</groupId><ar ...

  9. html表格里面怎么合并单元格的快捷键,合并单元格快捷键,教您excel怎么合并单元格快捷键...

    快捷键是大家办公常用的操作技巧,我们办公中经常会制作一些表格,为了让表格达到最终想要的效果,时常需要将Excel中多个单元格合并成一个单元格.当然,操作方法也有多种,下面,小编给大伙带来了excel合 ...

  10. html表格里面怎么合并单元格的快捷键,excel合并单元格快捷键是什么

    excel合并单元格快捷键是什么 快捷键的熟练使用可以帮助我们在工作中提高效率,那么excel合并单元格快捷键是什么呢?接下来为大家讲解excel合并单元格快捷键设置方法的图文演示. 合并单元格在ex ...

最新文章

  1. 20170824图论选讲部分习题
  2. linux 手动睡眠
  3. Android Bug分析系列:第三方平台安装app启动后,home键回到桌面后点击app启动时会再次启动入口类bug的原因剖析...
  4. 四、PHP基础——会话技术Cookie 和 Session
  5. java final static_Java基础之final、static关键字
  6. m3u8和HLS下载和分析工具
  7. 反客为主 ,Linux 成为微软 Azure 上最流行的操作系统
  8. A child container failed during start 解决方案
  9. 第十三周项目1-数组大折腾(一)
  10. 暴风转码转超清文件_暴风影音16破解版下载-暴风影音16多开精简版(附怎么用) v9.4.1029.1111...
  11. Mybatis源码解析!!! 附中午注释源码
  12. NX/UG二次开发—装配—实现标准件库添加组件效果
  13. 美团优选大数据开发岗面试真题-附答案详细解析
  14. LESS CSS 框架简介
  15. JZOJ1900. 【2010集训队出题】矩阵
  16. Python-Django框架学习笔记——第一课:Hello World
  17. .ipynb_checkpoints隐藏文件引发的错误
  18. 关于4月2号OpenAI大面积封停亚洲(中国大陆)帐号的问题和应对策略
  19. 电脑个性化和显示设置打不开解决方法
  20. 《Windows 8 权威指南》——第2章 Windows 8 Metro应用 2.1 打造快速流畅的动态Windows 8 Metro应用体验...

热门文章

  1. 深富策略:险资密集调研 周期股板块能否崛起?
  2. 关于段地址和偏移地址的理解
  3. Go语言学习日记【十八】golang中context包简介与使用
  4. 取消计算机触摸板,笔记本电脑触摸板,详细教您笔记本电脑触摸板怎么关闭
  5. [渝粤教育] 四川大学 土木工程概论 参考 资料
  6. Flink WaterMark 详解及结合 WaterMark 处理延迟数据
  7. 恒生UFX 统一接入介绍
  8. in predict assert self.binded and self.params_initialized AssertionError
  9. 开发人员系统功能设计常用办公软件分享
  10. CSS Sprite(CSS雪碧图)