File tree Expand file tree Collapse file tree 1 file changed +28
-2
lines changed Expand file tree Collapse file tree 1 file changed +28
-2
lines changed Original file line number Diff line number Diff line change @@ -14,18 +14,38 @@ composer require sujan/php-csv-exporter
14
14
All you have to do is to pass the ** Query Builder**
15
15
16
16
17
- `use Sujan\Exporter\Export
17
+ `use Sujan\Exporter\Exporter;
18
18
`
19
19
``` $xslt
20
20
$columns = [
21
21
'id',
22
22
'name',
23
23
'email'
24
24
];
25
-
25
+ ```
26
+ ###### From Query Builder (RECOMMENDED)
27
+ ```
26
28
$queryBuilder = User::query(); // Query builder
29
+ // $queryBuilder = User::where('email', '[email protected] '); // Query builder
27
30
28
31
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');
29
49
Exporter::export();
30
50
```
31
51
@@ -87,4 +107,10 @@ And then pass the `$stmt` to `Exporter`
87
107
$conn = null;
88
108
```
89
109
110
+ ## XLSX export
111
+ Just use the file extension as ` .xlsx `
112
+ ```
113
+ Exporter::init($queryBuilder, $columns, 'users.xlsx');
114
+ ```
115
+
90
116
## You are always welcome to contribute
You can’t perform that action at this time.
0 commit comments