Open Excel directly without saving to local disk

Hi,

I create a new excel workbook by using Workbook wb = new Workbook(). and then add some values into the worksheet.

Is there a way to not saving this workbook in the end but instead open it directly in the MS Excel?

Thanks.

Laura

Hi,


1) For windows/desktop applications, we have .NET’s System.Diagnostics.Process.Start() method, but this method obviously takes filePath and not stream as an argument, so this would not be worthwhile. We also have Aspose.Cells.GridDesktop control that does open/display the Excel files from streams, it is Excel like control, see the sample code:
Aspose.Cells.Workbook workbook = new Aspose.Cells.Workbook(“e:\test2\TestBook.xlsx”);
MemoryStream ms = new MemoryStream();
workbook.Save(ms, Aspose.Cells.SaveFormat.Xlsx);
ms.Position = 0;
this.gridDesktop1.ImportExcelFile(ms, false); //Place the GridDesktop on the Win Form and the control will display the Excel spreadsheet.

If you do not like this control, you may try to Google and find some means to view the Excel files directly from streams and not from disks, you need to create your own module and this might demand extensive coding etc. Also, you may try to find some way to write your own pseudo-file system in .NET, somehow mounting this as a disk in Windows, and having it intercept the file open from stream but not sure thought it would be effective much.

2) For web applications, you may use Response object to stream the Excel file as an attachment/inline to the client end, so that the file is directly opened into the client’s Excel/Excel Viewer.
e.g

Workbook wb = new Workbook();
//Your code goes here.

byte[] wbBytes = wb.SaveToStream().ToArray();

currentHttpContext.Response.Clear();
currentHttpContext.Response.ContentType = “application/vnd.ms-excel”;
currentHttpContext.Response.AddHeader(“content-disposition”, “attachment; filename=” + “Test.xls”);
currentHttpContext.Response.OutputStream.Write(wbBytes, 0, wbBytes.Length);
currentHttpContext.Response.Flush();
currentHttpContext.Response.End();

Also, you may use Aspose.Cells’s API (using the relevant Workbook.Save() method to response the Excel file to the client to be opened in the streams), see the document on how to save workbooks for your complete reference (see the subtopic: “3. Saving file to Response Object” in the document):

Similarly, we do have Aspose.Cells.GridWeb control that can suit your needs, see the demos:


Hope, this helps.

Thank you.

This works good. Thanks. However, the open worksheet doesn't have filter function, does it? Is there a way to implement the filter control??

Thanks.

Hi,

Please elaborate yourself.

Which product of Aspose.Cells family, you are using?

  1. Aspose.Cells for .NET
  2. Aspose.Celsl for GridDesktop

Please provide us the screenshot and source xls/xlsx file explaining the filter control you are searching for.

If it is existing feature, we will help you with sample code or if it is a new feature, we will log it in our database.