FAQ
1. Bagaimana mendapatkan string kolom, dari angka ?
use PhpOffice\PhpSpreadsheet\Cell\Coordinate;
Coordinate::stringFromColumnIndex(1);
Untuk informasi lebih lanjut lihat disini.
2. style dan protection (todo : perlu dilengkapi )
$styleArray = [
'font' => [
'bold' => true,
'size' => 12
],
'alignment' => [
'horizontal' => \PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_RIGHT,
],
'borders' => [
//opsinya bisa : left, right, top, bottom, diagonal, allBorders, outline, inside, vertical, horizontal
'top' => [
'borderStyle' => \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_THIN,
],
],
'fill' => [
'fillType' => \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_GRADIENT_LINEAR,
'rotation' => 90,
'startColor' => [
'argb' => 'FFA0A0A0',
],
'endColor' => [
'argb' => 'FFFFFFFF',
],
],
];
$spreadsheet->getActiveSheet()->getStyle('A3')->applyFromArray($styleArray);
$spreadsheet->getActiveSheet()->getColumnDimension('D')->setWidth(12);
$spreadsheet->getActiveSheet()->getColumnDimension('B')->setAutoSize(true);
$spreadsheet->getActiveSheet() ->getProtection()->setSheet(true);
$spreadsheet->getActiveSheet()->getStyle('B1') ->getProtection() ->setLocked(\PhpOffice\PhpSpreadsheet\Style\Protection::PROTECTION_UNPROTECTED);
Untuk informasi lebih lanjut : Styling cell borders, Setting a column's width, Setting security on a spreadsheet
3. freezePane
$sheet->freezePaneByColumnAndRow(4,4);
Untuk informasi lebih lanjut : Freeze Panes
4. Membaca File
Untuk informasi lebih lanjut Reading Files
5. Menulis File
Untuk informasi lebih lanjut Writing a spreadsheet, Generating Excel Using PhpSpreadsheet in PHP
6. Merge/Unmerge Cells
$spreadsheet->getActiveSheet()->mergeCells('A18:E22');
$spreadsheet->getActiveSheet()->unmergeCells('A18:E22');
7. Membaca Images
Referensi
- A pure PHP library for reading and writing spreadsheet files https://phpspreadsheet.readthedocs.io
- PhpSpreadsheet samples, https://github.com/PHPOffice/PhpSpreadsheet/tree/master/samples
- Reading Images from a worksheet, https://phpspreadsheet.readthedocs.io/en/latest/topics/recipes/#reading-images-from-a-worksheet
- Reading Images from Excel, https://stackoverflow.com/questions/52344718/reading-images-from-excel