你好,spreadjs 在对 1万条数据进行设置 居中 和 边框,性能问题很严重,比不设置样式多耗时 13 秒。代码如下,请问如何改进。谢谢
var data = sheet.data;
var para=$("body").data("para");
var dataformat = para.dataformat;
sheet.isPaintSuspended(true);
var style = new $.wijmo.wijspread.Style();
style.vAlign = $.wijmo.wijspread.VerticalAlign.center;
style.font = "normal normal normal 16px/normal 宋体";
var style_xh = new $.wijmo.wijspread.Style();
style_xh.vAlign = $.wijmo.wijspread.VerticalAlign.center;
style_xh.hAlign = $.wijmo.wijspread.HorizontalAlign.center;
for (var i = 0; i < dataformat.len_datarow ; i++) //遍历行
{
sheet.setStyle(dataformat.start_datarow + i, 0, style_xh);
for (var j = 1; j < sheet.getColumnCount(); j++) //遍历列
{
sheet.setStyle(dataformat.start_datarow + i, j, style);
}
}
var r = new $.wijmo.wijspread.Range(dataformat.start_datarow, 0, sheet.getRowCount() - dataformat.start_datarow, sheet.getColumnCount());
sheet.setBorder(r, new $.wijmo.wijspread.LineBorder("black",1), { all: true }, 3);
sheet.isPaintSuspended(false);
另外,设置默认样式不起作用。代码如下:
function setsheet_Default(sheet)
{
var style = new $.wijmo.wijspread.Style();
style.hAlign = $.wijmo.wijspread.HorizontalAlign.center;
style.vAlign = $.wijmo.wijspread.VerticalAlign.center;
sheet.setDefaultStyle(style, $.wijmo.wijspread.SheetArea.viewport);
} |
|