PHP code example of akeneo-labs / spreadsheet-parser

1. Go to this page and download the library: Download akeneo-labs/spreadsheet-parser library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

akeneo-labs / spreadsheet-parser example snippets


    use Akeneo\Component\SpreadsheetParser\SpreadsheetParser;

    $workbook = SpreadsheetParser::open('myfile.xlsx');

    $myWorksheetIndex = $workbook->getWorksheetIndex('myworksheet');
    
    foreach ($workbook->createRowIterator($myWorksheetIndex) as $rowIndex => $values) {
        var_dump($rowIndex, $values);
    }
 
    use Akeneo\Component\SpreadsheetParser\SpreadsheetParser;

    $workbook = SpreadsheetParser::open('myfile.csv');

    $iterator = $workbook->createRowIterator(
        0,
        [
            'encoding'  => 'UTF-8',
            'length'    => null,
            'delimiter' => ',',
            'enclosure' => '"',
            'escape'    => '\\'
        ]
    );
   
    
    foreach ($workbook->createRowIterator(0) as $rowIndex => $values) {
        var_dump($rowIndex, $values);
    }