ExcelFileSaveToHttpResponse Method

Note: This API is now obsolete.

Saves the ExcelFile to a System.Web.HttpResponse output stream and sets appropriate HTTP response headers. Use this method in ASP.NET application to send the document to a client browser. File format is resolved from options parameter or fileName parameter file extension as described in remarks. See remarks why httpResponse parameter is of type Object.

Namespace: GemBox.Spreadsheet
Assembly: GemBox.Spreadsheet (in GemBox.Spreadsheet.dll) Version:
[ObsoleteAttribute("Use 'GemBox.Spreadsheet.ExcelFile.Save(System.Object, System.String)' method with the specified file extension or 'GemBox.Spreadsheet.ExcelFile.Save(System.Object, System.String, GemBox.Spreadsheet.SaveOptions)' method instead. For more info, see http://www.gemboxsoftware.com/spreadsheet/help/html/Obsolete_Members.htm#ExcelFileSaveToHttpResponse.")]
public void SaveToHttpResponse(
	Object httpResponse,
	string fileName,
	params Object[] options


Type: SystemObject
HttpResponse object that can be retrieved through the Response property of the System.Web.HttpApplication, System.Web.HttpContext, System.Web.UI.Page or System.Web.UI.UserControl classes.
Type: SystemString
File name that will be presented in client browser when downloading a file.
Type: SystemObject
The saving options which can be used to define settings for save operation.

This method accepts Object rather than HttpResponse because otherwise GemBox.Spreadsheet assembly would have a dependency on System.Web assembly and could not be used in applications which target Client Profile .NET Framework.

HttpResponse can be retrieved through the Response property of the HttpApplication, HttpContext, Page or UserControl classes.

File format in which ExcelFile will be saved depends on the type of the first item in options array as follows:

  • if options array first item is of type XlsxSaveOptions, ExcelFile will be saved in Microsoft Excel 2007 format,
  • otherwise if options array first item is of type CsvType or Char, ExcelFile will be saved in Character separated value format,
  • otherwise if options array first item is of type HtmlSaveOptions, ExcelFile will be saved in HyperText Markup Language format,
  • otherwise, file format in which ExcelFile is saved is resolved based on fileName parameter file extension.

Following file extensions are supported:

  • Microsoft Excel 2007 formats: .xlsx, .xlsm, .xltm, .xltx
  • Microsoft Excel 97-2003 formats: .xls, .xlt
  • Character separated value formats: .csv, .tsv
  • OpenDocument Spreadsheet formats: .ods, .ots
  • HyperText Markup Language formats: .htm, .html
See Also