当前位置:首页 > PHPWord中文手册
目录样式属性列表:
样式属性区分大小写 !
名称 描述 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
共分享92篇相关文档