There is php 4.4.8 on server. How can write on a word document. I can write it , but it download . Writing didn't show. if it impossible , how can create a new word document.
Asked
Active
Viewed 285 times
-1
-
Your question is very unclear. Can you write the document, yes or no? If yes, then please tell us what your problem is. – Jonathon Reinhart Dec 16 '13 at 07:08
-
No . I want to create a new document with php – eildiz Dec 16 '13 at 07:38
1 Answers
0
Try this
$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);
Change this according to your needs.

halfer
- 19,824
- 17
- 99
- 186

Vignesh Kumar A
- 27,863
- 13
- 63
- 115
-
-
Please refer http://stackoverflow.com/questions/277224/how-do-i-catch-a-php-fatal-error – Vignesh Kumar A Dec 16 '13 at 08:34
-
Thanks your answer. I did some research on internet about COM. COM need to work window or .net machine. my machice linux. – eildiz Dec 16 '13 at 11:15
-
-
-