Jump to content

  • Log In with Google      Sign In   
  • Create Account

Is there any way to generate a word doc from a html file


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
4 replies to this topic

#1 Brainx7   Members   -  Reputation: 113

Like
0Likes
Like

Posted 06 June 2014 - 01:36 PM

Attached is my file. I would like that when the user clicks submit a word file is generated with the information. How could I do this?



Sponsor:

#2 SimonForsman   Crossbones+   -  Reputation: 6111

Like
3Likes
Like

Posted 06 June 2014 - 01:50 PM

with html you can't.

 

You can however do it using PHP, Python, C# or some other programming language on the server backend (There are plenty of libraries around that lets you generate word and excel documents (primary in the newer .docx and .xlsx formats)

 

C#: http://www.codeproject.com/Articles/660478/Csharp-Create-and-Manipulate-Word-Documents-Progra

PHP: http://phpword.codeplex.com/

PHP (alternative library): http://www.phpdocx.com/documentation/tutorial

Python: https://pypi.python.org/pypi/docx/0.2.4


Edited by SimonForsman, 07 June 2014 - 10:52 AM.

I don't suffer from insanity, I'm enjoying every minute of it.
The voices in my head may not be real, but they have some good ideas!

#3 Aardvajk   Crossbones+   -  Reputation: 5982

Like
2Likes
Like

Posted 07 June 2014 - 01:10 AM

What we do at work is save our (HTML) reports into an MHTML file, which we give a .doc extension. Word will then open it via the shell, but recognise the format.

 

Its okay. Plenty of formatting issues of course.



#4 DiegoSLTS   Members   -  Reputation: 1379

Like
3Likes
Like

Posted 07 June 2014 - 09:36 AM

You can create the file server side as SimonForsman said, but with the new File API in HTML5 and Javascript you can create files in client's side too ( http://www.html5rocks.com/en/tutorials/file/filesystem/ ). There are security limitations for this, you can't just write the file anywhere in the disk (it works in a sandboxed file system) so you'll need to send that file to the server and provide a "download" popup if you want the user to get it.

 

Also, "a word file" could have a lot of formats (a single txt file can be opened in Word), but if you're trying to create a .doc file it might be a hard task. The .doc file format is not fully documented, so maybe you can create a .odt file (it's a standard well defined file format for documents) that Word recognizes and opens without problems. You'll probably found more info about doing this than doing HTML -> .doc.



#5 slicer4ever   Crossbones+   -  Reputation: 3888

Like
0Likes
Like

Posted 09 June 2014 - 07:45 AM

this looks like it's technically possible: http://stackoverflow.com/questions/4184944/javascript-download-data-to-file-from-content-within-the-page (see all reply's after first) using javascript, but is apparently not very reliable for older browsers.


Check out https://www.facebook.com/LiquidGames for some great games made by me on the Playstation Mobile market.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS