Hey
I want to change the backgroundcolor and the border of each cell in a range?
Thank you for help.
GH
Public Sub New()
InitializeComponent()
spreadsheet1.LoadFromFile("Test.xlsx")
spreadsheet1.ActiveWorksheet.SetActiveCell(1, 1)
End Sub
Private Sub Format_Click(ByVal sender As Object, ByVal e As EventArgs) Handles button1.Click
Dim sheet As IWorksheet = spreadsheet1.ActiveWorksheet
Dim CellRange As List(Of CellRangeInfo) = spreadsheet1.ActiveWorksheet.GetAllSelectedRanges()
For m As Integer = 0 To CellRange.Count - 1
Dim topRow As Integer = CellRange(m).Top
Dim leftCol As Integer = CellRange(m).Left
Dim bottomRow As Integer = CellRange(m).Bottom
Dim rightCol As Integer = CellRange(m).Right
For i As Integer = topRow To bottomRow
For j As Integer = leftCol To rightCol
'set the backgroundcolor
sheet.Item(i, j).Style.ForegroundColor = System.Drawing.Color.Green
'set the border style and color
sheet.Item(i, j).Style.Borders.All = Utility.BorderLineType.Thick
sheet.Item(i, j).Style.Borders.AllColor = Color.Bisque
Next j
Next i
Next m
End Sub