Aspose Cells for .NET 7.2.0 Problem save workbook to browser

I do not see the ability to save the workbook to the browser. I am new to ASPOSE but it looks like in the demo that a method should exist in order to accomplish this task. The following link shows the workbook being saved to the response. I have added the line of code that I am referencing. Has this functionality been removed or am I missing something?




//Save the excel file
designer.Workbook.Save(HttpContext.Current.Response,“SmartMarker.xls”, ContentDisposition.Attachment,new XlsSaveOptions(SaveFormat.Excel97To2003));




Hi,

Thanks for your posting and considering Aspose.Cells for .NET.

Yes, you can save workbook object into response stream. Below is a simplest code that will create a workbook object and will save it in response stream either in xls or in xlsx format.

Since you are new to Aspose. I will strongly recomment you to try the Aspose.Cells for .NET demos to get familiar with Aspose.Cells quickly.

Please download and try the latest offline demos. These demos can work with Visual Studio 2005, 2008 or 2010. Please read the readme.txt file before running the demos.


C#


//Create a new Workbook.
Workbook workbook = new Workbook();

string outputFormat=“XLS”;

if (outputFormat == “XLS”)
{
////Save file and send to client browser using selected format
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));
}


This is not the case for version 7.2.0. There is no save method that takes the response as a parameter. However, I was able to get the functionality required. This is how I did it. Although this seems kind of clunky becuase earlier versions apparently had a save method that could be used to send a file to the browser.


string path = MapPath("~/Documents/SomePath.xlsx");


var stream = new MemoryStream();

//I am not using the designer functionality yet.
var designer = new WorkbookDesigner {Workbook = new Workbook(path)};

designer.Process();
//Save the excel file
designer.Workbook.Save(stream, SaveFormat.Xlsx);

var data = new byte[stream.Length];
stream.Read(data, 0, data.Length);
stream.Close();
Response.Clear();
Response.Buffer = true;

Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
Response.AddHeader("content-disposition", "attachment; filename=CostEstimateTemplate.xlsx");

Response.BinaryWrite(data);
Response.End();

Hi,

It seems you are using the wrong assembly, please use the .net2.0 folder assembly and not the client_profile directory assembly.

PS: If your framework is client profile, only then use the client_profile directory assembly.

Please use the DLL under the directory “net2.0” and not “net3.5_ClientProfile”.

And please check the readme.txt under the directory
“Bin”.

Please see this image for more help.



Anyway, I have checked, everything is working fine.

I have attached the .aspx file and code behind file and the screenshot illustrating to you that latest version is working fine.

Screenshot: