You are here

function _sheetnode_phpexcel_export in Sheetnode 6

Same name and namespace in other branches
  1. 5 modules/sheetnode_phpexcel/sheetnode_phpexcel.export.inc \_sheetnode_phpexcel_export()
  2. 7.2 modules/sheetnode_phpexcel/sheetnode_phpexcel.export.inc \_sheetnode_phpexcel_export()
  3. 7 modules/sheetnode_phpexcel/sheetnode_phpexcel.export.inc \_sheetnode_phpexcel_export()

Helper function to export a node using PHPExcel.

1 string reference to '_sheetnode_phpexcel_export'
sheetnode_phpexcel_menu in modules/sheetnode_phpexcel/sheetnode_phpexcel.module
Implementation of hook_menu().

File

modules/sheetnode_phpexcel/sheetnode_phpexcel.export.inc, line 6

Code

function _sheetnode_phpexcel_export($format, $node) {
  require_once drupal_get_path('module', 'sheetnode') . '/socialcalc.inc';
  if (empty($node)) {
    return drupal_not_found();
  }
  $sheets = array();
  if ($node->type == 'sheetnode') {
    $sheets[$node->title] = socialcalc_parse($node->sheetnode['value']);
  }
  $sheetfields = sheetnode_get_sheetfields($node->type);
  if (!empty($sheetfields)) {
    foreach ($sheetfields as $sheetfield) {
      foreach ($node->{$sheetfield['field_name']} as $delta => $item) {
        $sheets[$sheetfield['widget']['label'] . ' ' . ($delta + 1)] = socialcalc_parse($item['value']);
      }
    }
  }
  if (empty($sheets)) {
    return drupal_not_found();
  }
  sheetnode_phpexcel_batch_export($sheets, $node->title, $format);

  /* DEBUGGING
   * Simulate Batch API with sequential processing for easier debugging.
   */

  /*
  $context = array();
  $operations = array();
  foreach ($sheets as $title => $socialcalc) {
    _sheetnode_phpexcel_batch_export_sheet($title, $socialcalc, 'test', 'xls', '', $context);
  }
  return '';
  */
}