You need to sign in to do that
Don't have an account?
Render a VF page as ms-word
How can I get a VF page to render in such a way that I can open it in Word?
I know that renderAs supports only PDF, but per this blog article (http://blog.sforce.com/sforce/2008/12/visualforce-to-excel.html), I've been playing with contentType. I've tried a few contentTypes:
application/vnd.ms-word
application/rtf
vnd.ms-word.document.macroEnabled.12
The first two (especially when used with an #filename.doc suffix) create content that can be opened in Word, but the Word document contains HTML tags.
The second one came from http://www.iana.org/assignments/media-types/application/index.html which has a list of valid media types. Word wouldn't open anything created with that content type.
How can I get a VF page to generate content that can be opened in MS Word?
Makes very little sense to me, but if I wrap the body of the VF page inside an HTML table tag, I can successfully open the result in Word, without the HTML tags appearing in the content.
Here's an example:
Save the above in a VF page named Sample. Load the page with querystring parameters like this:
?id=YOUR_CONTACT_ID&type=word
It'll open a Word document, but you'll see the HTML tags in the content. Then remove the comments (that is, add the table tags), and you'll see that it renders correctly -- almost. The padding and margin aren't respected in the Word document.
So now I've got 2 more questions:
1. Why do I have to put my content inside <table> tags?
2. How can I generate a Word document that respects my formatting, like padding and margin attributes?
Hi MJ Kahn
Were you able to remove the html tags from the word document , can you share how did you it.
Thanks in advance
Raj.