Skip to content

Load data from a Excel sheet or plain array, and apply a number of different mapper functions to selected columns.

License

Notifications You must be signed in to change notification settings

ephort/sheetmapper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Packagist Downloads Code size

SheetMapper

SheetMapper provides functionality to load data from Excel sheet or plain array and apply a number of different mapper functions to selected columns.

You only need to provide a SplFileInfo object as source.

Both Illuminate\Http\File and Symfony\Component\HttpFoundation\File\File extends this native PHP class.

Installation

composer require justiversen/sheetmapper

Usage examples

Provide a plain PHP array of items to map.

    $data = (new \JustIversen\SheetMapper\SheetMapper)
        ->source($inputArray)
        ->modifyHeaders([
            'name in file' => 'component_name',
            'stkpris' => 'component_price',
            'beskrivelse' => 'component_description',
        ])
        ->toLower()
        ->numberToFloat(['measurement_amount'])
        ->get();

Or provide a SplFileInfo Excel file to map. Here we use Laravel's default request()->file

    $data = (new \JustIversen\SheetMapper\SheetMapper)
        ->source(request()->file)
        ->modifyHeaders([
            'name in file' => 'component_name',
            'stkpris' => 'component_price',
            'beskrivelse' => 'component_description',
        ])
        ->concat(['component_name', 'component_price'], '-', 'concatted_column')
        ->checkForNull()
        ->trim()
        ->get();

Contributers

License

The MIT License (MIT). Please see License File for more information.

About

Load data from a Excel sheet or plain array, and apply a number of different mapper functions to selected columns.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages