Thursday, 9 August 2012

Dynamic Visualforce Naming

I've been doing some work creating content in Visualforce that is rendered/opened in different formats (PDF, csv, excel etc). The few ways I have found to force rendering or download of the Visualforce page onload is to renderAs="PDF" or setting contenttype="text/csv" etc. The issue is during the load of the page, the page itself is saved using the naming convention of the Visualforce page, meaning you cannot specify the necessary extension. 

I was wondering if anyone had a workaround or any ideas to force the save of the page to a dynamic name and specify a file extension (for instance force a Visualforce page named Report with contenttype="application/csv" save as {dynamicname}.csv). 

My temporary work-around is having the file emailed as an attachment, as you can specify name of attachment and file extension dynamically in Visualforce templates. I would prefer the option to directly download rather then use this work-around. Anyone have any ideas?


No comments:

Post a Comment