那就是设置选中区域行的外边线了,外边线分为四部分:所有单元格的上边线、所有单元格的下边线、行最左侧单元格的左边线、最右侧单元格的右边线组成,依次设置这四个部分的边线即可。
代码示例如下:
- sheet.unbind(GC.Spread.Sheets.Events.CellClick);
- sheet.bind(GC.Spread.Sheets.Events.CellClick, function(e, args) {
- if (args.sheetArea === 2) {
- var selection = sheet.getSelections()[0];
- console.log(selection.row, selection.colCount);
- var colCount = selection.colCount;
- // 设置选中区域行的上下边线为虚线
- var style = new GC.Spread.Sheets.Style();
- style.borderTop = new GC.Spread.Sheets.LineBorder("blue",GC.Spread.Sheets.LineStyle.dashDot);
- style.borderBottom = new GC.Spread.Sheets.LineBorder("blue",GC.Spread.Sheets.LineStyle.dashDot);
- sheet.getRange(selection.row, 0, selection.rowCount, selection.colCount).setStyle(style);
-
- // 设置选中区域行最左侧单元格的上下边线为虚线
- var leftBorderStyle = new GC.Spread.Sheets.Style();
- leftBorderStyle.borderLeft =new GC.Spread.Sheets.LineBorder("blue",GC.Spread.Sheets.LineStyle.dashDot);
- leftBorderStyle.borderTop = new GC.Spread.Sheets.LineBorder("blue",GC.Spread.Sheets.LineStyle.dashDot);
- leftBorderStyle.borderBottom = new GC.Spread.Sheets.LineBorder("blue",GC.Spread.Sheets.LineStyle.dashDot);
- sheet.getCell(selection.row, 0).setStyle(leftBorderStyle);
- // 设置选中区域行最右侧单元格的上下边线为虚线
- var rightBorderStyle = new GC.Spread.Sheets.Style();
- rightBorderStyle.borderRight = new GC.Spread.Sheets.LineBorder("blue",GC.Spread.Sheets.LineStyle.dashDot);
- rightBorderStyle.borderTop = new GC.Spread.Sheets.LineBorder("blue",GC.Spread.Sheets.LineStyle.dashDot);
- rightBorderStyle.borderBottom = new GC.Spread.Sheets.LineBorder("blue",GC.Spread.Sheets.LineStyle.dashDot);
- sheet.getCell(selection.row, selection.colCount - 1).setStyle(rightBorderStyle);
- }
- });
复制代码 |