Skip to content

Commit 6ccfdea

Browse files
committed
doc updated
1 parent bb4ac7a commit 6ccfdea

File tree

1 file changed

+28
-2
lines changed

1 file changed

+28
-2
lines changed

README.md

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,38 @@ composer require sujan/php-csv-exporter
1414
All you have to do is to pass the **Query Builder**
1515

1616

17-
`use Sujan\Exporter\Export
17+
`use Sujan\Exporter\Exporter;
1818
`
1919
```$xslt
2020
$columns = [
2121
'id',
2222
'name',
2323
'email'
2424
];
25-
25+
```
26+
###### From Query Builder (RECOMMENDED)
27+
```
2628
$queryBuilder = User::query(); // Query builder
29+
// $queryBuilder = User::where('email', '[email protected]'); // Query builder
2730
2831
Exporter::init($queryBuilder, $columns, 'users.csv');
32+
// Exporter::init($queryBuilder, $columns, 'users.xlsx'); // For ExcelSheet export
33+
Exporter::export();
34+
```
35+
36+
###### From Collection
37+
```
38+
$usersCollection = User::all(); // Collection
39+
40+
Exporter::init($usersCollection, $columns, 'users.csv');
41+
Exporter::export();
42+
```
43+
44+
###### From Array
45+
```
46+
$usersArray = User::latest()->get()->toArray(); // Array
47+
48+
Exporter::init($usersArray, $columns, 'users.csv');
2949
Exporter::export();
3050
```
3151

@@ -87,4 +107,10 @@ And then pass the `$stmt` to `Exporter`
87107
$conn = null;
88108
```
89109

110+
## XLSX export
111+
Just use the file extension as `.xlsx`
112+
```
113+
Exporter::init($queryBuilder, $columns, 'users.xlsx');
114+
```
115+
90116
## You are always welcome to contribute

0 commit comments

Comments
 (0)