In Aspose 4.8, I was able to use Workbook.Save and write to a generic stream object, so I could use the same code to write to a file or the HttpResponse.OutputStream.
Hi,
Thanks for using Aspose.Cells.
Please download and use the latest version:
Aspose.Cells for .NET 7.3.2
Please use this code to save your file in XLS or in XLSX format in Response stream. It should solve your problem.
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();
VB.NET
'Save file and send to client browser using selected format
If yourFileFormat = “XLS” Then
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))
End If
HttpContext.Current.Response.End()
Hi,
In the latest versions, you may try some Workbook.Save overloads for saving file to streams or response object, SaveFormat can be set to Auto, e.g
public void Save(Stream,SaveFormat);
public void Save(Stream,SaveOptions);
public void Save(HttpResponse,string,ContentDisposition,SaveOptions);
For complete reference, see the document:
Thank you.
Hi Amjad,

Hi,
Thanks Amjad, version 7.3.2 works (7.3.0 did not).
Hi,
Thanks Again Amjad. If I initialise a workbook with just newWorkbook(), ie it is in Excel 2003 format, can I save it with SaveFormat.Xlsx? Presumably the affect of FileFormatType in the constructor is just to limit the features that can be used within the workbook?
Hi,
Thanks Amjad, all crystal clear now.
Hi,
It’s good to know that you now understand the difference between two enumerations.
Let us know if you face any other issue, we will be glad to help you.
Hi,
Hi,
Thanks for your posting and considering Aspose.Cells.
The web browser cannot display excel files, so whether you specify inline or attachment, it will not display the excel file inside it. However, some browser can display pdf inline. So if you specify inline for pdf format, then some browser like FireFox will display the pdf inline and if you specify attachment, then it will display as attachment.
We have verified this scenario using the following sample code. You can also download the attached sample project and test it at your end.
C#
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Aspose.Cells;
public partial class _Default : System.Web.UI.Page
{
string openMode = “Inline”;
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
Workbook workbook = new Workbook();
Worksheet worksheet = workbook.Worksheets[0];
worksheet.Cells[“B5”].PutValue(“This is a sample text.”);
//Save file and send to client browser using selected format
if (openMode == “Inline”)
{
workbook.Save(HttpContext.Current.Response, “output.pdf”, ContentDisposition.Inline, new PdfSaveOptions());
}
else
{
workbook.Save(HttpContext.Current.Response, “output.pdf”, ContentDisposition.Attachment, new PdfSaveOptions());
}
HttpContext.Current.Response.End();
}
}