New to Telerik UI for ASP.NET AJAXStart a free 30-day trial

SpreadsheetSheet Object

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:

NameParametersReturn TypeDescription
get_rangestringSpreadsheetRangeReturns 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_selectionnoneSpreadsheetRangeReturns a reference to a SpreadsheetRange representing the current active selection. (see Example 2)
get_columnWidthint, intintReturns the width of the column at the given index.
set_columnWidthintnoneSets the width of the column at the given index.
get_rowHeightintintReturns the height of the row at the given index.
set_rowHeightint, intintSets the height of the row at the given index. (see Example 3)
clearFilterint/ArraynoneClears the filters for the passed column index. If an array is passed, clearFilter will clear the filter for each column index from the array.
deleteColumnintnoneDeletes the contents of the column at the provided index and shifts the remaining contents of the sheet to the left.
deleteRowintnoneDeletes the contents of the row at the provided index and shifts the remaining contents of the sheet up.
hideColumnintnoneHides the column at the specified index.
hideRowintnoneHides the row at the specified index.
unhideColumnintnoneShows the hidden column at the specified index. Does not have any effect if the column is already visible.
unhideRowintnoneShows the hidden row at the specified index. Does not have any effect if the row is already visible.
insertColumnintnoneInserts 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.
insertRowintnoneInserts 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_frozenColumnsnoneintGets the amount of frozen columns displayed by the sheet.
set_frozenColumnsintnoneSets the amount of frozen columns displayed by the sheet.
get_frozenRowsnoneintGets the amount of frozen rows displayed by the sheet.
set_frozenRowsintnoneSet the amount of frozen rows displayed by the sheet.
set_showGridLinesboolnoneTogles 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
}
Not finding the help you need?
Contact Support