Commit d01c49bb by hannan

laravel excel changes

parent 691029d2
...@@ -15,10 +15,13 @@ use Maatwebsite\Excel\Concerns\Exportable; ...@@ -15,10 +15,13 @@ use Maatwebsite\Excel\Concerns\Exportable;
use Maatwebsite\Excel\Concerns\FromCollection; use Maatwebsite\Excel\Concerns\FromCollection;
use Maatwebsite\Excel\Concerns\FromView; use Maatwebsite\Excel\Concerns\FromView;
use Maatwebsite\Excel\Concerns\ShouldAutoSize; use Maatwebsite\Excel\Concerns\ShouldAutoSize;
use Maatwebsite\Excel\Concerns\WithColumnWidths;
use Maatwebsite\Excel\Concerns\WithStyles;
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
// class UsersExport implements FromCollection, Responsable // class UsersExport implements FromCollection, Responsable
class DepartmentExport implements FromView, ShouldAutoSize class DepartmentExport implements FromView, ShouldAutoSize, WithColumnWidths, WithStyles
{ {
use Exportable; use Exportable;
...@@ -33,6 +36,27 @@ class DepartmentExport implements FromView, ShouldAutoSize ...@@ -33,6 +36,27 @@ class DepartmentExport implements FromView, ShouldAutoSize
/** /**
* @return \Illuminate\Support\Collection * @return \Illuminate\Support\Collection
*/ */
public function styles(Worksheet $sheet)
{
$sheet->getStyle('1')->getFont()->setBold(true);
$sheet->getStyle('2')->getFont()->setBold(true);
$sheet->getStyle('4')->getFont()->setBold(true);
}
public function columnWidths(): array
{
return [
'A' => 50,
'B' => 20,
'C' => 20,
'D' => 20,
'E' => 20,
'F' => 20
];
}
public function view(): View public function view(): View
{ {
// dd($this->request); // dd($this->request);
......
...@@ -11,10 +11,13 @@ use Maatwebsite\Excel\Concerns\Exportable; ...@@ -11,10 +11,13 @@ use Maatwebsite\Excel\Concerns\Exportable;
use Maatwebsite\Excel\Concerns\FromCollection; use Maatwebsite\Excel\Concerns\FromCollection;
use Maatwebsite\Excel\Concerns\FromView; use Maatwebsite\Excel\Concerns\FromView;
use Maatwebsite\Excel\Concerns\ShouldAutoSize; use Maatwebsite\Excel\Concerns\ShouldAutoSize;
use Maatwebsite\Excel\Concerns\WithColumnWidths;
use Maatwebsite\Excel\Concerns\WithStyles;
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
// class UsersExport implements FromCollection, Responsable // class UsersExport implements FromCollection, Responsable
class ProjectExport implements FromView, ShouldAutoSize class ProjectExport implements FromView, ShouldAutoSize, WithColumnWidths, WithStyles
{ {
use Exportable; use Exportable;
...@@ -29,6 +32,43 @@ class ProjectExport implements FromView, ShouldAutoSize ...@@ -29,6 +32,43 @@ class ProjectExport implements FromView, ShouldAutoSize
/** /**
* @return \Illuminate\Support\Collection * @return \Illuminate\Support\Collection
*/ */
public function styles(Worksheet $sheet)
{
$sheet->getStyle('1')->getFont()->setBold(true);
$sheet->getStyle('2')->getFont()->setBold(true);
$sheet->getStyle('4')->getFont()->setBold(true);
}
// public function styles(Worksheet $sheet)
// {
// return [
// // Style the first row as bold text.
// '1' => ['font' => ['bold' => true]],
// '2' => ['font' => ['bold' => true]],
// '4' => ['font' => ['bold' => true]],
// '10' => ['font' => ['bold' => true]]
// // Styling a specific cell by coordinate.
// // 'B2' => ['font' => ['italic' => true]],
// // Styling an entire column.
// // 'C' => ['font' => ['size' => 16]],
// ];
// }
public function columnWidths(): array
{
return [
'A' => 50,
'B' => 20,
'C' => 15,
'D' => 15
];
}
public function view(): View public function view(): View
{ {
// dd($this->request); // dd($this->request);
......
...@@ -16,10 +16,11 @@ use Maatwebsite\Excel\Concerns\Exportable; ...@@ -16,10 +16,11 @@ use Maatwebsite\Excel\Concerns\Exportable;
use Maatwebsite\Excel\Concerns\FromCollection; use Maatwebsite\Excel\Concerns\FromCollection;
use Maatwebsite\Excel\Concerns\FromView; use Maatwebsite\Excel\Concerns\FromView;
use Maatwebsite\Excel\Concerns\ShouldAutoSize; use Maatwebsite\Excel\Concerns\ShouldAutoSize;
use Maatwebsite\Excel\Concerns\WithColumnWidths;
// class UsersExport implements FromCollection, Responsable // class UsersExport implements FromCollection, Responsable
class RingkasanExport implements FromView, ShouldAutoSize class RingkasanExport implements ShouldAutoSize, FromView, WithColumnWidths
{ {
use Exportable; use Exportable;
...@@ -34,6 +35,19 @@ class RingkasanExport implements FromView, ShouldAutoSize ...@@ -34,6 +35,19 @@ class RingkasanExport implements FromView, ShouldAutoSize
/** /**
* @return \Illuminate\Support\Collection * @return \Illuminate\Support\Collection
*/ */
public function columnWidths(): array
{
return [
'A' => 5,
'B' => 12,
'D' => 50,
'H' => 12,
'I' => 12
];
}
public function view(): View public function view(): View
{ {
// dd(VwStaff::all()); // dd(VwStaff::all());
......
...@@ -15,12 +15,12 @@ ...@@ -15,12 +15,12 @@
<table> <table>
<thead> <thead>
<tr> <tr>
<th>staff</th> <th>{{strtoupper('staff')}}</th>
<th>project type</th> <th>{{strtoupper('project type')}}</th>
<th>project code / task</th> <th>{{strtoupper('project code / task')}}</th>
<th>description</th> <th>{{strtoupper('description')}}</th>
<th>total hours</th> <th>{{strtoupper('total hours')}}</th>
<th>total days</th> <th>{{strtoupper('total days')}}</th>
</tr> </tr>
</thead> </thead>
<?php $totalhours = $totaldays = $staffhours = $staffdays = 0; ?> <?php $totalhours = $totaldays = $staffhours = $staffdays = 0; ?>
......
...@@ -21,12 +21,12 @@ ...@@ -21,12 +21,12 @@
<tr> <tr>
<th style="width: 10%">Project </th> <th style="width: 10%">Project </th>
<th style="width: 1%">:</th> <th style="width: 1%">:</th>
<th colspan="3"> {{data_get($pdetail,'pcode')}} - {{data_get($pdetail,'pname')}}</th> <th colspan="2"> {{data_get($pdetail,'pcode')}} - {{data_get($pdetail,'pname')}}</th>
</tr> </tr>
<tr> <tr>
<th style="width: 10%"> Month/Year</th> <th style="width: 10%"> Month/Year</th>
<th style="width: 1%">:</th> <th style="width: 1%">:</th>
<th colspan="3"> {{$month}} {{$year}}</th> <th colspan="2"> {{$month}} {{$year}}</th>
</tr> </tr>
</thead> </thead>
</table> </table>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment