Contract reference text format inside exported excel
This commit is contained in:
@@ -11,11 +11,14 @@
|
||||
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||
use Maatwebsite\Excel\Concerns\WithMapping;
|
||||
use PhpOffice\PhpSpreadsheet\Shared\Date as ExcelDate;
|
||||
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
|
||||
|
||||
class SegmentContractsExport implements FromQuery, ShouldAutoSize, WithColumnFormatting, WithHeadings, WithMapping
|
||||
{
|
||||
public const DATE_EXCEL_FORMAT = 'dd"."mm"."yyyy';
|
||||
|
||||
public const TEXT_EXCEL_FORMAT = NumberFormat::FORMAT_TEXT;
|
||||
|
||||
/**
|
||||
* @var array<string, array{label: string}>
|
||||
*/
|
||||
@@ -76,8 +79,16 @@ public function columnFormats(): array
|
||||
$formats = [];
|
||||
|
||||
foreach ($this->columns as $index => $column) {
|
||||
$letter = $this->columnLetter($index);
|
||||
|
||||
if ($column === 'reference') {
|
||||
$formats[$letter] = self::TEXT_EXCEL_FORMAT;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if (in_array($column, ['start_date', 'end_date'], true)) {
|
||||
$formats[$this->columnLetter($index)] = self::DATE_EXCEL_FORMAT;
|
||||
$formats[$letter] = self::DATE_EXCEL_FORMAT;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user