コード例 #1
0
ファイル: buku.blade.php プロジェクト: udibagas/digilib
<?php

header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
header('Content-Disposition: attachment;filename="data buku.xlsx"');
header('Cache-Control: max-age=0');
// objek
$excel = new Excel();
$sheet = $excel->getActiveSheet();
// properti
$excel->getProperties()->setCreator('Heru Rusdianto')->setLastModifiedBy('Heru Rusdianto')->setTitle('Data Buku')->setSubject('Data Buku')->setDescription('Data Buku ' . $sekolah->nama);
// font
$excel->getDefaultStyle()->getFont()->setName('Helvetica Neue')->setSize(12);
// page setup
$sheet->getPageSetup()->setHorizontalCentered(true)->setPaperSize(PHPExcel_Worksheet_PageSetup::PAPERSIZE_A4)->setRowsToRepeatAtTopByStartAndEnd(5, 5);
// grid lines
$sheet->setShowGridlines(false);
// margins
$sheet->getPageMargins()->setTop(1)->setRight(0.75)->setLeft(0.75)->setBottom(1);
// nama sheet
$sheet->setTitle(date('d-m-Y'));
// logo
$nama_logo = $sekolah->logo ?: 'blank.png';
$logo = public_path() . '/foto/sekolah/' . $nama_logo;
// tambah logo
$draw = new PHPExcel_Worksheet_Drawing();
$draw->setName('Logo');
$draw->setDescription('Logo ' . $sekolah->nama);
$draw->setPath($logo);
$draw->setHeight(95);
$draw->setWorksheet($sheet);
// nama sekolah dan judul