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 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 it 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 it inside the browser

XLS Files

XLSX Files

PDF Files

Note

Because the System.Web.HttpResponse object is not included in .NET 5 and .NET Standard, this function does not exist in Aspose.Cells .NET 5 and .NET Standard versions. You can refer to the following code to save the file to a stream and then operate on the stream.