function r1c1_to_a1(row,col){
var startRow = row +1;
var num = col;
var str = "";
if (num == 0)
{
str = "A";
}
else
{
for ( i = 0; num != 0; i++)
{
if (num == 1)
{
str = "B" + str;
break;
}
var _theasc = 65 - (i != 0 ? 1 : 0) + num % 26;
if(_theasc>=65){
str = String.fromCharCode(_theasc) + str;
}
if ((num % 26 == 0) && (num / 26 == 1))
{
str = "A" + str;
break;
}
num = num / 26;
}
}
return ""+str+startRow;
}
|
|