Free Support Forum - aspose.com

workbook.Save (HttpContext response...no more

Moving from Aspose v8 to 19.4. Upgrade to Core 3.

v8 code was:
using (MemoryStream fstream = memoryStream)
{
//Specify the LoadOptions and set the memory preferences
var opt = new LoadOptions { MemorySetting = MemorySetting.MemoryPreference };

            //Instantiating a Workbook object, Opening the Excel file through the file stream
            var workbook = new Workbook(fstream, opt);

            //Save file and send to client browser using selected format
            if (saveFormat == SaveFormat.Xlsx)
            {
                workbook.Save(HttpContext.Response, fileName, ContentDisposition.Attachment, new OoxmlSaveOptions(saveFormat));
            }
            else
            {
                workbook.Save(System.Web.HttpContext.Current.Response, fileName, ContentDisposition.Attachment, new XlsSaveOptions(SaveFormat.Excel97To2003));
            }
            HttpContext.Response.end();
        }

v19 ‘workbook.Save’ has no overload for response object.

Question is how is the Save to a response context handled in v19?

Thanks.

@freeflyrw,
We have investigated the issue and observed that support for saving file to response object is present for .NET environment as follows:

Saving file to response object

Sample Code

HttpResponse Response = null;

// Load your source workbook
Workbook workbook = new Workbook();

if (Response != null)
{
    // Save in Excel2003 XLS format
    workbook.Save(Response, dataDir + "output.xls", ContentDisposition.Inline, new XlsSaveOptions());
	Response.End();
}

For its support in .NET Core and .NET Standard environment, we have logged an investigation ticket for detailed analysis. Once, we will have some news for you, we will update you in this topic.

This issue has been logged as
CELLSNETCORE-54 – Support for saving file to response object in ASP.NET Core Web application

@freeflyrw,

We have investigated your issue in details. We found that “System.Web.HttpResponse” class only exists in .NET framework, Please note, .NETStandard20 does not contain class i.e., “System.Web.HttpResponse”. So we removed the relevant Workbook.Save() overloaded(s) in Aspose Cells for .NET Standard2.0 version.

We suggest you to kindly try using:
public void Save(Stream stream, SaveOptions saveOptions) for saving workbook to a stream, then you may add an HttpHead ahead of the stream by yourself.

Hope, this helps a bit.