0

We need to download a MS-Word Document from a Visualforce page which needs to contain the information from the Browser Local Storage as well. How can we fetch and download the value from Browser local storage to a MS-Word file?

Currently we using contentType="application/msWord#test.doc" for downloading the VF page as msWord file but not able add the values fetched from Browser Local Storage the VF page so that the downloaded file can also be updated from the data fetched from browser local storage.

Also, if we can achieve through lightning component and VF page, do share your thoughts as we need to provide around 50000 character length from local storage download in msWord file using a VF page.

Also, just to share we will use this feature for a managed package(if this would make any difference in the solution or workaround).

1 Answer 1

0

You can't, as described.

Currently we using contentType="application/msWord#test.doc" for downloading the VF page as msWord file

That's not a Word document; it is an HTML file. You are lying to Word and the user's browser, and Word's compatibility layer is willing to accept this in some circumstances and attempt to render the HTML file. You should be aware that you will have little control over Word's behavior and rendering.

but not able add the values fetched from Browser Local Storage the VF page so that the downloaded file can also be updated from the data fetched from browser local storage.

If the file is being downloaded, you cannot execute any JavaScript in it in the browser context where it could in theory access local storage, so this won't work at all.


You may be able to build a Visualforce page that renders, loads data from local storage, constructs an in-memory HTML document, and then initiates a download of that document as a blob via JavaScript. The current approach, however, won't work at all.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .