本帖最后由 StarStarStar 于 2024-6-5 10:35 编辑
使用Designer和SpreadSheet 用setArray赋值一万八千多行,时间差10倍左右,怎么才能提高Designer使用setArray的速度
Designer使用代码:
import { Designer } from "@grapecity/spread-sheets-designer-react";
const initSpread = (workbooks: any) => {
var spread = workbooks?.getWorkbook();
const sheet = spread.getActiveSheet();
console.time('spreadjs设置行的时间')
let allRow = 18163;
sheet.setRowCount(allRow);
console.log(allRow, 'setRowCountallRow');
console.timeEnd('spreadjs设置行的时间')
console.time('spreadjs设置数据的时间');
sheet.suspendCalcService(false);
sheet.suspendPaint();
sheet.setArray(frozenLine, 0, exceldata?.data.dataArray);
sheet.resumePaint();
sheet.resumeCalcService(false);
console.timeEnd('spreadjs设置数据的时间');
};
<Designer
designerInitialized={(spread: any) => {
initSpread(spread);
}}
></Designer>
结果:
SpreadSheet 代码:
import { SpreadSheets, Worksheet } from '@grapecity/spread-sheets-react';
const initSpread = (workbooks: any) => {
const sheet = workbooks.getActiveSheet();
console.time('spreadjs设置行的时间')
let allRow = 18163;
sheet.setRowCount(allRow);
console.log(allRow, 'setRowCountallRow');
console.timeEnd('spreadjs设置行的时间')
console.time('spreadjs设置数据的时间');
sheet.suspendCalcService(false);
sheet.suspendPaint();
sheet.setArray(frozenLine, 0, exceldata?.data.dataArray);
sheet.resumePaint();
sheet.resumeCalcService(false);
console.timeEnd('spreadjs设置数据的时间');
};
<SpreadSheets
workbookInitialized={(spread: any) => {
initSpread(spread);
}}
>
<Worksheet />
</SpreadSheets>
结果:
|