EN FR
← Packages

jdz/importer

Spreadsheet import (xlsx / csv / ods)

Overview

Spreadsheet import (xlsx / csv / ods) built on PhpSpreadsheet — the counterpart of jdz/exporter. Reads the active worksheet of an uploaded file into field-keyed rows: the first row is the header, and each value is coerced to its column type.

Features

  • Formats: xlsx, csv, ods — the active worksheet is read
  • Header labels become the field names by default
  • Subclass getColumns() to map the sheet onto your own fields, types and defaults
  • Coercions: string / int / bool (1 or X) / url (forces https://) / date (dd/mm/yyyy and dd-mm-yyyy → Y-m-d)
  • One call: $rows = (new Importer())->parse('/tmp/upload.xlsx')

Installation

composer require jdz/importer