PHP生成word文档,表格实例
2015-03-27 13:42
232 查看
<?php require_once 'PHPWord.php'; // New Word Document $PHPWord = new PHPWord(); // New portrait section $section = $PHPWord->createSection(); $PHPWord->addFontStyle('rStyle', array('bold'=>true,'color'=>'000000','size'=>16)); $PHPWord->addParagraphStyle('pStyle', array('align'=>'center')); $section->addText('×××公司招聘信息', 'rStyle', 'pStyle'); $section->addTextBreak(2); // Define table style arrays $styleTable = array('borderSize'=>6, 'borderColor'=>'006699', 'cellMargin'=>80); // Add table style $PHPWord->addTableStyle('myOwnTableStyle', $styleTable); // Add table $table = $section->addTable('myOwnTableStyle'); $fontStyle = array('bold'=>true, 'align'=>'center'); // Add more rows / cells $table->addRow(); $table->addCell(2000)->addText("单位名称",$fontStyle); $table->addCell(3000)->addText("",$fontStyle); $table->addCell(2000)->addText("详细地址",$fontStyle); $table->addCell(3000)->addText("",$fontStyle); $table->addRow(); $table->addCell(2000)->addText("场所负责人",$fontStyle); $table->addCell(3000)->addText("",$fontStyle); $table->addCell(2000)->addText("联系电话",$fontStyle); $table->addCell(3000)->addText("",$fontStyle); $styleTable2 = array('borderColor'=>'006699', 'borderLeftSize'=>6,'borderRightSize'=>6,'cellMargin'=>80); $fontStyle2 = array('align'=>'center'); // Add table style $PHPWord->addTableStyle('myOwnTableStyle2', $styleTable2); for($i=1;$i<=5;$i++){ $table2 = $section->addTable('myOwnTableStyle2'); $table2->addRow(); $table2->addCell(10000)->addText("服务岗位".$i,$fontStyle); $table3 = $section->addTable('myOwnTableStyle'); $table3->addRow(); $table3->addCell(2000)->addText("岗位内容",$fontStyle2); $table3->addCell(3000)->addText("",$fontStyle2); $table3->addCell(2000)->addText("需求数量",$fontStyle2); $table3->addCell(3000)->addText("",$fontStyle2); $table3->addRow(); $table3->addCell(2000)->addText("服务时数",$fontStyle2); $table3->addCell(3000)->addText("",$fontStyle2); $table3->addCell(2000)->addText("服务周期",$fontStyle2); $table3->addCell(3000)->addText("",$fontStyle2); } $styleTable3 = array('borderColor'=>'006699', 'borderLeftSize'=>6, 'borderBottomSize'=>6,'borderRightSize'=>6,'cellMargin'=>80); $fontStyle3 = array('align'=>'center'); $cellStyle3 = array('borderColor'=>'006699', 'borderRightSize'=>6); // Add table style $PHPWord->addTableStyle('myOwnTableStyle3', $styleTable3); $table4 = $section->addTable('myOwnTableStyle3'); $table4->addRow(2000); $table4->addCell(3333,$cellStyle3)->addText("本单位意见",$fontStyle3); $table4->addCell(3333,$cellStyle3)->addText("主管部门意见",$fontStyle3); $table4->addCell(3334)->addText("集团总部意见",$fontStyle3 ); //Two enter $section->addTextBreak(2); //Add image $section->addImage('logo.jpg', array('width'=>100, 'height'=>100,'align'=>'right')); $objWrite = PHPWord_IOFactory::createWriter($PHPWord, 'Word2007'); $objWrite->save('index.docx');
相关文章推荐
- php生成word文档的实例代码
- [C#]用C#动态生成Word文档并将数据填入Word表格中
- 实例:asp生成WORD文档
- 使用ASPOSE.WORD组件,在word文档指定的位置动态生成表格,支持单元格合并及背景填充
- php在程序中把网页生成word文档并提供下载
- 使用Interop.Excel生成Word表格文档
- 用C#动态生成Word文档并将数据填入Word表格中
- 推荐.NET使用Aspose.Words动态生成word文档数据表格(附Aspose.Words for NET 6.5 破解版下载)
- 【原】php生成2003 word文档并以页面视图打开
- C#根据word模板生成word表格报表文档
- php在程序中将网页生成word文档并提供下载的代码
- php 生成word文档
- asp.net下用Aspose.Words for .NET动态生成word文档中的数据表格的方法
- OLE方式控制WORD生成一个文档,包括自动生成表格
- 【原】php自动生成带图片附件的word文档类
- 根据word模板生成word表格报表文档(C#)
- PHP生成word文档
- 用C#动态生成Word文档并将数据填入Word表格中
- 用Aspose.Words for .NET动态生成word文档中的数据表格
- 用Aspose.Words for .NET动态生成word文档中的数据表格