0
thebook = open_workbook(file_to_import)
thesheet = thebook.sheet_by_index(0)
print "show that there is value in the sheet: %s" % thesheet.cell(1,1).value
print "there is nothing in thesheet.col_label_ranges:"
print thesheet.col_label_ranges

for crange in thesheet.col_label_ranges:
    rlo, rhi, clo, chi = crange
    for rx in xrange(rlo, rhi):
        for cx in xrange(clo, chi):
            print "Column label at (rowx=%d, colx=%d) is %r" \
                (rx, cx, thesheet.cell_value(rx, cx))

特定のセルの行と列のラベルを取得しようとしていますが、上記で使用したcol_label_rangesをループするコードが見つかりました。ただし、このコードを実行すると、次の結果が得られます。

show that there is value in the sheet: Katherine
there is nothing in thesheet.col_label_ranges:
[]

何が問題になっているのか、セルの行と列のラベルを読み取るにはどうすればよいですか?

4

1 に答える 1

0

.col_label_ranges空です - 実際にラベル名はありますか? すべては、あなたがそうしていないことを意味します。

ドキュメントの xlrd の言及に注意してください。

列ラベルを含むセルのアドレス範囲のリスト。これらは、[挿入] > [名前] > [ラベル] > [列] によって Excel で設定されます。

于 2012-12-13T16:30:07.860 に答える