You are here

private function FeedsExcelParser::getSheetIDs in Feeds Excel 7

Get the defined sheet ids of sheets that shall get parsed.

Return value

array

1 call to FeedsExcelParser::getSheetIDs()
FeedsExcelParser::parse in ./ExcelParser.inc
Implementation of FeedsParser::parse().

File

./ExcelParser.inc, line 134

Class

FeedsExcelParser
Parses a given file as a Excel file.

Code

private function getSheetIDs() {
  $sheet_config = $this->config['sheets'];
  $available_sheets = array_keys($this->reader->sheets);

  // Determine all sheets we shall read in by definition.
  $sheet_ids = array();

  // Either all sheets, if no special one is specified.
  if (strlen($sheet_config) < 1) {
    $sheet_ids = $available_sheets;
  }
  else {
    $sheet_expressions = explode(EXCELSHEET_SEP, $sheet_config);
    foreach ($sheet_expressions as $expr) {
      list($from, $to) = explode(EXCELSHEET_RANGE, $expr);

      // Numeric Range
      if (is_numeric($from) && (!$to || is_numeric($to))) {
        if (!$to) {
          $to = $from;
        }

        // Add matching sheets to sheet ids
        foreach ($available_sheets as $available_sheet) {
          if ($from <= $available_sheet && $available_sheet <= $to) {
            $sheet_ids[$available_sheet] = $available_sheet;
          }
        }
      }
      else {
        foreach ($this->reader->boundsheets as $sheet_id => $boundsheet) {
          if ($boundsheet['name'] == $expr) {
            $sheet_ids[$sheet_id] = $sheet_id;
          }
        }
      }
    }
  }
  return $sheet_ids;
}