PHP code example of parkejunior / spreadsheetmr

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

    

parkejunior / spreadsheetmr example snippets


use SpreadSheetMR\SpreadSheetMR;

$path_to_file = "file.csv";
$file_extension = ".csv"; // or only "csv"
$import = new SpreadSheetMR($path_to_file, $file_extension);
$data = $import->getObject();

var_dump($data);

...

$import->verifyFile(array(
	"first_title" => "name", // check if first title on header is "name"
	"last_title" => "phone", // check if last title on header is "phone"
	"total_columns" => 4  // check if total columns on header is 4
));
$data = $import->getObject();

var_dump($data);

...

$import->ignoreRow(3); // ignore 4th row
$import->ignoreColumn(0); // ignore first column
$data = $import->getObject();

var_dump($data);

...

$import->headerIndex = 0; // define first row as header
$data = $import->getObject();

var_dump($data);