您好,
实现的思路是使用EnterCell和LeaveCell两个事件,在进入和离开单元格的时候,设置行的颜色。
参考代码如下:- $(document).ready(function() {
- var spread = new GcSpread.Sheets.Spread($("#ss").get(0), {
- sheetCount: 3
- });
- var activeSheet = spread.getActiveSheet();
- var spreadNS = GcSpread.Sheets;
-
- var rowStyle = new spreadNS.Style();
- rowStyle.backColor = "green";
-
- var defStyle = activeSheet.getDefaultStyle();
- activeSheet.setStyle(0, -1, rowStyle, spreadNS.SheetArea.viewport);
-
- $("#ss").data("spread").getActiveSheet().bind(GcSpread.Sheets.Events.EnterCell, function (e, info) {
- activeSheet.setStyle(info.row, -1, rowStyle, spreadNS.SheetArea.viewport);
- });
- $("#ss").data("spread").getActiveSheet().bind(GcSpread.Sheets.Events.LeaveCell, function (e, info) {
- activeSheet.setStyle(info.row, -1, defStyle, spreadNS.SheetArea.viewport);
- });
- });
复制代码 |