You are here

function socialcalc_cr_to_coord in Sheetnode 7

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.2 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 the field.
sheetnode_handler_field_range::render in views/sheetnode_handler_field_range.inc
Render the field.
sheetnode_plugin_style::render_sheet in views/sheetnode_plugin_style.inc
socialcalc_parse_edit in ./socialcalc.inc
socialcalc_save_cell in ./socialcalc.inc

... See full list

File

./socialcalc.inc, line 689
SocialCalc manipulation functions Translated from socialcalc-3.js and companion files

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) {
    $c = 702;
  }

  // maximum number of columns - ZZ
  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];
}