Loading

Turn a Visualforce page into a Word document

Publiceringsdatum: Oct 13, 2022
Beskrivning
Visualforce pages can generate HTML and CSS content that may be returned to the browser as a file with .doc extension. This file may in turn be parsed by Microsoft Word, and a document may be presented to the end user assuming that the used markup meets Microsoft Word's requirements. This is due to Microsoft Word's ability to read old .doc files (that should be binary files as per its format specification) as .docx files (that use Office Open XML).

Salesforce does not support generating native .doc files (binary files as per the .doc binary file format) or .docx files (zipped XML documents that meet the Office Open XML specification), but the approach provided below may be used as a workaround.
Lösning
To turn a Visualforce page into a .doc file (not an correct .doc file as per the binary format specification, but a file that may be parsed by Microsoft Word as an Office Open XML document) your Visualforce page should make use of the contentType attribute as well as applyHtmlTag and applyBodyTag:
 
<apex:page controller="MyController" contentType="application/msword#filename.doc" sidebar="false" standardStylesheets="false"
applyHtmlTag="false" applyBodyTag="false">

<html>
<body>
...
</body>
</html>

NOTE: Providing the HTML and CSS markup required by Microsoft Word to achieve a certain result that should be displayed in the document shown by Word is out of scope for Salesforce Support.
Knowledge-artikelnummer

000382324

 
Laddar
Salesforce Help | Article