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 DataSource 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:
<template> <div class="sample-tutorial"> <gc-spread-sheets class="sample-spreadsheets" @workbookInitialized="initSpread" :newTabVisible=false> <gc-worksheet> </gc-worksheet> <gc-worksheet> </gc-worksheet> <gc-worksheet> </gc-worksheet> </gc-spread-sheets> </div> </template> <script setup> import { ref } from "vue"; import GC from "@mescius/spread-sheets"; import '@mescius/spread-sheets-vue' let initSpread = function (spread) { spread.options.allowDynamicArray = true; let renderSheet = spread.getSheet(0); let templateSheet = spread.getSheet(1); let dataSheet = spread.getSheet(2); spread.options.scrollByPixel = true; spread.options.scrollPixel = 10; spread.suspendPaint(); initTemplateSheet(templateSheet); initDataSheet(dataSheet); initRenderSheet(renderSheet); spread.resumePaint(); } let initRenderSheet = function (renderSheet) { renderSheet.name("RenderSheet"); renderSheet.setColumnCount(50); renderSheet.setColumnWidth(0, 1200); renderSheet.getCell(0, 0).value("Top 5 Products (by units sold)") .font("20px Arial").vAlign(GC.Spread.Sheets.VerticalAlign.center) .foreColor("white").backColor("#82bc00"); renderSheet.setRowHeight(0, 35); for (var i = 1; i < 6; i++) { renderSheet.setRowHeight(i, 250); renderSheet.setFormula(i, 0, 'RANGEBLOCKSPARKLINE(TemplateSheet!A2:M11, OBJECT(product_table[#Headers], INDEX(product_table[#Data],ROW()-1,SEQUENCE(COUNTA(product_table[#Headers]),1))))'); } } let initTemplateSheet = function (templateSheet) { templateSheet.fromJSON(templateJson); templateSheet.name("TemplateSheet"); templateSheet.setFormatter(2, 1, "=IMAGE(\"$DEMOROOT$/spread/source/images/products/\"&@)"); templateSheet.setBindingPath(2, 1, "Image"); } let initDataSheet = function (dataSheet) { dataSheet.fromJSON(dataJson); } </script> <style scoped> #app { height: 100%; } .sample-tutorial { position: relative; height: 100%; overflow: hidden; } .sample-spreadsheets { width: 100%; height: 100%; overflow: hidden; float: left; } body { position: absolute; top: 0; bottom: 0; left: 0; right: 0; } </style>
<!DOCTYPE html> <html style="height:100%;font-size:14px;"> <head> <meta charset="utf-8" /> <meta http-equiv="X-UA-Compatible" content="IE=edge" /> <title>SpreadJS VUE</title> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <link rel="stylesheet" type="text/css" href="$DEMOROOT$/en/vue3/node_modules/@mescius/spread-sheets/styles/gc.spread.sheets.excel2013white.css"> <script src="$DEMOROOT$/en/vue3/node_modules/systemjs/dist/system.src.js"></script> <script src="$DEMOROOT$/spread/source/data/range-block-data.js" type="text/javascript"></script> <script src="$DEMOROOT$/spread/source/data/range-block-template.js" type="text/javascript"></script> <script src="./systemjs.config.js"></script> <script src="./compiler.js" type="module"></script> <script> var System = SystemJS; System.import("./src/app.js"); System.import('$DEMOROOT$/en/lib/vue3/license.js'); </script> </head> <body> <div id="app"></div> </body> </html>
(function (global) { SystemJS.config({ transpiler: 'plugin-babel', babelOptions: { es2015: true }, paths: { // paths serve as alias 'npm:': 'node_modules/' }, packageConfigPaths: [ './node_modules/*/package.json', "./node_modules/@mescius/*/package.json", "./node_modules/@babel/*/package.json", "./node_modules/@vue/*/package.json" ], map: { 'vue': "npm:vue/dist/vue.esm-browser.js", 'tiny-emitter': 'npm:tiny-emitter/index.js', 'plugin-babel': 'npm:systemjs-plugin-babel/plugin-babel.js', "systemjs-babel-build": "npm:systemjs-plugin-babel/systemjs-babel-browser.js", '@mescius/spread-sheets': 'npm:@mescius/spread-sheets/index.js', '@mescius/spread-sheets-vue': 'npm:@mescius/spread-sheets-vue/index.js' }, meta: { '*.css': { loader: 'systemjs-plugin-css' }, '*.vue': { loader: "../plugin-vue/index.js" } } }); })(this);