Python / Excel - Conditional cell printing with xlrd -



Python / Excel - Conditional cell printing with xlrd -

i want print rows of specifig column, let's colmn b, far good:

import xlrd file_location = "/home/myuser/excel.xls" workbook = xlrd.open_workbook(file_location) sheet = workbook.sheet_by_index(0) info = [[sheet.cell_value(r, c) c in range(sheet.ncols)] r in range(sheet.nrows)] r in data: print r[1]

now want print out cell values, have yellowish colored background. found link failed adept code. help me out?

if know specific color index of cells yellowish background, can check background.pattern_colour_index value of cell style. note of import pass formatting_info=true open_workbook():

import xlrd file_location = "/home/myuser/excel.xls" workbook = xlrd.open_workbook(file_location, formatting_info=true) sheet = workbook.sheet_by_index(0) row in range(sheet.nrows): cell = sheet.cell(row, 1) style = workbook.xf_list[cell.xf_index] color = style.background.pattern_colour_index if color == 43: # on of yellows print cell.value

example:

for file containing 2 cells yellowish background:

the code above prints:

test2 test4

python excel xlrd

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -