php报表模板_PHPWord插件创建表格及模板替换技术记录说明(含PHPWord⽂件及中。。。
1.模板替换功能require_once 'PHPWord.php';
require_once 'PHPWord/IOFactory.php';
$PHPWord = new PHPWord();
$template = $PHPWord->loadTemplate('PHPWord/mb/test.docx');
$template->setValue('Name','你好,测试-123abc');//${Name}
$template->setValue('Street', 'Coming-Undone-Street 32');
$filename = 'PHPWord/mb/test_update.docx';
$template->save($filename);
2.直接创建表格$section = $PHPWord->createSection();
表格网站php源码$styleTable = array('borderSize'=>6, 'borderColor'=>'000000', 'cellMargin'=>80);//表格样式
$fontStyle = array('bold'=>true, 'align'=>'center');//⽂字样式
$PHPWord->addTableStyle('table_1', $styleTable);//定义表格样式
$table = $section->addTable('table_1');
$table->addRow(400);
$table->addCell(2000)->addText('Cell 1',$fontStyle);
$table->addCell(2000)->addText('Cell 2',$fontStyle);
$table->addCell(2000)->addText('Cell 3',$fontStyle);
$table->addRow(1000);
$table->addCell(2000)->addText('Cell 4',$fontStyle);
$table->addCell(2000)->addText('Cell 5',$fontStyle);
$table->addCell(2000)->addText('Cell 6',$fontStyle);
$objWrite = PHPWord_IOFactory::createWriter($PHPWord, 'Word2007');
$filename = 'PHPWord/mb/test_create.docx';
$objWrite->save($filename);
3.PHPWord插件⽂件及中⽂技术⽂档下载

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。