边框设置完整代码:
Private Sub SetCellBorderAll()
Dim sv As FarPoint.Win.Spread.SheetView = FpSpread1.ActiveSheet
If sv Is Nothing Then
Exit Sub
End If
Dim border As ComplexBorder
Dim StarRow As Integer
Dim StarColumn As Integer
Dim EndRow As Integer
Dim Endcolumn As Integer
Dim cr As FarPoint.Win.Spread.Model.CellRange
Dim lb As FarPoint.Win.ComplexBorderSide = New FarPoint.Win.ComplexBorderSide(Color.Black, 1)
Dim tb As ComplexBorderSide = New ComplexBorderSide(Color.Black, 1)
If sv.GetSelections().Length > 0 Then
cr = sv.GetSelections(0)
StarRow = cr.Row
StarColumn = cr.Column
EndRow = StarRow + cr.RowCount
Endcolumn = StarColumn + cr.ColumnCount
sv.Cells(cr.Row, cr.Column, cr.RowCount + cr.Row - 1, cr.ColumnCount + cr.Column - 1).Border = New FarPoint.Win.ComplexBorder(Nothing, Nothing, tb, tb)
If StarRow = 0 Then
sv.Cells(0, StarColumn, 1, Endcolumn - 1).Border = New FarPoint.Win.ComplexBorder(Nothing, tb, tb, tb)
Else
For i As Integer = 0 To cr.ColumnCount - 1
border = TryCast(FpSpread1.ActiveSheet.Cells(StarRow - 1, StarColumn + i).Border, ComplexBorder)
If Not border Is Nothing Then
sv.Cells(StarRow - 1, StarColumn + i).Border = New FarPoint.Win.ComplexBorder(border.Left, Nothing, border.Right, tb)
Else
sv.Cells(StarRow - 1, StarColumn + i).Border = New FarPoint.Win.ComplexBorder(Nothing, Nothing, Nothing, tb)
End If
Next
End If
End If
If StarColumn = 0 Then
sv.Cells(StarRow, 0, EndRow, 0).Border = New FarPoint.Win.ComplexBorder(lb, Nothing, lb, tb)
Else
For i As Integer = 0 To cr.RowCount - 1
border = TryCast(FpSpread1.ActiveSheet.Cells(cr.Row + i, cr.Column - 1).Border, ComplexBorder)
If Not border Is Nothing Then
sv.Cells(cr.Row + i, cr.Column - 1).Border = New FarPoint.Win.ComplexBorder(border.Left, Nothing, tb, border.Bottom)
Else
sv.Cells(cr.Row + i, cr.Column - 1).Border = New FarPoint.Win.ComplexBorder(Nothing, Nothing, tb, Nothing)
End If
Next
End If
End Sub |