Jump to content


Photo

Writing to MS Word with PHP on Linux


  • Please log in to reply
2 replies to this topic

#1 Gast

Gast
  • Members
  • PipPipPip
  • Advanced Member
  • 131 posts
  • LocationSouth East England

Posted 17 July 2006 - 08:42 PM

Does anyone know if it is possible? I understand you need the COM extension on a Microsoft Server, but is there a way to get it to work on a Linux system?

Also, can't you just use fwrite()? I have made an Excel document using only PHP's functions so maybe it is possible with Word?
OS and Internet Specs:
Windows XP (with SP2), 1680x1050, PHP 4, MySQL 3, Internet Explorer 6 &7 /FireFox 2.0/Opera 9.2

Tutorials:
Simple Introduction to AJAX and XMLHttpRequest
Creating Live Data with AJAX Making a Google Suggest like application

#2 hitman6003

hitman6003
  • Members
  • PipPipPip
  • Advanced Member
  • 1,807 posts

Posted 18 July 2006 - 12:58 AM

You probably did not create a true excel file...probably a csv that excel opened and was able to manipulate.  I don't think it's possible to create a true MS word file without using COM.  You can write .txt and I think .rtf files in straight text which word will manipulate.  The rtf (rich text format, which is what wordpad produces) MS Word will work with, and you can apply formatting to the text...bold, italic, and such.

#3 Gast

Gast
  • Members
  • PipPipPip
  • Advanced Member
  • 131 posts
  • LocationSouth East England

Posted 19 July 2006 - 07:26 PM

You probably did not create a true excel file...probably a csv that excel opened and was able to manipulate.  I don't think it's possible to create a true MS word file without using COM.  You can write .txt and I think .rtf files in straight text which word will manipulate.  The rtf (rich text format, which is what wordpad produces) MS Word will work with, and you can apply formatting to the text...bold, italic, and such.


I might have to go with the RTF option as a customer wants basically to be able to get a script to generate letters that he can "mail merge" in Word.

Also, about the Excel file, it wasn't a CSV file, it was an XLS file. Basically if you write to one using fwrite() etc, you can use the tab character "\t" to move to each cell. I will post the script when I find it in a minute out of interest.
OS and Internet Specs:
Windows XP (with SP2), 1680x1050, PHP 4, MySQL 3, Internet Explorer 6 &7 /FireFox 2.0/Opera 9.2

Tutorials:
Simple Introduction to AJAX and XMLHttpRequest
Creating Live Data with AJAX Making a Google Suggest like application




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users