export function chatatABC(n: number) {
  var orda = 'a'.charCodeAt(0)

  var ordz = 'z'.charCodeAt(0)

  var len = ordz - orda + 1

  var s = ''

  while (n >= 0) {
    s = String.fromCharCode((n % len) + orda) + s

    n = Math.floor(n / len) - 1
  }

  return s.toUpperCase()
}

export function getRangetxt(row0: number, row1: number, column0: number, column1: number) {
    // let row0 = range["row"][0], row1 = range["row"][1];
    // let column0 = range["column"][0], column1 = range["column"][1];

    if (row0 == null && row1 == null) {
        return chatatABC(column0) + ":" + chatatABC(column1);
    }
    else if (column0 == null && column1 == null) {
        return (row0 + 1) + ":" + (row1 + 1);
    }
    else {
        if (column0 == column1 && row0 == row1) {
            return chatatABC(column0) + (row0 + 1);
        }
        else {
            return chatatABC(column0) + (row0 + 1) + ":" + chatatABC(column1) + (row1 + 1);
        }
    }
}
