4

I'm automating formula's using pythons XLWT library. I have column indexs, eg, 1,2,3,99, etc and would like to convert to A,B,C,D, AA,AB, etc.

Is there anything built into xlwt for this? Or should I just write my own function?

Humphrey
  • 4,108
  • 2
  • 28
  • 27

1 Answers1

7

You can use xlrds helper function:

import xlrd
print xlrd.colname(56)
# BE

Strangely - there doesn't appear to be a direct equivalent in xlwt or xlwt.Utils (although this does have various helper functions for conversion of cells and names)

Going by the question's title - you can use:

>>> xlwt.Utils.rowcol_to_cell(5, 2)
'C6'
Jon Clements
  • 138,671
  • 33
  • 247
  • 280
  • Brilliant! I search all through the source and docs of xlwt, but didn't think to look in xlrd. Thanks :-) – Humphrey Oct 17 '13 at 00:05
  • 2
    @Humphrey I noticed that the question in the title is slightly different - so I've updated the answer to include `xlwt.Utils.rowcol_to_cell` which produces the full cell address – Jon Clements Oct 17 '13 at 00:14