第一范文网 - 专业文章范例文档资料分享平台

PHPWord中文手册

来源:用户分享 时间:2025/6/25 15:03:46 本文由loading 分享 下载这篇文档手机版
说明:文章内容仅供预览,部分内容可能不全,需要完整文档或者需要复制内容,请下载word后使用。下载word有问题请添加微信号:xxxxxxx或QQ:xxxxxx 处理(尽可能给您提供完整文档),感谢您的支持与谅解。

目录样式属性列表:

样式属性区分大小写 !

名称 描述 tabLeader 标题的类型和对应页码.默认使用系统常量 PHPWord_Style_TOC::TABLEADER_... tabPos 标题与页码的位臵,单位: twips. Indent 标题缩进,单位: twips.

表格

添加表格

添加表格使用函数方法:addTable: $table = $section->addTable( [$tableStyle] ); 参数 $tableStyle 是可选的. 表格样式这章有关于表格样式的详细说明。为addTable建立一个本地对象,我们需要使用这个对象来调用相关函数方法。

添加行 $table->addRow( [$height] ); 行的高度可以通过$height参数来设臵,单位:twips.

添加单元格

单元格添加前必须先添加行,添加单元格的函数方法为: addCell $cell = $table->addCell(h, [$cellStyle] ); addCell() 参数 类型 描述 $width Integer 单元格宽度: twips. 17

$cellStyle Array 单元格样式 为addcell创建一个本地对象,需要使用该对象来调用以下函数 名称 描述 addText 添加文本 addTextBreak 添加换行符 addLink 添加链接 addImage 添加图片 addMemoryImag添加水印 e addListItem 添加列表 addObject 添加对象 addPreserveTe添加页码,只对页眉和页脚有效 xt 示例1: $table = $section->addTable(); $table->addRow(); $cell = $table->addCell(2000); $cell->addText('Cell 1'); $cell = $table->addCell(2000); $cell->addText('Cell 2'); $cell = $table->addCell(2000); $cell->addText('Cell 3'); 示例2: $table = $section->addTable(); $table->addRow(400); $table->addCell(2000)->addText('Cell 1'); $table->addCell(2000)->addText('Cell 2'); $table->addCell(2000)->addText('Cell 3'); $table->addRow(1000); $table->addCell(2000)->addText('Cell 4'); $table->addCell(2000)->addText('Cell 5'); 18

$table->addCell(2000)->addText('Cell 6');

单元格样式

使用addCell的第二个参数来给单元格设臵样式

示例: $cellStyle = array('textDirection'=>PHPWord_Style_Cell::TEXT_DIR_BTLR, 'bgColor'=>'C0C0C0'); $table = $section->addTable(); $table->addRow(1000); $table->addCell(2000, $cellStyle)->addText('Cell 1'); $table->addCell(2000, $cellStyle)->addText('Cell 2'); $table->addCell(2000, $cellStyle)->addText('Cell 3'); $table->addRow(); $table->addCell(2000)->addText('Cell 4'); $table->addCell(2000)->addText('Cell 5'); $table->addCell(2000)->addText('Cell 6'); 单元格样式属性列表:

属性大小写敏感 ! 名称 描述 valign 单元格内容对齐方式: left, right, center textDirection 文本方向. 使用预定常量 PHPWord_Style_Cell:: TEXT_DIR_... bgColor 单元格背景色 borderTopSize 单元格上边框尺寸,单位 twips. borderTopColor 单元格上边框颜色 borderLeftSize 单元格左边框尺寸,单位twips borderLeftColo单元格左边框颜色 r 19

borderRightSiz单元格右边框尺寸,单位twips e borderRightCol单元格右边框颜色 or borderBottomSi单元格下边框尺寸 ,单位twips ze borderBottomCo单元格下边框颜色 lor 表格样式

我们可以设臵整个表格的样式,通过创建表格函数addTable的参数$tableStyle,表格具有如下样式属性 属性名称大小写敏感! 名称 描述 cellMarginTo单元格上边距,单位: twips. p cellMarginLe单元格左边距,单位: twips. ft cellMarginRi单元格右边距,单位: twips. ght cellMarginBo单元格下边距,单位: twips. ttom 示例: $tableStyle = array('cellMarginTop'=>80, 'cellMarginLeft'=>80, 'cellMarginRight'=>80, 'cellMarginBottom'=>80); $table = $section->addTable($tableStyle); 我们可以使用函数方法: addTableStyle,为表格定义一个完整的样式。

20

搜索更多关于: PHPWord中文手册 的文档
PHPWord中文手册.doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印
本文链接:https://www.diyifanwen.net/c1qcnn5koeg85bn78adgm_5.html(转载请注明文章来源)
热门推荐
Copyright © 2012-2023 第一范文网 版权所有 免责声明 | 联系我们
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ:xxxxxx 邮箱:xxxxxx@qq.com
渝ICP备2023013149号
Top