Skip to content

Commit

Permalink
Added new kb article spreadsheet-hiding-excel-option-exportas (#531)
Browse files Browse the repository at this point in the history
Co-authored-by: KB Bot <kb-bot@telerik.com>
  • Loading branch information
github-actions[bot] and KB Bot committed Apr 26, 2024
1 parent 4c65d4c commit 1c81fca
Showing 1 changed file with 51 additions and 0 deletions.
51 changes: 51 additions & 0 deletions knowledge-base/spreadsheet-hiding-excel-option-exportas.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
---
title: Hiding Excel Option in ExportAs
description: Learn how to hide the Excel option in the ExportAs tool in RadSpreadsheet for ASP.NET AJAX.
type: how-to
page_title: Hide Excel Option in ExportAs | RadSpreadsheet for ASP.NET AJAX
slug: spreadsheet-hiding-excel-option-exportas
tags: radspreadsheet, asp.net ajax, exportas, excel, pdf
res_type: kb
---

## Environment
| Product | RadSpreadsheet for ASP.NET AJAX |
|--------------|---------------------------------|
| Version | all |

## Description
The customer wants to hide the Excel option in the ExportAs tool in RadSpreadsheet. They only want the user to be able to export to a PDF, as the Excel data can be changed.

## Solution
To achieve this, you need to implement a custom solution. Use the following code:

```javascript
function OnClientExcelExport(sender, args) {
args.set_cancel(true);
alert("Export to Excel has been disabled.");
}

var original_triggerDialog = kendo.spreadsheet.TabStrip.prototype._triggerDialog;
kendo.spreadsheet.TabStrip.prototype._triggerDialog = function (args) {
original_triggerDialog.call(this, args);
if (args.name == "exportAs") {
var exportDialog = this.element.closest(".RadSpreadsheet").getKendoSpreadsheet()._view._dialogs[0];
exportDialog.viewModel.set("extension", ".pdf")

var $dialog = exportDialog.dialog().element;
$dialog.find('div:not(.k-export-config)>.k-edit-field >.k-file-format').closest('div:not(.k-edit-field)').hide();
}
}
```

Add the following code to your RadSpreadsheet markup:

```html
<telerik:RadSpreadsheet runat="server" OnClientExcelExport="OnClientExcelExport" ID="RadSpreadsheet1"></telerik:RadSpreadsheet>
```

This code will disable the Excel export option and only allow exporting to PDF. When the user tries to export to Excel, they will see an alert message indicating that Excel export has been disabled.

Please note that the provided solution is a custom implementation and may require further adjustments based on your specific requirements.


0 comments on commit 1c81fca

Please sign in to comment.