How to Generate MS-Word document using VF pages?
I have a VF which renders as MS-Word. for this you need to mention content type in <apex:page> tag.
EX:-
<apex:page standardController="Account" contentType="application/msword#sfdcsrini.doc" cache="true">
<html xmlns:w="urn:schemas-microsoft-com:office:word">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<body>
<apex:outputText title="Welcome to word" value="{!$User.FirstName}"/>
<br/>
<br/>
<apex:pageBlock >
<div style="text-align:left" >
<b>Account Name :</b><apex:outputText value="{!account.name}"/><br/>
<b>Account Number: </b><apex:outputText value="{!account.AccountNumber}"/><br/>
</div>
</apex:pageBlock>
</body>
</html>
</apex:page>
once you save this code in to your vf page you need to pass the account id in to url like
https://c.ap1.visual.force.com/apex/worddocvf?id=0019000000RMAaF
here contentType="application/msword#sfdcsrini.doc" tells that page should render as ms-word document.(sfdcsrini) is the name of the document in content type, you can give your own name.
5 comments:
Hi Srini,
Any apporach for "docx" documents.
Thanks
Arshad
There is more information for us.I really impress to visit your website.It is so good.Thanks for sharing with us.
Run 4 Cat Ninja Ludo Star
https://sourcecalendar.com/april-2018-calendar
https://sourcecalendar.com/july-2018-calendar
https://sourcecalendar.com/june-2018-calendar
https://sourcecalendar.com/may-2018-calendar
thanks for sharing..
Server and Storage
how to generate vfpage in format of (.docx)?
can u tell me.
Thanks
Post a Comment