Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function columnToLetter(column){
- var temp, letter = '';
- while (column > 0){
- temp = (column - 1) % 26;
- letter = String.fromCharCode(temp + 65) + letter;
- column = (column - temp - 1) / 26;
- }
- return letter;
- }
- function to_a1(row, col, rowcount, colcount){
- if(typeof(row)== "number" && typeof(col)== "number" && row >0 && col>0 ){
- var ocol = col;
- if(col !== null){col = columnToLetter(col);}
- var a1 = col+row;
- if(colcount !== null){
- colcount = columnToLetter(ocol+colcount-1);
- if(rowcount !== null){a1+=":"+colcount+(row+rowcount-1);}else{a1+=":"+colcount+row;}
- }
- Logger.log(a1);
- return a1;
- }else{
- throw 'to_a1 requires row and col to be positive numbers';
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement