@@ -48,13 +48,13 @@ php artisan migrate
48
48
49
49
1 . Add the export-button livewire component on your view file that uses dataTable class.
50
50
51
- ``` phpt
51
+ ``` php
52
52
<livewire:export-button :table-id =" $dataTable->getTableId()" />
53
53
```
54
54
55
55
2 . On your ` DataTable ` class, use ` WithExportQueue `
56
56
57
- ``` phpt
57
+ ``` php
58
58
use Yajra\DataTables\WithExportQueue;
59
59
60
60
class PermissionsDataTable extends DataTable
@@ -71,15 +71,15 @@ class PermissionsDataTable extends DataTable
71
71
72
72
On ` app\Console\Kernel.php ` , register the purge command
73
73
74
- ``` phpt
74
+ ``` php
75
75
$schedule->command('datatables:purge-export')->weekly();
76
76
```
77
77
78
78
## Export Filename
79
79
80
80
You can set the export filename by setting the property.
81
81
82
- ``` phpt
82
+ ``` php
83
83
<livewire:export-button :table-id =" $dataTable->getTableId()" filename =" my-table.xlsx" />
84
84
<livewire:export-button :table-id =" $dataTable->getTableId()" filename =" my-table.csv" />
85
85
@@ -90,7 +90,7 @@ You can set the export filename by setting the property.
90
90
91
91
You can set the export type by setting the property to ` csv ` or ` xlsx ` . Default value is ` xlsx ` .
92
92
93
- ``` phpt
93
+ ``` php
94
94
<livewire:export-button :table-id =" $dataTable->getTableId()" type =" xlsx" />
95
95
<livewire:export-button :table-id =" $dataTable->getTableId()" type =" csv" />
96
96
```
@@ -99,7 +99,7 @@ You can set the export type by setting the property to `csv` or `xlsx`. Default
99
99
100
100
You can format the column by setting it via Column definition on you DataTable service class.
101
101
102
- ``` phpt
102
+ ``` php
103
103
Column::make('mobile')->exportFormat('00000000000'),
104
104
```
105
105
@@ -109,7 +109,7 @@ The format above will treat mobile numbers as text with leading zeroes.
109
109
110
110
The package will auto-detect numeric fields and can be used with custom formats.
111
111
112
- ``` phpt
112
+ ``` php
113
113
Column::make('total')->exportFormat('0.00'),
114
114
Column::make('count')->exportFormat('#,##0'),
115
115
Column::make('average')->exportFormat('#,##0.00),
@@ -119,7 +119,7 @@ Column::make('average')->exportFormat('#,##0.00),
119
119
120
120
The package will auto-detect date fields when used with a valid format or is a DateTime instance.
121
121
122
- ``` phpt
122
+ ``` php
123
123
Column::make('report_date')->exportFormat('mm/dd/yyyy'),
124
124
Column::make('created_at'),
125
125
Column::make('updated_at')->exportFormat(NumberFormat::FORMAT_DATE_DATETIME),
@@ -129,7 +129,7 @@ Column::make('updated_at')->exportFormat(NumberFormat::FORMAT_DATE_DATETIME),
129
129
130
130
Valid date formats can be adjusted on ` datatables-export.php ` config file.
131
131
132
- ``` phpt
132
+ ``` php
133
133
'date_formats' => [
134
134
'mm/dd/yyyy',
135
135
NumberFormat::FORMAT_DATE_DATETIME,
0 commit comments