Workbook.SelectedTableCells

Syntax

SelectedTableCells: JSON;

Description

The SelectedTableCells property sets object that contains information about values selected in the table.

Comments

Object set with the property is returned in the cellsTable metadata property.

Example

To execute the example, the page must contain the WorkbookBox component named workbookBox (see Example of Creating the WorkbookBox Component), and also add the following code in the handler, that processes document opening event:

	var count = new PP.Ui.Button({
	ParentNode: document.body, //DOM parent node
	Content: "Calculate Sum", //text 					
	Click: PP.Delegate(onCount)					
	});						
	function onCount()
	{	
		var source = workbookBox.getSource().getActiveSheet();//return instance of the PP.TS.Workbook class
		//Set an object that contains information about values of selected table cells
		var selCells = source.getSelectedTableCells();
		//Get array of cells and sum their values
		var cells = selCells.cells.c;
		var summ = null;
		for (var i = 0; i<cells.length; i++)
		{
			summ += parseInt(cells[i]["@v"]);
		}
		alert("Sum of values of selected cells = " + summ);
	}

After executing the example the Calculate Sum button is placed in the HTML page. Select a cell range and click the button. After that the sum of values for selected cells is shown.

See also:

Workbook