You are here

function socialcalc_cr_to_coord in Sheetnode 7.2

Same name and namespace in other branches
  1. 5 socialcalc.inc \socialcalc_cr_to_coord()
  2. 6 socialcalc.inc \socialcalc_cr_to_coord()
  3. 7 socialcalc.inc \socialcalc_cr_to_coord()
9 calls to socialcalc_cr_to_coord()
sheetnode_handler_field_named_range::render in views/sheetnode_handler_field_named_range.inc
Render views field.
sheetnode_handler_field_range::render in views/sheetnode_handler_field_range.inc
Render views field.
sheetnode_plugin_style::render_sheet in views/sheetnode_plugin_style.inc
Render views plugin style.
socialcalc_parse_edit in ./socialcalc.inc
socialcalc_save_cell in ./socialcalc.inc

... See full list

File

./socialcalc.inc, line 898
SocialCalc manipulation functions.

Code

function socialcalc_cr_to_coord($c, $r, $return_as_array = FALSE) {
  $letters = array(
    "A",
    "B",
    "C",
    "D",
    "E",
    "F",
    "G",
    "H",
    "I",
    "J",
    "K",
    "L",
    "M",
    "N",
    "O",
    "P",
    "Q",
    "R",
    "S",
    "T",
    "U",
    "V",
    "W",
    "X",
    "Y",
    "Z",
  );
  if ($c < 1) {
    $c = 1;
  }
  if ($c > 702) {

    // Maximum number of columns - ZZ.
    $c = 702;
  }
  if ($r < 1) {
    $r = 1;
  }
  $collow = ($c - 1) % 26;
  $colhigh = floor(($c - 1) / 26);
  if ($colhigh) {
    $result = array(
      $letters[$colhigh - 1] . $letters[$collow],
      $r,
    );
  }
  else {
    $result = array(
      $letters[$collow],
      $r,
    );
  }
  return $return_as_array ? $result : $result[0] . $result[1];
}