RangeBlock

A rangeblock sparkline can bind to and return a range template to make working with range templates easier. Take a look at the workbook below to see how the RenderSheet uses a range of cells in the TemplateSheet as the template and the OBJECT function to create an object from data in the data sheet.

You can create a rangeblock sparkline using the RANGEBLOCKSPARKLINE function in a formula: =RANGEBLOCKSPAKLINE(template_range, data_expr). The function has the following parameters: template_range: Reference that represents the range of rangetemplate, such as Template!A1:E10. data_expr: Cell reference or the result of OBJECT function that represents the object data of range template for the data bind, such as A1 or OBJECT(E4:AB4, E5:AB5). For example: For the OBJECT function, you can create an object using OBJECT function in a formula: =OBJECT(prop1, expr1, prop2, expr2, …) // the 1->1 case or =OBJECT(props_range, exprs_range) // the n1->n2 case or =OBJECT(property1, expressionArray1, property2, expressionArray2, …) // the 1->n case. It defines an object and the params must be key-value order and needs to come in pairs. The prop and value support 1->1, 1->n, n1->n2(n1 equals to n2). The case of 1->1 and n1->n2 returns an object, the case of 1->n returns an object array. For example:
var spreadNS = GC.Spread.Sheets; window.onload = function () { var spread = new GC.Spread.Sheets.Workbook(document.getElementById("ss"), { sheetCount: 3 }); spread.options.allowDynamicArray = true; initSpread(spread); }; function initSpread(spread) { var renderSheet = spread.getSheet(0); var templateSheet = spread.getSheet(1); var dataSheet = spread.getSheet(2); spread.suspendPaint(); initTemplateSheet(templateSheet); initDataSheet(dataSheet); initRenderSheet(renderSheet); spread.resumePaint(); } function ImageCellType() { this.typeName = "ImageCellType"; } ImageCellType.prototype = new GC.Spread.Sheets.CellTypes.Base(); ImageCellType.prototype.paint = function (ctx, value, x, y, w, h, style, context) { style.backgroundImage = value; style.backgroundImageLayout = GC.Spread.Sheets.ImageLayout.center; GC.Spread.Sheets.CellTypes.Text.prototype.paint.apply(this, [ctx, '', x, y, w, h, style, context]); } function initRenderSheet (renderSheet) { renderSheet.name("RenderSheet"); renderSheet.setColumnCount(8); renderSheet.setRowCount(1); renderSheet.setRowHeight(0, 400); for (var i = 0; i < 8; i++) { renderSheet.setColumnWidth(i, 400); renderSheet.setFormula(0, i, 'RANGEBLOCKSPARKLINE(TemplateSheet!A2:F11, OBJECT(tblPlayers[#Headers], INDEX(tblPlayers[#Data],COLUMN(),SEQUENCE(COUNTA(tblPlayers[#Headers]),1))))'); } } function initTemplateSheet (templateSheet) { templateSheet.fromJSON(templateJson); templateSheet.name("TemplateSheet"); var imageCellType = new ImageCellType(); templateSheet.getCell(2, 1).cellType(imageCellType); } function initDataSheet (dataSheet) { dataSheet.fromJSON(dataJson); }
<!doctype html> <html style="height:100%;font-size:14px;"> <head> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <link rel="stylesheet" type="text/css" href="$DEMOROOT$/en/purejs/node_modules/@grapecity/spread-sheets/styles/gc.spread.sheets.excel2013white.css"> <script src="$DEMOROOT$/en/purejs/node_modules/@grapecity/spread-sheets/dist/gc.spread.sheets.all.min.js" type="text/javascript"></script> <script src="$DEMOROOT$/spread/source/js/license.js" type="text/javascript"></script> <script src="$DEMOROOT$/spread/source/data/data-sheet-json.js" type="text/javascript"></script> <script src="$DEMOROOT$/spread/source/data/template-sheet-json.js" type="text/javascript"></script> <script src="app.js" type="text/javascript"></script> <link rel="stylesheet" type="text/css" href="styles.css"> </head> <body> <div class="sample-tutorial"> <div id="ss" style="width:100%;height:100%"></div> </div></body> </html>
.sample-tutorial { position: relative; height: 100%; overflow: hidden; } body { position: absolute; top: 0; bottom: 0; left: 0; right: 0; }