Activity Forums Salesforce® Discussions Generate MS-Word document (.docx) using Salesforce Visualforce pages

  • Satyakam

    Member
    December 6, 2016 at 6:39 am

    Hi Arshadulla,

    In your Visualforce page,you have to add contentType to get any type of files.

    <apex:page standardController="Account"  showHeader="false" contentType="application/vnd.msword" >

    .................

    code here

    ...............

    </apex:page>

    Thanks

  • Avnish Yadav

    Member
    September 30, 2018 at 3:49 am

    Hello,

    Let`s see how we can display Salesforce data using Visual force pages.

    Generation of pdf file:

    Salesforce data can be displayed in Visualforce page using Controllers as per the client template format

    Visualforce can be easily converted to PDF documents automatically—simply add “renderAs” attribute of <apex:page> tag

    Example:
    <apex:page  renderAs=”pdf”>
    ……
    Code to display data in the desired format
    ……
    </apex:page>

    Generation of word file:

    To generate Ms-word file, we just use contentType=”application/vnd.msword” attribute of <apex:page> tag.

    Example:
    <apex:page  contentType=”application/vnd.msword”>
    ……
    Code to display data in the desired format
    ……

    </apex:page>

    Generation of excel file:

    Now if we need to generate Excel file, we just use contentType=”application/vnd.ms-excel” attribute of <apex:page> tag .

    Example:

    <apex:page  contentType=”application/vnd.ms-excel”>
    ……
    Code to display data in the desired format
    ……

    </apex:page> server headers site information expiration of domains .

    Thanks.

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos