Save dialog box on SaveToExcel

How do you bring up the Save dialog box (to enter a different name and select filepath) when you call the SafeToExcel API? Your demo provides the prompt when the Save icon is clicked on the Worksheet.

Thanks

That’s the routine of IE when you stream a file to client browser.

Please, could you please post an example of a routine that prompts to user to save the file generated?

I only could save direct to a specified path, but never could get the same effect that is in your Demo.

Thanks you all in advance.

Rudolf Gütlich
Delsis Eng.

Please try:

FileStream fs1 = new FileStream("d:\\book1.xls", FileMode.Open, FileAccess.Read);
byte[] data1 = new byte[fs1.Length];
fs1.Read(data1, 0, data1.Length);


this.Response.ContentType = "application/xls";
Response.AddHeader( "content-disposition","attachment; filename=book1.xls");
Response.BinaryWrite(data1);

This code will display an existing or saved excel file on the browser. How about if I click the save icon on the grid for the very first time to save the worksheets? How do I transfer the name selected in the SaveDialog box to the SaveToExcel API? Does your demo use this API to save or do it use the standard IE dialog box save?

I figured it out. Here is the code in case anyone needs it.

this.Page.Response.ContentType = "application/xls";
this.Page.Response.AddHeader("content-disposition", "attachment; filename=\"Book1.xls\"");

MemoryStream memStream = new MemoryStream();

base.WebWorksheets.SaveToExcelFile(memStream);

memStream.Seek(0, SeekOrigin.Begin);

byte[] data = new byte[memStream.Length];
memStream.Read(data, 0, data.Length);

this.Page.Response.BinaryWrite(data);

memStream.Flush();

memStream.Close();