【发布时间】:2015-10-16 11:22:41
【问题描述】:
我正在尝试使用 PHPWord 创建 word 文件。我已经设置了一些字体样式和段落样式。即使没有给出文本分隔符,我也会在 line1 和 line2 之间得到 6 行 空格。有什么建议吗?
这是我的代码
$this->word->addFontStyle('titleStyle', array('bold' => true, 'size' => 16, 'name'=>'Calibri'));
$this->word->addFontStyle('lineStyle', array('align'=>'left','size' => 10, 'name'=>'Calibri'));
$this->word->addParagraphStyle('pStyle', array('align' => 'center', 'spaceBefore' => 0, 'spaceAfter' => 0, 'spacing' => 0));
$section = $this->word->createSection(array('breakType'=>'continuous'));
// Simple text
$section->addText('Text Document','titleStyle','pStyle');
$section->addText('Line1 : ','lineStyle');
$section->addText('Line2 : ','lineStyle');
$section->addText('Line3 : ','lineStyle');
$section->addText('Line4 : ','lineStyle');
$filename='NewDoc.docx'; //save our document as this file name
header('Content-Type: application/vnd.openxmlformats-officedocument.wordprocessingml.document'); //mime type
header('Content-Disposition: attachment;filename="'.$filename.'"'); //tell browser what's the file name
header('Cache-Control: max-age=0'); //no cache
$objWriter = PHPWord_IOFactory::createWriter($this->word, 'Word2007');
$objWriter->save('php://output');
任何帮助将不胜感激。
【问题讨论】:
标签: codeigniter phpword