Commit d01c49bb by hannan

laravel excel changes

parent 691029d2
......@@ -15,10 +15,13 @@ use Maatwebsite\Excel\Concerns\Exportable;
use Maatwebsite\Excel\Concerns\FromCollection;
use Maatwebsite\Excel\Concerns\FromView;
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 DepartmentExport implements FromView, ShouldAutoSize
class DepartmentExport implements FromView, ShouldAutoSize, WithColumnWidths, WithStyles
{
use Exportable;
......@@ -33,6 +36,27 @@ class DepartmentExport implements FromView, ShouldAutoSize
/**
* @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
{
// dd($this->request);
......
......@@ -11,10 +11,13 @@ use Maatwebsite\Excel\Concerns\Exportable;
use Maatwebsite\Excel\Concerns\FromCollection;
use Maatwebsite\Excel\Concerns\FromView;
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 ProjectExport implements FromView, ShouldAutoSize
class ProjectExport implements FromView, ShouldAutoSize, WithColumnWidths, WithStyles
{
use Exportable;
......@@ -29,6 +32,43 @@ class ProjectExport implements FromView, ShouldAutoSize
/**
* @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
{
// dd($this->request);
......
......@@ -16,10 +16,11 @@ use Maatwebsite\Excel\Concerns\Exportable;
use Maatwebsite\Excel\Concerns\FromCollection;
use Maatwebsite\Excel\Concerns\FromView;
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
use Maatwebsite\Excel\Concerns\WithColumnWidths;
// class UsersExport implements FromCollection, Responsable
class RingkasanExport implements FromView, ShouldAutoSize
class RingkasanExport implements ShouldAutoSize, FromView, WithColumnWidths
{
use Exportable;
......@@ -34,6 +35,19 @@ class RingkasanExport implements FromView, ShouldAutoSize
/**
* @return \Illuminate\Support\Collection
*/
public function columnWidths(): array
{
return [
'A' => 5,
'B' => 12,
'D' => 50,
'H' => 12,
'I' => 12
];
}
public function view(): View
{
// dd(VwStaff::all());
......
......@@ -15,12 +15,12 @@
<table>
<thead>
<tr>
<th>staff</th>
<th>project type</th>
<th>project code / task</th>
<th>description</th>
<th>total hours</th>
<th>total days</th>
<th>{{strtoupper('staff')}}</th>
<th>{{strtoupper('project type')}}</th>
<th>{{strtoupper('project code / task')}}</th>
<th>{{strtoupper('description')}}</th>
<th>{{strtoupper('total hours')}}</th>
<th>{{strtoupper('total days')}}</th>
</tr>
</thead>
<?php $totalhours = $totaldays = $staffhours = $staffdays = 0; ?>
......
......@@ -21,12 +21,12 @@
<tr>
<th style="width: 10%">Project </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>
<th style="width: 10%"> Month/Year</th>
<th style="width: 1%">:</th>
<th colspan="3"> {{$month}} {{$year}}</th>
<th colspan="2"> {{$month}} {{$year}}</th>
</tr>
</thead>
</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