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');
?>

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