Akeneo\Component\SpreadsheetParser\SpreadsheetParser::open PHP Method

open() public static method

Opens a spreadsheet
public static open ( string $path, string | null $type = null ) : Akeneo\Component\SpreadsheetParser\SpreadsheetInterface
$path string
$type string | null
return Akeneo\Component\SpreadsheetParser\SpreadsheetInterface
    public static function open($path, $type = null)
    {
        return static::getSpreadsheetLoader()->open($path, $type);
    }

Usage Example

Ejemplo n.º 1
0
 /**
  * reads the given sheet
  * @param $file
  * @param $sheet
  * @param $offset
  */
 protected function readSheet($file, $sheet, $offset = 0)
 {
     $this->logInfo(sprintf('Try to read sheet "%s" from file "%s"', $sheet, $file));
     $workbook = SpreadsheetParser::open($file);
     $worksheets = $workbook->getWorksheets();
     if (!array_key_exists($sheet, $worksheets)) {
         $this->logWarning(sprintf('Tried to read non existing sheet with index "%s" from file "%s"', $sheet, $file));
         return;
     }
     $properties = [];
     $rowIterator = $workbook->createRowIterator($sheet);
     foreach ($rowIterator as $rowIndex => $values) {
         if ($this->headerDetector->isHeader($rowIndex, $values)) {
             $properties = $this->describeProperties($values);
             continue;
         }
         if ($rowIndex < $offset) {
             continue;
         }
         if (!count($properties)) {
             continue;
         }
         $this->processValues($properties, $values);
     }
     if (empty($properties)) {
         $this->logWarning('No properties found to process');
     }
 }
All Usage Examples Of Akeneo\Component\SpreadsheetParser\SpreadsheetParser::open