New to Telerik UI for ASP.NET AJAX? Start a free 30-day trial
SpreadsheetSheet Object
Updated over 6 months ago
This article explains the methods of the SpreadsheetSheet client-side object and provides examples on its usage.
The following example demonstrates how to get a reference to the active Sheet.
JavaScript
function getActiveSheet() {
var spreadsheet = $find("<%= RadSpreadSheet1.ClientID %>");
var activeSheet = spreadsheet.get_activeSheet();
}
more methods demonstrating how to acquire a reference to the SpreadsheetSheet, could be observed in the RadSpreadsheet Object article
The following table lists the methods of the client-side Spreadsheetsheet object:
| Name | Parameters | Return Type | Description |
|---|---|---|---|
| get_range | string | SpreadsheetRange | Returns a reference to a SpreadsheetRange for the given range specification. Note: accepts A1 or RC notation reference of the SpreadsheetRange object. (see Example 1) |
| get_selection | none | SpreadsheetRange | Returns a reference to a SpreadsheetRange representing the current active selection. (see Example 2) |
| get_columnWidth | int, int | int | Returns the width of the column at the given index. |
| set_columnWidth | int | none | Sets the width of the column at the given index. |
| get_rowHeight | int | int | Returns the height of the row at the given index. |
| set_rowHeight | int, int | int | Sets the height of the row at the given index. (see Example 3) |
| clearFilter | int/Array | none | Clears the filters for the passed column index. If an array is passed, clearFilter will clear the filter for each column index from the array. |
| deleteColumn | int | none | Deletes the contents of the column at the provided index and shifts the remaining contents of the sheet to the left. |
| deleteRow | int | none | Deletes the contents of the row at the provided index and shifts the remaining contents of the sheet up. |
| hideColumn | int | none | Hides the column at the specified index. |
| hideRow | int | none | Hides the row at the specified index. |
| unhideColumn | int | none | Shows the hidden column at the specified index. Does not have any effect if the column is already visible. |
| unhideRow | int | none | Shows the hidden row at the specified index. Does not have any effect if the row is already visible. |
| insertColumn | int | none | Inserts a new, empty column at the specified index. The contents of the spreadsheet (including the ones in the current column index) are shifted to the right. |
| insertRow | int | none | Inserts a new, empty row at the specified index. The contents of the spreadsheet (including the ones in the current row index) are shifted down. (see Example 4) |
| get_frozenColumns | none | int | Gets the amount of frozen columns displayed by the sheet. |
| set_frozenColumns | int | none | Sets the amount of frozen columns displayed by the sheet. |
| get_frozenRows | none | int | Gets the amount of frozen rows displayed by the sheet. |
| set_frozenRows | int | none | Set the amount of frozen rows displayed by the sheet. |
| set_showGridLines | bool | none | Togles the visibility state of the GrigLines in the sheet. (see Example 5) |
Example 1: Demonstrates the usage of the get_range method
JavaScript
function getSheetRange() {
var spreadsheet = $find("<%= RadSpreadsheet1.ClientID %>");
var activeSheet = spreadsheet.get_activeSheet();
var range = activeSheet.get_range("A1:B3");
}
Example 2: Demonstrates the usage of the get_selection method
JavaScript
function getSelectedRangeValue() {
var spreadsheet = $find("<%= RadSpreadsheet1.ClientID %>");
var activeSheet = spreadsheet.get_activeSheet();
var selection = activeSheet.get_selection();
alert(selection.get_value());
}
Example 3: Demonstrates the usage of the set_rowHeight method
JavaScript
function setSheetRowHeight() {
var spreadsheet = $find("<%= RadSpreadsheet1.ClientID %>");
var activeSheet = spreadsheet.get_activeSheet();
activeSheet.set_rowHeight(0, 30);
}
Example 4: Demonstrates the usage of the insertRow method
JavaScript
function insertSheetRow() {
var spreadsheet = $find("<%= RadSpreadsheet1.ClientID %>");
var activeSheet = spreadsheet.get_activeSheet();
activeSheet.insertRow(1);
}
Example 5: Demonstrates the usage of the set_showGridLines method
JavaScript
function insertSheetRow() {
var spreadsheet = $find("<%= RadSpreadsheet1.ClientID %>");
var activeSheet = spreadsheet.get_activeSheet();
activeSheet.set_showGridLines(false); //hides the grid lines in the active sheet
}