You are here

function _sheetnode_phpexcel_export_reference in Sheetnode 7

Same name and namespace in other branches
  1. 6 modules/sheetnode_phpexcel/sheetnode_phpexcel.export.inc \_sheetnode_phpexcel_export_reference()
  2. 7.2 modules/sheetnode_phpexcel/sheetnode_phpexcel.export.inc \_sheetnode_phpexcel_export_reference()

Helper to export referenced sheet.

1 call to _sheetnode_phpexcel_export_reference()
_sheetnode_phpexcel_export_cell_value_and_format in modules/sheetnode_phpexcel/sheetnode_phpexcel.export.inc
Helper function to export a cell.

File

modules/sheetnode_phpexcel/sheetnode_phpexcel.export.inc, line 553
Export sheetnodes through PHPExcel to xls or xlsx spreadsheets.

Code

function _sheetnode_phpexcel_export_reference($c, $cell, $worksheet) {
  list($sheetname, $reference) = explode('!', $c['formula'], 2);
  $sheetname = trim($sheetname, '"\'');
  list($value, $title) = sheetnode_find_sheet($sheetname);
  if ($value) {
    $workbook = $worksheet
      ->getParent();
    $external = $workbook
      ->getSheetByName($title);
    if (!$external) {
      $external = $workbook
        ->createSheet($workbook
        ->getSheetCount());
      $socialcalc = socialcalc_parse($value);
      _sheetnode_phpexcel_export_sheet($external, $title, $socialcalc);
    }
    $cell
      ->setValue('=\'' . $title . '\'!' . $reference);
  }
  else {
    $cell
      ->setValue($c['datavalue']);
    $comment = t(variable_get('sheetnode_phpexcel_bad_formula', 'Could not export formula !formula.'), array(
      '!formula' => $c['formula'],
    ));
    $worksheet
      ->getComment($cell
      ->getCoordinate())
      ->getText()
      ->createTextRun($comment);
  }
}