If you enter a range in a formula, the range indicator is displayed. You can use the mouse to click and select a range.
Use the Function class to add your own function. For example:
You can also get the function description as shown below:
You can change the in-cell across sheet formula textbox and its popup elements by modify the css definition.
<template>
<div class="sample-tutorial">
<div class="demo-options">
<div class="option-row">
<div id="formulaBar" contenteditable="true" spellcheck="false" style="font-family: Calibri;border: 1px solid #808080;width:100%;box-sizing: border-box;"></div>
</div>
</div>
<gc-spread-sheets class="sample-spreadsheets" @workbookInitialized="initSpread">
<gc-worksheet>
</gc-worksheet>
<gc-worksheet>
</gc-worksheet>
</gc-spread-sheets>
</div>
</template>
<script>
import Vue from 'vue';
import '@mescius/spread-sheets-vue'
import GC from '@mescius/spread-sheets';
import './styles.css';
let App = Vue.extend({
name: "app",
methods:{
initSpread: function (spread) {
this.spread = spread;
var fbx = new GC.Spread.Sheets.FormulaTextBox.FormulaTextBox(document.getElementById('formulaBar'));
fbx.workbook(spread);
spread.suspendPaint();
var sheet2 = spread.sheets[1];
sheet2.setArray(0, 0, [[1, 4, 7], [2, 5, 8], [3, 6, 9]]);
var sheet = spread.sheets[0];
sheet.options.allowCellOverflow = true;
sheet.setValue(1, 2, "A helpful text box is displayed when typing any formula in a cell or the area above the sheet.");
sheet.setValue(2, 2, "For example: =sum(1,2,3)");
for (var i = 5; i < 35; i++) {
for (var j = 1; j < 15; j++) {
sheet.setValue(i, j, i * j);
}
}
// used to help show table support feature
sheet.tables.add("Table1", 4, 7, 5, 4);
for (var c = 7; c <= 10; c++) {
sheet.setColumnWidth(c, 90);
}
sheet.setFormula(3, 0, "Table1[[#Headers],[Column2]]");
// used to help show custom name support feature
sheet.addCustomName("RangeB6C9", "$B$6:$C$9", 0, 0);
sheet.addCustomName("Range2", "SUM($C$11:$D$14)", 0, 0);
sheet.setFormula(4, 0, "AVERAGE(RangeB6C9)");
// used to help show multi supported reference types
var formula = "SUM(B6:C9,E6:F9,Table1[#Data],Range2,F11:J14,D16:I17)";
sheet.setActiveCell(1, 0);
sheet.getCell(1, 0).formula(formula);
fbx.text("=" + formula);
// used to help show cross sheet reference
sheet.setFormula(5, 0, "SUM(sheet2!A1:C3)");
sheet.getRange(1, 0, 5, 1).foreColor("green");
spread.resumePaint();
}
}
});
new Vue({ render: h => h(App) }).$mount('#app');
</script>
<!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/vue/node_modules/@mescius/spread-sheets/styles/gc.spread.sheets.excel2013white.css">
<!-- SystemJS -->
<script src="$DEMOROOT$/en/vue/node_modules/systemjs/dist/system.src.js"></script>
<script src="systemjs.config.js"></script>
<script>
System.import('./src/app.vue');
System.import('$DEMOROOT$/en/lib/vue/license.js');
</script>
</head>
<body>
<div id="app"></div>
</body>
</html>
.sample-tutorial {
position: relative;
height: 100%;
overflow: hidden;
}
.sample-spreadsheets {
width: 100%;
height: calc(100% - 20px);
overflow: hidden;
float: left;
}
body {
position: absolute;
margin: 0;
top: 0;
bottom: 0;
left: 0;
right: 0;
}
.gc-across-sheet-ftb {
z-index: -1 !important;
}
.gc-across-sheet-func-popup {
z-index: -1 !important;
}
(function (global) {
System.config({
transpiler: 'plugin-babel',
babelOptions: {
es2015: true
},
meta: {
'*.css': { loader: 'css' },
'*.vue': { loader: 'vue-loader' }
},
paths: {
// paths serve as alias
'npm:': 'node_modules/'
},
// map tells the System loader where to look for things
map: {
'@mescius/spread-sheets': 'npm:@mescius/spread-sheets/index.js',
'@mescius/spread-sheets-vue': 'npm:@mescius/spread-sheets-vue/index.js',
'@grapecity/jsob-test-dependency-package/react-components': 'npm:@grapecity/jsob-test-dependency-package/react-components/index.js',
'jszip': 'npm:jszip/dist/jszip.js',
'css': 'npm:systemjs-plugin-css/css.js',
'vue': 'npm:vue/dist/vue.min.js',
'vue-loader': 'npm:systemjs-vue-browser/index.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'
},
// packages tells the System loader how to load when no filename and/or no extension
packages: {
src: {
defaultExtension: 'js'
},
rxjs: {
defaultExtension: 'js'
},
"node_modules": {
defaultExtension: 'js'
}
}
});
})(this);