Save XLS/XLSX file to ResponseStream in Web application using Aspose.Cells for .NET in C#

I just downloaded version 5.3.2 to replace my old 4.5.0 version and now my Save function doesn’t work. The documentation says to replace my current save function with Workbook.Save(System.Web.HttpResponse, string, ContentDisposition, SaveOptions). But I can’t find this overloaded function.

Hi,

Please use this code to save your file in XLS or in XLSX format in Response stream.

C#


//Save file and send to client browser using selected format
if (yourFileFormat == “XLS”)
{
workbook.Save(HttpContext.Current.Response, “output.xls”, ContentDisposition.Attachment, new XlsSaveOptions(SaveFormat.Excel97To2003));

}
else
{
workbook.Save(HttpContext.Current.Response, “output.xlsx”, ContentDisposition.Attachment, new OoxmlSaveOptions(SaveFormat.Xlsx));
}

HttpContext.Current.Response.End();

It doesn’t recognize ContentDisposition.

Hi,

Please add a reference to Aspose.Cells 5.3.2 dll and make sure use the DLL under the directory “net2.0” and not “net3.5_ClientProfile”. See the screenshot.

Then add

using Aspose.Cells;

or you can use ContentDisposition using full naming i.e

Aspose.Cells.ContentDisposition.Attachment

Screenshot:


I was referencing the dll in the 3.5 folder. Switched to the correct one and it works now. Thanks for the assistance.