你好,我看了一下,可以试一下创建一个Style设置好了之后调用setStyle. 参考代码:
- function renderData() {
- spread.suspendPaint();
- var cellType = new FivePointedStarCellType();
- data.forEach((rowData, row) => rowData.forEach((v, col) => {
- /*const cell = sheet.getCell(row, col);
- // 更新单元格样式,每个单元格可能不同,这里设置成一样的
- cell.backColor('red');
- // cell.text(v);
- cell.vAlign(1).hAlign(1);
- cell.font('normal normal 14px Microsoft Yahei');
- // 边框,每个单元格可能不同,这里设置成一样的
- const lineColor = '#333';
- const lineStyle = 2;
- const border = new spreadNS.LineBorder;
- border.color = lineColor;
- border.style = lineStyle;
- cell['borderRight'](border);
- cell['borderBottom'](border);
- // 更新单元格类型,每个单元格可能不同,这里设置成一样的
- cell.cellType(
- new FivePointedStarCellType()
- );*/
- var style = new GC.Spread.Sheets.Style();
- style.backColor = "red";
- style.vAlign = 1;
- style.hAlign = 1;
- style.font = 'normal normal 14px Microsoft Yahei';
- const lineColor = '#333';
- const lineStyle = 2;
- const border = new spreadNS.LineBorder;
- border.color = lineColor;
- border.style = lineStyle;
- style.borderRight = border;
- style.borderBottom = border;
- style.cellType = cellType;
- sheet.setStyle(row, col, style);
- }));
- spread.resumePaint();
- }
复制代码
我试了一下,改之后renderData只需要一秒多 |