Commit 77b02def by 孙龙

excel合同

parent a75fe939
<?php
namespace App\Exports;
use Illuminate\Contracts\View\View;
use Maatwebsite\Excel\Concerns\FromView;
use Maatwebsite\Excel\Concerns\WithColumnWidths;
use Maatwebsite\Excel\Concerns\WithDefaultStyles;
use Maatwebsite\Excel\Concerns\WithEvents;
use Maatwebsite\Excel\Events\AfterSheet;
use PhpOffice\PhpSpreadsheet\Style\Alignment;
use PhpOffice\PhpSpreadsheet\Style\Style;
class ContractCIExport implements FromView, WithColumnWidths, WithDefaultStyles, WithEvents
{
private $order_info;
private $order_item_num;
public function __construct($data=[])
{
$this->data=$data;
}
public function view(): View
{
return view('export.order_contract_CI', [
"ship"=>$this->data["ship"],
"bill"=>$this->data["bill"],
"info"=>$this->data["info"],
]);
}
public function columnWidths(): array
{
return [
'A' => 14,
'B' => 17,
'C' => 14,
'D' => 17,
'E' => 12,
'F' => 12,
'G' => 10,
'H' => 10,
'I' => 10,
];
}
public function defaultStyles(Style $defaultStyle)
{
return $defaultStyle->getFont()->setSize(8);
}
public function registerEvents(): array
{
return [
AfterSheet::class => function (AfterSheet $event) {
// $cellRange = $this->specific_cells;
// foreach ($cellRange as $cell) {
// // 单个单元格设置格式
// $event->sheet->getDelegate()->getStyle($cell)->getNumberFormat()->setFormatCode('0.000000');
// }
// 垂直居中
// $last_line = $this->order_item_num + 8; // 最后行 = 明细数量 + (起始行 - 1)
// $event->sheet->getDelegate()->getStyle('A9:I' . $last_line)->getAlignment()->setVertical(Alignment::VERTICAL_CENTER);
}
];
}
}
<?php
namespace App\Exports;
use Illuminate\Contracts\View\View;
use Maatwebsite\Excel\Concerns\FromView;
use Maatwebsite\Excel\Concerns\WithColumnWidths;
use Maatwebsite\Excel\Concerns\WithDefaultStyles;
use Maatwebsite\Excel\Concerns\WithEvents;
use Maatwebsite\Excel\Events\AfterSheet;
use PhpOffice\PhpSpreadsheet\Style\Alignment;
use PhpOffice\PhpSpreadsheet\Style\Style;
class ContractPIExport implements FromView, WithColumnWidths, WithDefaultStyles, WithEvents
{
private $order_info;
private $order_item_num;
public function __construct($data=[])
{
$this->data=$data;
}
public function view(): View
{
return view('export.order_contract_PI', [
"ship"=>$this->data["ship"],
"bill"=>$this->data["bill"],
"info"=>$this->data["info"],
]);
}
public function columnWidths(): array
{
return [
'A' => 14,
'B' => 17,
'C' => 14,
'D' => 17,
'E' => 16,
'F' => 16,
'G' => 10,
'H' => 10,
'I' => 10,
];
}
public function defaultStyles(Style $defaultStyle)
{
return $defaultStyle->getFont()->setSize(8);
}
public function registerEvents(): array
{
return [
AfterSheet::class => function (AfterSheet $event) {
// $cellRange = $this->specific_cells;
// foreach ($cellRange as $cell) {
// // 单个单元格设置格式
// $event->sheet->getDelegate()->getStyle($cell)->getNumberFormat()->setFormatCode('0.000000');
// }
// 垂直居中
// $last_line = $this->order_item_num + 8; // 最后行 = 明细数量 + (起始行 - 1)
// $event->sheet->getDelegate()->getStyle('A9:I' . $last_line)->getAlignment()->setVertical(Alignment::VERTICAL_CENTER);
}
];
}
}
<?php
namespace App\Exports;
use Illuminate\Contracts\View\View;
use Maatwebsite\Excel\Concerns\FromView;
use Maatwebsite\Excel\Concerns\WithColumnWidths;
use Maatwebsite\Excel\Concerns\WithDefaultStyles;
use Maatwebsite\Excel\Concerns\WithEvents;
use Maatwebsite\Excel\Events\AfterSheet;
use PhpOffice\PhpSpreadsheet\Style\Alignment;
use PhpOffice\PhpSpreadsheet\Style\Style;
class ContractPLExport implements FromView, WithColumnWidths, WithDefaultStyles, WithEvents
{
private $order_info;
private $order_item_num;
public function __construct($data=[])
{
$this->order_info=[];
}
public function view(): View
{
return view('export.order_contract_PL', $this->order_info);
}
public function columnWidths(): array
{
return [
'A' => 10,
'B' => 23,
'C' => 22,
'D' => 10,
'E' => 23,
'F' => 10,
'G' => 12,
'H' => 12,
'I' => 15,
'J' => 15,
'K' => 15,
];
}
public function defaultStyles(Style $defaultStyle)
{
return $defaultStyle->getFont()->setSize(8);
}
public function registerEvents(): array
{
return [
AfterSheet::class => function (AfterSheet $event) {
// $cellRange = $this->specific_cells;
// foreach ($cellRange as $cell) {
// // 单个单元格设置格式
// $event->sheet->getDelegate()->getStyle($cell)->getNumberFormat()->setFormatCode('0.000000');
// }
// 垂直居中
// $last_line = $this->order_item_num + 8; // 最后行 = 明细数量 + (起始行 - 1)
// $event->sheet->getDelegate()->getStyle('A9:I' . $last_line)->getAlignment()->setVertical(Alignment::VERTICAL_CENTER);
}
];
}
}
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 sign in to comment