Hello @Drbohlav
instead of trying to convert ColorIndex to Rgb you can use Interior.Color and ColorTranslator to get RGB values
import clr
import System
from System.Collections.Generic import List
clr.AddReferenceByName('Microsoft.Office.Interop.Excel, Version=11.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c' )
from Microsoft.Office.Interop import Excel
from System.Runtime.InteropServices import Marshal
clr.AddReference('System.Drawing')
from System.Drawing import Color, ColorTranslator
def getRGBfromIntColor(intColor):
colorGDI = ColorTranslator.FromOle(intColor)
return colorGDI.R, colorGDI.G, colorGDI.B
rgbColor = []
ex = System.Runtime.InteropServices.Marshal.GetActiveObject("Excel.Application")
ex.Visible = True
workbook = ex.ActiveWorkbook
ws = ex.ActiveSheet
myrange = ws.Range[ws.Cells(1, 1), ws.Cells(10, 1)]
#setColor by Interior ColorIndex (just for example)
i = 10
for rx in myrange:
rx.Interior.ColorIndex = i
i += 1
#get Rgb by Interior Color and ColorTranslator
for rx in myrange:
r, g, b = getRGBfromIntColor(rx.Interior.Color)
rgbColor.append([r, g, b])
OUT = rgbColor