Saving File to Response Object

Saving File to Response Object

It is also possible to generate a file dynamically and send it directly to a client browser. In order to do so, use a special overloaded version of the Save method that accepts the following parameters:

The ContentDisposition enumeration determines whether the file being sent to the browser provides the option to open by itself directly in the browser or in an application associated with .xls/.xlsx or another extension.

The enumeration contains the following pre-defined save types:

Type Description
Attachment Sends the spreadsheet to the browser and opens in an application as an attachment associated with .xls/.xlsx or other extensions
Inline Sends the document to the browser and presents an option to save the spreadsheet to disk or open inside the browser

XLS Files

XLSX Files

PDF Files