【发布时间】:2018-05-26 18:28:39
【问题描述】:
我正在使用 codeigniter 和 phpword 我试图获得如下图所示的间距。
当我导出文档时,我的感觉如何
问题:在 PHPWord 中如何设置正确的间距,我想让我的输出与第一张图像相同。
public function export() {
$phpWord = new \PhpOffice\PhpWord\PhpWord();
$section = $phpWord->addSection();
$results = $this->get_events_for_export();
foreach ($results as $result) {
$date = strtotime($result['event_date']);
$line = date('M', $date) .' '. date('d', $date) .' '. date('D', $date) .' '. htmlentities($result['event_title']);
$section->addText($line . "\n");
}
// Saving the document as OOXML file...
$filename = 'date1.docx';
header("Content-Description: File Transfer");
header('Content-Disposition: attachment; filename="' . $filename . '"');
header('Content-Type: application/vnd.openxmlformats-officedocument.wordprocessingml.document');
header('Content-Transfer-Encoding: binary');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Expires: 0');
$objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, 'Word2007');
$objWriter->save("php://output");
exit();
}
【问题讨论】:
-
您可能需要添加一些 html 标签,请参见此处:stackoverflow.com/questions/23005670/…
-
并检查一下:github.com/PHPOffice/PHPWord/tree/master/samples,希望对您有所帮助...
-
@Vickel 在大量阅读发布答案后,我现在已经开始工作了
标签: php codeigniter phpword