JavaScript
const data = [
['150', '643', '0.32', '11', '=A1*(B1*C1)+D1'],
['172', '474', '0.51', '11', '=A2*(B2*C2)+D2'],
['188', '371', '0.59', '11', '=A3*(B3*C3)+D3'],
['162', '731', '0.21', '10', '=A4*(B4*C4)+D4'],
['133', '682', '0.81', '9', '=A5*(B5*C5)+D5'],
['87', '553', '0.66', '10', '=A6*(B6*C6)+D6'],
['26', '592', '0.62', '11', '=A7*(B7*C7)+D7'],
['110', '461', '0.73', '9', '=A8*(B8*C8)+D8'],
['50', '346', '0.52', '15', '=A9*(B9*C9)+D9'],
['160', '423', '0.82', '11', '=A10*(B10*C10)+D10'],
['30', '216', '0.26', '9', '=A11*(B11*C11)+D11'],
['Sum', 'Average', 'Average', 'Sum', 'Sum'],
['=SUM(A1:A12)', '=AVERAGE(B1:B12)', '=AVERAGE(C1:C12)', '=SUM(D1:D12)', '=SUM(E1:E12)']
];
const output = document.querySelector('#output');
const output2 = document.querySelector('#output2');
const getButton = document.querySelector('#getButton');
const container = document.querySelector('#example-data-grid');
const options = {
licenseKey: 'gpl-v3', //... other options
}
//tao 1 bien toan cuc
var pt_glb_indexRow;
var pt_glb_indexCol;
var glb_indexRow;
var glb_indexCol;
var glb_dataLocation;
const hfInstance = HyperFormula.buildFromArray(data, options);
const hot = new Handsontable(container, {
data: data,
formulas: {
engine: HyperFormula,
},
colHeaders: ['Qty', 'Unit price', 'Discount', 'Freight', 'Total due (fx)'],
fixedRowsBottom: 2,
stretchH: 'all',
height: 500,
allowCopy: 'true',
rowHeaders: true,
colHeaders: true,
outsideClickDeselects: false,
selectionMode: 'multiple',
outsideClickDeselects: false,
licenseKey: 'non-commercial-and-evaluation',
afterOnCellMouseDown(event, coords, TD, controller) {
const selected = hot.getSelected() || [];
...