你不要使用LineBorder,使用ComplexBorder来代替。
设置完All Border,再设置Thick Border时,只需要把外面一圈Cell的Border的Top,Bottom,Left和Right,按照需要加粗就可以了。
All Border- CellRange cr = this.fpSpread1.ActiveSheet.GetSelection(0);
- ComplexBorderSide nomalSide = new ComplexBorderSide(Color.Red,1);
- for (int i = cr.Row; i < cr.Row + cr.RowCount; i++)
- {
- for (int j = cr.Column; j < cr.Column + cr.ColumnCount; j++)
- {
- this.fpSpread1.ActiveSheet.Cells[i, j].Border = new ComplexBorder(nomalSide);
- }
- }
复制代码
Thick Border (该示例只是设置了最上边和最下边的Border,不包括最左边和最右边,也不包括4个角的Cell)- CellRange cr = this.fpSpread1.ActiveSheet.GetSelection(0);
- ComplexBorderSide noneSide = new ComplexBorderSide(Color.Empty,0);
- ComplexBorderSide thickSide = new ComplexBorderSide(Color.Red, 3);
- for (int i = cr.Column + 1; i < cr.Column + cr.ColumnCount - 1; i++)
- {
- ComplexBorder orignalBorder = (this.fpSpread1.ActiveSheet.Cells[cr.Row, i].Border as ComplexBorder);
- if (orignalBorder == null)
- {
- // 设置CellRange最上边Cell的Border
- this.fpSpread1.ActiveSheet.Cells[cr.Row, i].Border = new ComplexBorder(noneSide, thickSide, noneSide, noneSide);
- // 设置CellRange最下边Cell的Border
- this.fpSpread1.ActiveSheet.Cells[cr.Row + cr.RowCount - 1, i].Border = new ComplexBorder(noneSide, noneSide, noneSide, thickSide);
- }
- else
- {
- // 设置CellRange最上边Cell的Border
- this.fpSpread1.ActiveSheet.Cells[cr.Row, i].Border = new ComplexBorder(orignalBorder.Left, thickSide, orignalBorder.Right, orignalBorder.Bottom);
- // 设置CellRange最下边Cell的Border
- this.fpSpread1.ActiveSheet.Cells[cr.Row + cr.RowCount - 1, i].Border = new ComplexBorder(orignalBorder.Left, orignalBorder.Top, orignalBorder.Right, thickSide);
- }
- }
复制代码 |