0

こんにちは、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;?>

助けてください私はがっかりしています。前もって感謝します。

4

1 に答える 1