コード例 #1
0
ファイル: ExcelHelper.php プロジェクト: jocoonopa/lubri
 /**
  * Layout
  *
  * 'A' => 暫時編號
  * 'B' => 會員編號
  * 'C' => 開發人員姓名
  * 'D' => 客戶姓名
  * 'E' => 客戶電話
  * 'F' => 客戶地址
  * 'G' => 紅利
  * 'H' => 備註
  * 
  * @param  Maatwebsite\Excel\Facades\Excel $excel
  * @return $sheet
  */
 public static function initExcel(\Maatwebsite\Excel\Writers\LaravelExcelWriter $excel)
 {
     $returnSheet = NULL;
     $excel->setTitle(ExportExcel::M64_TITLE)->setCreator(ExportExcel::CREATOR)->setCompany(ExportExcel::COMPANY);
     $excel->sheet('表格1', self::getInitCallback($returnSheet));
     return $returnSheet;
 }
コード例 #2
0
 protected function addSheet(LaravelExcelWriter $excel, string $name, Collection $fragments)
 {
     $excel->sheet($name, function ($sheet) use($fragments) {
         $sheet->freezeFirstRow();
         $sheet->cells('A1:Z1', function ($cells) {
             $cells->setFontWeight('bold');
             $cells->setBorder('node', 'none', 'solid', 'none');
         });
         $rowCounter = 1;
         $sheet->row($rowCounter++, $this->getHeaderColumns());
         foreach ($fragments as $fragment) {
             $fragmentProperties = [$fragment['group'], $fragment['key'], $fragment['contains_html'] ? 0 : 1, $fragment['description']];
             $translatedFragmentProperties = locales()->map(function (string $locale) use($fragment) {
                 return $fragment->getTranslation($locale);
             })->toArray();
             $sheet->row($rowCounter++, array_merge($fragmentProperties, $translatedFragmentProperties));
         }
     });
 }