Skip to content

DevExpress-Examples/asp-net-web-forms-spreadsheet-download-file-on-custom-ribbon-item-click

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Spreadsheet for ASP.NET Web Forms - How to download a document on a custom ribbon item click

This example illustrates how to download a file on a custom ribbon item click.

Overview

The item is added in code behind to the existing ribbon tabs. The tabs are generated by the ASPxSpreadsheet.CreateDefaultRibbonTabs method:

  Spreadsheet.CreateDefaultRibbonTabs(true);
  RibbonButtonItem item = new RibbonButtonItem("Download", "Download");
  Spreadsheet.RibbonTabs[1].Groups[0].Items.Insert(0, item);

Since it is not possible to download a document on a callback request, a ribbon item should send a postback. For this, use the __doPostBack function in the client-side ASPxClientSpreadsheet.CustomCommandExecuted event handler:

function onCustomCommandExecuted(s,e) {
  if (e.commandName == "Download") 
      __doPostBack("DownloadExcel");
  }

ASPxSpreadsheet in this example loads data from a database, so the default file dialogs are disabled.

Note that a cell doesn't get the value an end-user entered until the user clicks Enter or tabs out of this cell. As a result the issue with saving an entered value may occur if the value was not submitted. To force submission of the last entered value, call the ASPxClientSpreadsheet.ApplyCellEdit method.

Documentation

Does this example address your development requirements/objectives?

(you will be redirected to DevExpress.com to submit your response)

About

Download a file on a custom ribbon item click.

Topics

Resources

License

Stars

Watchers

Forks

Contributors 4