-1

サーバーにはphp 4.4.8があります。ワード文書に書き込める方法を教えてください。私はそれを書くことができますが、それはダウンロードします。書き込みは表示されませんでした。不可能な場合、新しいワード文書を作成する方法を教えてください。

4

1 に答える 1

0

これを試して

$word = new COM("word.application");

// Hide MS Word application window
$word->Visible = 0;


$template_file = 'C:/xampp/htdocs/portal/includes/templates/form1.docx'; 
//file name is different based on initiating form.

//Create new document
$word->Documents->Open($template_file);
//WO Number
$woNumBookMark = 'WONum';
$objBookmark = $word->ActiveDocument->Bookmarks($woNumBookMark);
$range = $objBookmark->Range;
$range->Text = htmlentities($workOrderNum) . '/' . htmlentities($lotID);
$filename = tempnam(sys_get_temp_dir(), "word");
$word->Documents[1]->SaveAs($filename);

// Close and quit
$word->Quit();
unset($word);
header("Content-Length: ".filesize($filename));
//header("Content-Type: application/force-download");
header("Content-type: application/vnd.openxmlformats-officedocument.wordprocessingml.document");
header("Content-Disposition: attachment;Filename=document_name.docx");
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');

// Send file to browser

readfile($filename);
unlink($filename);

必要に応じてこれを変更してください。

于 2013-12-16T07:09:41.023 に答える