Babel + JSX
import { createApp, defineComponent, onMounted, ref } from 'vue';
import { HotTable } from '@handsontable/vue3';
import { registerAllModules } from 'handsontable/registry';
import 'handsontable/dist/handsontable.full.css';
import { HyperFormula } from 'hyperformula';
// register Handsontable's modules
registerAllModules();
const hyperformulaInstance = HyperFormula.buildEmpty({
licenseKey: 'internal-use-in-handsontable'
})
const colHeaders = ref(['测试1', '测试2', '测试3']);
const rowColumns = ref([
{ data: 'test1', type: 'text' },
{ data: 'test2', type: 'text' },
{ data: 'test3', type: 'text' }
]);
const formulas = ref({
engine: hyperformulaInstance
});
const settings = ref({
formulas: true,
minRows: 1,
data: [],
contextMenu: {
items: {
row_above: {
name: 'Insert row above this one (custom name)'
},
row_below: {}
}
}
});
const tableRef = ref();
const getHot = () => {
return tableRef.value?.hotInstance;
};
const ExampleComponent = defineComponent({
components: {
HotTable,
},
setup() {
onMounted(() => {
console.log('data', getHot()?.getSourceData());
for (let i = 0; i < getHot()?.getSourceData().length; i++) {
getHot().setDataAtCell(i, 2, '=1+1');
}
});
return {
tableRef,
colHeaders,
rowColumns,
formulas,
settings,
hotSettings: {
data: [
['A1', 'B1', 'C1', 'D1', 'E1', 'F1', 'G1', 'H1', 'I1', 'J1'],
['A2', 'B2', 'C2', 'D2', 'E2', 'F2', 'G2', 'H2', 'I2', 'J2'],
['A3', 'B3', 'C3', 'D3', 'E3', 'F3', 'G3', 'H3', 'I3', 'J3'],
['A4', 'B4', 'C4', 'D4', 'E4', 'F4', 'G4', 'H4', 'I4', 'J4'],
['A5', 'B5', 'C5', 'D5', 'E5', 'F5', 'G5', 'H5', 'I5', 'J5'],
['A6', 'B6', 'C6', 'D6', 'E6', 'F6', 'G6', 'H6', 'I6', 'J6']
],
colHeaders: true,
height: 'auto',
autoWrapRow: true,
autoWrapCol: true,
licenseKey:...