Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
SimoTod authored Aug 31, 2018
1 parent 8ddc542 commit d9f8d70
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,10 @@ class ExampleSerialiser implements SerialiserInterface
}
}
```
then set the serialiser before saving the file the collection.
```
$collection = Exporter::make('Excel')->load($yourCollection)->setSerialiser(new ExampleSerialiser)->stream($yourFileName);
```

## Import Excel
Add
Expand Down Expand Up @@ -175,9 +179,9 @@ namespace App\Parsers;
use App\Models\YourModel;
use Cyberduck\LaravelExcel\Contract\ParserInterface;
class ExampleSerialiser implements ParserInterface
class ExampleParser implements ParserInterface
{
public function transform($row)
public function transform($row, $header)
{
$model = new YourModel();
$model->field1 = $row[0];
Expand All @@ -188,6 +192,10 @@ class ExampleSerialiser implements ParserInterface
}
}
```
then set the parser before creating the collection.
```
$collection = Importer::make('Excel')->load($filepath)->setParser(new ExampleParser)->getCollection();
```

## Different formats
The package supports ODS and CSV files.
Expand Down

0 comments on commit d9f8d70

Please sign in to comment.