这是处理此问题的一种方法:
import xlrdbook = xlrd.open_workbook("sample.xls", formatting_info=True)sheets = book.sheet_names()print "sheets are:", sheetsfor index, sh in enumerate(sheets): sheet = book.sheet_by_index(index) print "Sheet:", sheet.name rows, cols = sheet.nrows, sheet.ncols print "Number of rows: %s Number of cols: %s" % (rows, cols) for row in range(rows): for col in range(cols): print "row, col is:", row+1, col+1, thecell = sheet.cell(row, col) # could get 'dump', 'value', 'xf_index' print thecell.value, xfx = sheet.cell_xf_index(row, col) xf = book.xf_list[xfx] bgx = xf.background.pattern_colour_index print bgx有关Python-Excel Google Group的更多信息。



