PHP code example of fdmsantos / exceltofiles

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

    

fdmsantos / exceltofiles example snippets




use ExcelToFiles\ExcelToFiles;

$exceltoFiles = new ExcelToFiles([
  'template' => 'template.txt',
  'excel'    => 'excel.xls',
  'mapping'  => [
    '[name]' => 'A'
    '[country]' => 'B'
    '[age]' => 'C'
]);

$exceltoFiles->generate();



use ExcelToFiles\ExcelToFiles;

$exceltoFiles = new ExcelToFiles([
  'template' => '{template.txt}',
  'excel'    => '{excel.xls}',
  'excludeRows' => [1,2,13], // To exclude Rows. This example wil exclude row 1, 2 and 13
  'filesname' => 'person_{A}.txt', // To define filename. The name can depends from excel row. For this it's necessary use {column}.
  'outputdir' => 'src/', // To choose files path. The Default is current path.
  'mapping'  => [
    '[name]' => 'A'
    '[country]' => 'B'
    '[age]' => 'C'
]);

// One Clousure for Variable
$exceltoFiles->mapWithClosure('[name]',function($columns) {
	return $columns['A'].' => '.$columns['B'];
});

$exceltoFiles->generate();