您好,首先您检查一下您的代码,在执行设置数据验证前后,
有没有加suspendPaint() 和 resumePaint()?
我这边使用如下代码,没能重现性能的问题:
- var spread = GC.Spread.Sheets.findControl("ss");
- var sheet = spread.getActiveSheet();
- sheet.setRowCount(500);
- var spreadNS = GC.Spread.Sheets;
- var dv1 = new spreadNS.DataValidation.createListValidator("Fruit,Vegetable,Food");
- dv1.inputTitle("Please choose a category:");
- dv1.inputMessage("Fruit, Vegetable, Food");
- sheet.suspendPaint();
- for (var i = 0; i < 500; i++) {
- sheet.setDataValidator(i, 2, dv1);
- }
- sheet.resumePaint();
复制代码
另外,如果要设置一整列,不需要用循环,可以把for循环块整个替换为以下代码:
- sheet.setDataValidator(-1, 2, dv1);
复制代码 |