本帖最后由 allen-an 于 2022-12-14 11:02 编辑
不知道这算不算你们的 bug,开发环境是 vue3+ts+vite,同时使用了 designer 和 spread
- <script setup lang="ts">
- import {onMounted, ref} from 'vue'
- import '@grapecity/spread-sheets/styles/gc.spread.sheets.excel2016colorful.css';
- import '@grapecity/spread-sheets-designer/styles/gc.spread.sheets.designer.min.css';
- import '@grapecity/spread-sheets-designer-resources-cn';
- import DesignerGC from '@grapecity/spread-sheets-designer';
- import GC from '@grapecity/spread-sheets';
- import data from './data';// sheet json
- const spreadBox=ref();
- let spread: any = null;
- onMounted(() => {
- const designer = new DesignerGC.Spread.Sheets.Designer.Designer(spreadBox.value);
- spread = designer.getWorkbook();
- spread.suspendPaint();
- spread.clearSheets();
- const sheet = new GC.Spread.Sheets.Worksheet('a');
- sheet.fromJSON(data);
- spread.addSheet(0, sheet);
- spread.resumePaint();
- })
- </script>
复制代码 上面这种写法会出现chart 组件报错,只有在 sheet 中有图表会报这个错误
解决方法就是不要用 chearSheet 这个方法,使用覆盖
- spread.suspendPaint();
- const sheet = spread.getActiveSheet();
- sheet.name(sheetName);
- sheet.fromJSON(data);
- spread.resumePaint();
复制代码
|