You are here

function theme_sheetnode_range in Sheetnode 5

Same name and namespace in other branches
  1. 6 sheetnode.module \theme_sheetnode_range()
  2. 7.2 sheetnode.module \theme_sheetnode_range()
  3. 7 sheetnode.module \theme_sheetnode_range()

File

./sheetnode.module, line 376

Code

function theme_sheetnode_range($range) {
  if (empty($range)) {
    return '';
  }
  require_once drupal_get_path('module', 'sheetnode') . '/socialcalc.inc';
  list($c, $r) = socialcalc_coord_to_cr(key($range));
  $row = array();
  $row[] = array(
    'data' => $r,
    'header' => TRUE,
  );
  $header = array();
  $header[] = array();
  $rows = array();
  foreach ($range as $coord => $value) {
    $pos = socialcalc_coord_to_cr($coord);
    if ($pos[1] > $r) {
      $rows[] = $row;
      $r = $pos[1];
      $row = array();
      $row[] = array(
        'data' => $r,
        'header' => TRUE,
      );
    }
    $row[] = $value;
    if (empty($rows)) {
      $coord = socialcalc_cr_to_coord($pos[0], $pos[1], TRUE);
      $header[] = $coord[0];
    }
  }
  $rows[] = $row;
  return theme('table', $header, $rows);
}