Commit 511e87c1 authored by Nicolas Delaby's avatar Nicolas Delaby

add function to convert int to letters

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@24638 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent b400a4c4
......@@ -259,6 +259,15 @@ def getPath(object_or_path, **kw):
return path.split('/')
return path
def int2letters(i):
"""
Convert an integer to letters, to generate spreadsheet column id
A, B, C ..., Z, AA, AB, ..., AZ, BA, ..., ZZ, AAA ...
"""
if i < 26:
return (chr(i + ord('A')))
d, m = divmod(i, 26)
return int2letter(d - 1) + int2letter(m)
#####################################################
# Globals initialization
......
......@@ -107,7 +107,8 @@ from AccessControl.SecurityInfo import ModuleSecurityInfo
allow_module('Products.ERP5Type.Cache')
ModuleSecurityInfo('Products.ERP5Type.Utils').declarePublic(
'sortValueList', 'convertToUpperCase', 'UpperCase',
'convertToMixedCase', 'cartesianProduct', 'sleep', 'getCommonTimeZoneList')
'convertToMixedCase', 'cartesianProduct', 'sleep', 'getCommonTimeZoneList',
'int2letters',)
allow_module('Products.ERP5Type.Message')
ModuleSecurityInfo('Products.ERP5Type.Message').declarePublic('translateString')
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment