SSRS create PDF or Excel from <form> POST

Viewed 32

According to this Microsoft dev guidance, it should be possible to have a element on a web page do a POST via the method=POST attribute of the form. It shows an example of HTML needed in order to open a report viewer to a report and render the HTML viewer. I have that working. I would like to use the exact same technique to create a PDF or Excel file, but it doesn't work when I update the Format parameter to either PDF or EXCELOPENXML. Instead it ignores that parameter and provides the HTML viewer anyway. I would like to stick to one technique for both opening the HTML viewer and for downloading the various file formats. Does anyone know a workaround? I have considered a generic function to take the hidden elements and tack them on to the action URL, and open a new window with that. Does anyone have the code to do that?

1 Answers

I would still be curious to know if there's an issue with the POST action for file exports, but in the meantime, I solved it with this:

 $("form").find(":input[name]").map(function(val, key) {
    return encodeURIComponent($(this).attr('name')) 
      + '=' 
      + encodeURIComponent($(this).val()).replace(/%2C/g,',').replace(/%20/g,' ');
    //unencode space and comma characters for convinience and shorter URLs
 }).get().join("&")
Related