0
嗨我正在使用cakephp将页面内容导出到MS word文档。 这件事对我来说是全新的,我以前没有用过任何语言。 到目前为止,谷歌搜索后,我无法找到很多关于此。 但是,我发现这样的艺术。将内容导出到cakephp中的MS Word文档中
“词”的布局:
<?php
header("Content-Type: application/vnd.ms-word");
header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // Date in the past - so must always re-read
header("content-disposition: attachment;filename=myfile.doc"); //this will be the name of the file the user downloads
echo $content_for_layout; ?>
控制器功能:
function printToWord($pageId) {
$page = $this->Customer->findById($pageId);
$this->set('page',$page);
$file = new File(APP.DS.'webroot'.DS.'css'.DS.'print.css', false); //1
$this->set('inlineCss',$file->read()); //2
$file->close();
$this->layout = "word";
Configure::write('debug',0);
}
,并考虑:
<style>
<?php if (isset($inlineCss) echo $inlineCss;?>
帮助我,我很失望。 在此先感谢。
第二个选项..我想动态创建word文档吗? 你能帮助我吗? @Pbal –
这个库支持MS词吗? –
@MuhammadUsman:是的!有了这个库,你可以动态地生成Word文档。查看“入门”部分。这是非常直接的使用。 – Pbal