Hi, is there any way to apply the foreground color to an entire row? My code looks like this:
cells(6, 0).Style.Pattern = BackgroundType.Solid
cells(6, 0).Style.ForegroundColor = Color.Silver
I would like this foreground color on all of row 6 and I tried this but it doesn't work:
cells.Rows(6).Style.Pattern = BackgroundType.Solid
cells.Rows(6).Style.ForegroundColor = Color.Silver
Thanks!
Hi,
Thanks for considering Aspose.
Well, when ever you want to apply formattings to a row/column, you may use StyleFlag struct with Row.ApplyStyle() method. Following is the adjusted code which will work fine:
Dim workbook As Workbook = New Workbook()
Dim worksheet As Worksheet = workbook.Worksheets(0)
Dim cells As Cells = worksheet.Cells
Dim stl As Style
Dim flag As StyleFlag = New StyleFlag()
flag.CellShading = True
stl = cells.Rows(6).Style
stl.Pattern = BackgroundType.Solid
stl.ForegroundColor = Color.Silver
cells.Rows(6).ApplyStyle(stl,flag)
workbook.Save("d:\test\testingrowclr.xls")
Thank you.
Thanks so much for your help!