def getTableColumnLabel(c):
  label = ''
  while True:
    label += 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'[c % 26]
    if c <= 26:
      break
    c = int(c/26)
  return label

def parseTableColumnLabel(label):
  ret = 0
  for c in map(ord, reversed(label)):
    if 0x41 <= c <= 0x5A:
      ret = ret*26 + (c-0x41)
    else:
      raise ValueError('Invalid label: %s' % label)
  return ret

def getTableColumnLabel(c):
  label = ''
  while True:
    label = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'[c % 26] + label
    if c < 26:
      break
    c = c//26-1
  return label

def parseTableColumnLabel(label):
  if not label:
    raise ValueError('Invalid label: %s' % label)
  ret = -1
  for c in map(ord, label):
    if 0x41 <= c <= 0x5A:
      ret = (ret+1)*26 + (c-0x41)
    else:
      raise ValueError('Invalid label: %s' % label)
  return ret

Fix (parse|generate) table header label function
Fix (parse|generate) table header label function
