brainy8872
brainy8872

Reputation: 43

How to map dynamic excel rows to sql database columns

I am trying to import an excel using Laravel with dynamically changing columns(names as well as sequence) . I am looking for a way to map these columns against Sql db columns.

Upvotes: 1

Views: 185

Answers (1)

Mudassar Zahid
Mudassar Zahid

Reputation: 11

Please share your code for clarification;

you can use this package to import and change dynamically in callback;

https://github.com/rap2hpoutre/fast-excel

$users = (new FastExcel)->import('file.xlsx', function ($line) {
    //here you can perform custom action on your data
    return User::create([
        'name' => $line['Name'],
        'email' => $line['Email']
    ]);
});

Upvotes: 1

Related Questions