Skip to content

Commit 1c81fca

Browse files
github-actions[bot]KB Bot
and
KB Bot
authored
Added new kb article spreadsheet-hiding-excel-option-exportas (#531)
Co-authored-by: KB Bot <[email protected]>
1 parent 4c65d4c commit 1c81fca

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
---
2+
title: Hiding Excel Option in ExportAs
3+
description: Learn how to hide the Excel option in the ExportAs tool in RadSpreadsheet for ASP.NET AJAX.
4+
type: how-to
5+
page_title: Hide Excel Option in ExportAs | RadSpreadsheet for ASP.NET AJAX
6+
slug: spreadsheet-hiding-excel-option-exportas
7+
tags: radspreadsheet, asp.net ajax, exportas, excel, pdf
8+
res_type: kb
9+
---
10+
11+
## Environment
12+
| Product | RadSpreadsheet for ASP.NET AJAX |
13+
|--------------|---------------------------------|
14+
| Version | all |
15+
16+
## Description
17+
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.
18+
19+
## Solution
20+
To achieve this, you need to implement a custom solution. Use the following code:
21+
22+
```javascript
23+
function OnClientExcelExport(sender, args) {
24+
args.set_cancel(true);
25+
alert("Export to Excel has been disabled.");
26+
}
27+
28+
var original_triggerDialog = kendo.spreadsheet.TabStrip.prototype._triggerDialog;
29+
kendo.spreadsheet.TabStrip.prototype._triggerDialog = function (args) {
30+
original_triggerDialog.call(this, args);
31+
if (args.name == "exportAs") {
32+
var exportDialog = this.element.closest(".RadSpreadsheet").getKendoSpreadsheet()._view._dialogs[0];
33+
exportDialog.viewModel.set("extension", ".pdf")
34+
35+
var $dialog = exportDialog.dialog().element;
36+
$dialog.find('div:not(.k-export-config)>.k-edit-field >.k-file-format').closest('div:not(.k-edit-field)').hide();
37+
}
38+
}
39+
```
40+
41+
Add the following code to your RadSpreadsheet markup:
42+
43+
```html
44+
<telerik:RadSpreadsheet runat="server" OnClientExcelExport="OnClientExcelExport" ID="RadSpreadsheet1"></telerik:RadSpreadsheet>
45+
```
46+
47+
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.
48+
49+
Please note that the provided solution is a custom implementation and may require further adjustments based on your specific requirements.
50+
51+

0 commit comments

Comments
 (0)