The RangeTemplate is a very powerful feature allowing the user or developer to define a template of cell ranges as a single CellType and apply that template to a cell to load different data into the template. This could include multiple rows and/or columns, for example allowing you to display a card view in one cell.
To create a RangeTemplate , follow this example:
var cellType = new GC.Spread.Sheets.CellTypes.RangeTemplate(templateSheet, 0, 0, 12, 11);
sheet.setCellType(3, 2, cellType, GC.Spread.Sheets.SheetArea.viewport);
The following is the API definition:
/**
* @description RangeTemplate provide a template from a range of referenced worksheet,it can apply to a cell.It will render the cell same as the tempalte and fill data different.If the param row,col, rowCount, colCount not set , it will use the whole sheet as the range scope.
* @extends GC.Spread.Sheets.CellTypes.Base
* @param {GC.Spread.Sheets.Worksheet} sheet the referenced worksheet, the sheet could be an individual sheet outside the workbook.
* @param {number} [row] the template scope start row.
* @param {number} [col] the template scope start col.
* @param {number} [rowCount] the template scope row count.
* @param {number} [colCount] the template scope col count.
*/
The parameters row, col, rowCount, and colCount are optional. If those parameters not set, the whole sheet row will be used to create the RangeTemplate. Here is an example of creating a RangeTemplate with a defined row and column count:
var templateSheet = new GC.Spread.Sheets.Worksheet();
templateSheet.setRowCount(12);
templateSheet.setColumnCount(11);
var cellType = new GC.Spread.Sheets.CellTypes.RangeTemplate(templateSheet);
sheet.setCellType(3, 2, cellType, GC.Spread.Sheets.SheetArea.viewport);
You can customize your bindingPath or formula in the template WorkSheet. The RangeTemplate will then use the cell value as the datasource to resolve the bindingPath or formula in the designated range.
Conditional rules, data validation, sparkline data & date ranges, sparklineEx, and formulas can refer to a cell or cell range and they must be contained within the RangeTemplate. In addition, the spans in template WorkSheet must be completely contained inside the RangeTemplate.
The RangeTemplate does not support nesting other RangeTemplates, as it may lose data or cause an endless loop.
Submit and view feedback for