Trouble applying a style to a range


#1

I have this code which will loop every 12 rows and apply a particular
style to a group of 6 rows. Below is the code that I think should do
the job but doesn’t. Any suggestions?



Dim leftpoint As Integer = 3

Dim rightpoint As Integer = 8



Dim style As Style = xlApp.Styles(xlApp.Styles.Add)

style.Pattern = BackgroundType.Solid

style.BackgroundColor = Drawing.Color.FromArgb(40)



Do

If rightpoint > 4467 Then

Exit Do

Else

Dim rng As Range = xlWSheet.Cells.CreateRange(“F” &
leftpoint.ToString, _

“S” & rightpoint.ToString)

rng.Style = style



'.Interior.ColorIndex = 40

'.Style.Pattern = BackgroundType.Solid



leftpoint = leftpoint + 12

rightpoint = rightpoint + 12

End If

Loop


#2

What's the problem? Is the color not correct?

Please try:

excel.ChangePalette(Drawing.Color.FromArgb(40), 55)

Dim leftpoint As Integer = 3
Dim rightpoint As Integer = 8

Dim style As Style = xlApp.Styles(xlApp.Styles.Add)
style.Pattern = BackgroundType.Solid
style.ForegroundColor = Drawing.Color.FromArgb(40)

Do
If rightpoint > 4467 Then
Exit Do
Else
Dim rng As Range = xlWSheet.Cells.CreateRange("F" & leftpoint.ToString, _
"S" & rightpoint.ToString)
rng.Style = style

leftpoint = leftpoint + 12
rightpoint = rightpoint + 12
End If
Loop


#3

whenever i apply style.ForegroundColor = Drawing.Color.*

to a color besides Gray or Black, it fills the range with the color black.


#4

If you set a Color.Red, does it still show black?

Please check http://www.aspose.com/Wiki/default.aspx/Aspose.Cells/ColorAndPalette.html for reference.