Hello everybody,
i'm trying to read the rgb value from a cell but getting wrong
values.
My testfile:
http://torsti.net/files/xlrd-test.xls
Testcode:
import xlrd
book = xlrd.open_workbook("xlrd-test.xls", formatting_info=1)
sheets = book.sheet_names()
for index, sh in enumerate(sheets):
sheet = book.sheet_by_index(index)
rows, cols = sheet.nrows, sheet.ncols
for row in range(rows):
for col in range(cols):
print "row, col:", row+1, col+1,
thecell = sheet.cell(row, col) # could get 'dump',
'value', 'xf_index'
xfx = sheet.cell_xf_index(row, col)
xf = book.xf_list[xfx]
bgx = xf.background.pattern_colour_index
print " idx:",bgx,
rgb = book.colour_map[bgx]
print " RGB:",rgb
Output:
row, col: 1 1 idx: 54 RGB: (102, 102, 153)
row, col: 2 1 idx: 10 RGB: (255, 0, 0)
row, col: 3 1 idx: 11 RGB: (0, 255, 0)
row, col: 4 1 idx: 12 RGB: (0, 0, 255)
row, col: 5 1 idx: 64 RGB: None
row, col: 6 1 idx: 13 RGB: (255, 255, 0)
row, col: 7 1 idx: 15 RGB: (0, 255, 255)
row, col: 8 1 idx: 14 RGB: (255, 0, 255)
Row 2-8 are ok, but row 1 is wrong. In Excel set it to (78, 128,
178).
Am i doing something wrong or is there a bug in xlrd?