PHP code example of myclabs / xport

1. Go to this page and download the library: Download myclabs/xport 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/ */

    

myclabs / xport example snippets


$modelBuilder = new SpreadsheetModelBuilder();
$export = new PHPExcelExporter();

$modelBuilder->bind('contacts', $contacts);

$export->export($modelBuilder->build('mapping.yml'), 'myFile.xslx');

$modelBuilder = new SpreadsheetModelBuilder();
$export = new PHPExcelExporter();

$modelBuilder->bind('companies', $companies);

$export->export($modelBuilder->build(new YamlMappingReader('mapping.yml')), 'myFile.xslx');

$modelBuilder = new SpreadsheetModelBuilder();
$export = new PHPExcelExporter();

$modelBuilder->bindFunction('up', function($str) {
    return strtoupper($str);
});

$export->export($modelBuilder->build(new YamlMappingReader('mapping.yml')), 'myFile.xslx');

// ...
$export->export($spreadsheet, 'myFile.xslx', new PHPExcel_Writer_Excel2007());