Multiformat spreadsheet reader

0.1.0 2021-01-12 18:02 UTC

This package is auto-updated.

Last update: 2022-05-16 12:53:14 UTC


SpreadSheetMR is a simple multiformat spreadsheet reader.

  • Read XLSX, XLS, CSV or TXT files
  • Combine header with data
  • Ignore row or columns

This library uses shuchkin/SimpleXLS and shuchkin/SimpleXLSX for read Excel files.


First, you will need to install Composer. Then, run the following command:

$ composer install parkejunior/spreadsheetmr



Here is a basic example of using the library:

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();


The getObject method get data formatted using stdClass. Note that the file extension is passed as a separate property from the file path, because the path can be temporary like the superglobal $_FILES['file']['tmp_name'].

Verify header and limits

You can use the verifyFile() method by passing an array with some settings. Example:


	"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();


Ignore row and columns

It is also possible to ignore columns or rows using the ignoreRow() and ignoreColumn() methods by passing the index offset as a parameter. Example:


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


Define which row is the header

You can define which line is the header by passing to the headerIndex property the index offset of the line. Note that when the header is defined, the getObject () method returns a stdClass combining the header as an association to the data of each line. Example:


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



If you find any incorrect English grammar or any suggestions on how to improve the library, I appreciate it.