Once I have a grid displayed on a web page, my users want a button that will export the grid as seen on the web page into an Excel file for them to save locally i.e. I don't want to save to a file or stream on the server side.
Yes you may do it. You can write lines of code in GridWeb_SaveCommand event handler. So when you click on the save button(icon) on the control you can save it locally on the client.
Example:
private void GridWeb1_SaveCommand(object sender, System.EventArgs e) { // Generates a temporary file name. string filename = System.IO.Path.GetTempPath() + Session.SessionID + ".xls"; // Saves to the file. this.GridWeb1.WebWorksheets.SaveToExcelFile(filename); // Sents the file to browser. Response.ContentType = "application/vnd.ms-excel"; //Adds header. Response.AddHeader( "content-disposition","attachment; filename=book1.xls"); // Writes file content to the response stream. Response.WriteFile(filename); // OK. Response.End(); }
Sets consent for sending user data to Google for online advertising purposes.
Sets consent for personalized advertising.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
More info
Enables storage, such as cookies, related to analytics.
Enables storage, such as cookies, related to advertising.
Sets consent for sending user data to Google for online advertising purposes.
Sets consent for personalized advertising.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
More info
Enables storage, such as cookies, related to analytics.
Enables storage, such as cookies, related to advertising.
Sets consent for sending user data to Google for online advertising purposes.