amis2/packages/office-viewer/examples/excel.ts
吴多益 4b8dd7a9ca
feat: Office Viewer 支持 Excel (#9826)
* feat: Office viewer 支持 Excel

* 修复类型报错

* 修复类型报错
2024-03-20 11:08:43 +08:00

40 lines
1.2 KiB
TypeScript

/**
* 本地测试例子
*/
import {HitTestResult} from '../src/excel/render/selection/hitTest';
import {App} from './common';
import fileLists from './excelFileList';
const viewerElement = document.getElementById('viewer') as HTMLElement;
const testDir = '/__tests__/xlsx';
const data = {};
const renderOptions = {
height: 700,
debug: true,
editable: true,
fontURL: {
线: '/examples/static/font/DengXian.ttf',
仿: '/examples/static/font/STFANGSO.TTF',
: '/examples/static/font/simhei.ttf'
},
data,
mousePositionTracker: (
x: number,
y: number,
hitTestResult: HitTestResult | null
) => {
document.getElementById('mousePosition')!.innerText = `x${x}, y${y}`;
if (hitTestResult) {
document.getElementById(
'hitTestResult'
)!.innerHTML = `${hitTestResult.type}<br/>row: ${hitTestResult.startRow}<br/>col: ${hitTestResult.startCol}<br/>endRow: ${hitTestResult.endRow}<br/>endCol: ${hitTestResult.endCol}<br/>r: ${hitTestResult.region}<br/>width: ${hitTestResult.width}<br/>height: ${hitTestResult.height}`;
}
},
enableVar: true
};
new App(testDir, fileLists, viewerElement, renderOptions);