很简单,就是你上面的代码封装成一个函数,页面中添加一个id=“btn”的元素按钮,我简单写一下:
$(function(){
$("#ss").wijspread({sheetCount:1});
var spread = $("#ss").wijspread("spread");
var sheet= spread.getActiveSheet();
sheet.getCell(0, 0).backColor("red").foreColor("yellow").value("cell1");
sheet.getCell(1, 0).backColor("yellow").foreColor("red").value("cell2");
$("#btn").click(function () {
var startRange = new $.wijmo.wijspread.Range(0, 0, 2, 1);
var fillRange = new $.wijmo.wijspread.Range(2, 0, 7, 1);
alert(0);//该处往上都是没问题的
var dragFillExtent = new $.wijmo.wijspread.UndoRedo.DragFillExtent(startRange, fillRange, $.wijmo.wijspread.AutoFillType.FillFormattingOnly, $.wijmo.wijspread.FillDirection.Down);
alert(1);//发现到此处语句没有被执行
var dragFillAction = new $.wijmo.wijspread.UndoRedo.DragFillUndoAction(sheet, dragFillExtent);
sheet.doCommand(dragFillAction);
})
});
在<body></body>中添加一个按钮元素,如
<body>
<input id="btn" type="button" value="AutoFillTest"/>
<div id="ss"></div>
</body> |