PHPWord案例整理

<?php
require_once 'PHPWord/PHPWord.php';

// New Word Document
$PHPWord = new PHPWord();
$fileName = 'create_word';
//设置默认字体
$PHPWord-> setDefaultFontName('黑体');


$section = $PHPWord->createSection();

//添加页眉
$header = $section->createHeader();
$table = $header->addTable();
$table->addRow();
$table->addCell(4500)->addImage('logo.png', array('width'=>557, 'height'=>93, 'align'=>'center'));

//报价函
$PHPWord->addFontStyle('rStyle', array('bold'=>true, '黑体'=>true, 'size'=>14));
$PHPWord->addParagraphStyle('pStyle', array('align'=>'center', 'spaceAfter'=>100));
$section->addText('报价函', 'rStyle', 'pStyle');

//XX公司
$section->addText('致:青岛尚讯信息技术公司', array('bold'=>true, '黑体'=>true, 'size'=>11), array('spacing'=>120));

// 简介
$PHPWord->addFontStyle('r_descStyle', array('黑体'=>true, 'size'=>11));
$PHPWord->addParagraphStyle('p_descStyle', array('spacing'=>120));
$section->addText('    我司十分荣幸地就贵司“XXX项目”与贵司达成合作意向。在与贵司相关负责人仔细分析制作要求及探讨制作内容的基础上,经我司召开技术部会议部署制作计划,现向贵司发出报价函,同时我司承诺:', r_descStyle, p_descStyle);
$listStyle = array('listType'=>PHPWord_Style_ListItem::TYPE_NUMBER);
$section->addListItem('该报价一旦为贵司认可,即为合同价;该报价有效期为6个工作日。', 0, r_descStyle, $listStyle, p_descStyle);
$section->addListItem('本公司报价函一经发出,即不可撤回。本公司一旦荣幸地成为本项目的签约方,同意将按项目洽谈会上所达成的相关要求进一步深入推进制作进程。', 0, r_descStyle, $listStyle, p_descStyle);
$section->addListItem('若贵司对报价函持有异议,请务必通过书面或其他渠道与我司相关负责人进行磋商,以免影响项目进度。', 0, r_descStyle, $listStyle, p_descStyle);

//制作内容
$section->addText('制作内容:  公园壹号项目', array('bold'=>true, '黑体'=>true, 'size'=>11));
//$section->addText('XX项目', array('underline'=>true));
$section->addTextBreak();


//费用明细
$section->addText('费用明细:', array('bold'=>true, '黑体'=>true, 'size'=>11));
$section->addTextBreak();
/**************table start*******************/
$styleTable = array('borderSize'=>6, 'borderColor'=>'000000', 'cellMargin'=>80);
$styleCell = array('valign'=>'center', 'align'=>'center');
$fontStyle = array('size'=>11 /*,'bold'=>true*/);
$PHPWord->addTableStyle('myOwnTableStyle', $styleTable, $fontStyle);

$table = $section->addTable('myOwnTableStyle');
$table->addRow(900);
$table->addCell(3000, $styleCell)->addText('制作项目', $fontStyle, $styleCell);
$table->addCell(10000, $styleCell)->addText('内容说明', $fontStyle, $styleCell);
$table->addCell(2000, $styleCell)->addText('价格(万)', $fontStyle, $styleCell);
for($i = 1; $i <= 3; $i++) {
	$table->addRow();
	$table->addCell(2000)->addText("", $fontStyle, $styleCell);
	$table->addCell(2000)->addText("", $fontStyle, $styleCell);
	$table->addCell(2000)->addText("", $fontStyle, $styleCell);
}
/**************table start*******************/
$section->addTextBreak();





//制作工期
$section->addText('制作工期:  5个月', array('bold'=>true, '黑体'=>true, 'size'=>11));
//$section->addText('XX项目', array('underline'=>true));


//黑晶信息技术有效公司
$section->addText('黑晶信息技术有效公司', array('黑体'=>true, 'size'=>11), array('align'=>'right', 'spaceBefore'=>200));
$section->addText('殷娜  18663930415', array('黑体'=>true, 'size'=>11), array('align'=>'right', 'spaceBefore'=>200));
$section->addText('2013-11-04', array('黑体'=>true, 'size'=>11), array('align'=>'right', 'spaceBefore'=>200));


/**设置在浏览器下载**/
header('Pragma: public');
header('Expires: 0');
header('Cache-Control:must-revalidate, post-check=0, pre-check=0');
header('Content-Type:application/force-download');
header('Content-Type:application/vnd.ms-word');
header('Content-Type:application/octet-stream');
header('Content-Type:application/download');
header('Content-Disposition:attachment;filename='.$fileName.'.docx');
header('Content-Transfer-Encoding:binary');
$objWriter = PHPWord_IOFactory::createWriter($PHPWord, 'Word2007');
$objWriter->save('php://output');
?>

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章