2011年10月12日水曜日

xlrdで背景色(やりかけ)

#!/usr/bin/env python
# -*- coding: utf-8 -*-

import xlrd

if __name__ == '__main__':
    doStrip = True
    wb = xlrd.open_workbook(U'./' + u'test.xls', formatting_info=True)
    sheetCount = wb.nsheets
    workSheets = []
    for num in range(sheetCount):
        sheet = wb.sheets()[num]
        rows =[]
        print u'row, col, value, attr'
        for row in range(sheet.nrows):
            cols = []
            for col in range(sheet.ncols):
                value = int(sheet.cell(row,col).value)
                attr = sheet.cell_xf_index(row, col)
                print row, col, value, attr

                cols.append(value)
            rows.append(cols)
        workSheets.append((sheet.name, rows))

row, col, value, attr
0 0 10 15
0 1 21 15
1 0 11 21
1 1 22 15
2 0 12 15
2 1 23 15
3 0 13 15
3 1 24 21
4 0 14 15
4 1 25 15
5 0 15 21
5 1 26 15
6 0 16 15
6 1 27 15
7 0 17 15
7 1 28 15
8 0 18 15
8 1 29 15
9 0 19 15
9 1 30 15

0 件のコメント:

コメントを投稿