/** * Created by Tony on 2017/4/5. */ var test = require('tape'); var headerStr = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'; test('test private 1', function(t){ private_getCellIdxStr = function(idx, pre){ var rst = 'A', prefix = '', tmpIdx = idx; if (tmpIdx >= 26) { var ti = Math.floor(tmpIdx / 26), tj = tmpIdx % 26; if (ti <= 26) { rst = pre + headerStr[ti - 1] + headerStr[tj]; } else { rst = private_getCellIdxStr(ti, 'A' + pre) + headerStr[tj]; } } else { rst = pre + headerStr[tmpIdx % 26]; } return rst; }; //t.equal(private_getCellIdxStr(0, ''), 'A'); //t.equal(private_getCellIdxStr(25, ''), 'Z'); //t.equal(private_getCellIdxStr(26, ''), 'AA'); //t.equal(private_getCellIdxStr(27, ''), 'AB'); //t.equal(private_getCellIdxStr(51, ''), 'AZ'); //t.equal(private_getCellIdxStr(52, ''), 'BA'); //t.equal(private_getCellIdxStr(675, ''), 'YZ'); //t.equal(private_getCellIdxStr(676, ''), 'ZA'); //t.equal(private_getCellIdxStr(701, ''), 'ZZ'); t.equal(private_getCellIdxStr(702, ''), 'AAA'); t.end(); })