// ------------------------------- // 5. Footer (Tanda Tangan & Info) // ------------------------------- $footerRow = $row + 12; $sheet->setCellValue("G$footerRow", 'Kepala Desa/Lurah,'); $footerRow++; $sheet->setCellValue("G$footerRow", '_________________________'); $footerRow++; $sheet->setCellValue("G$footerRow", '(Nama jelas & stempel)');
// ------------------------------- // 3. Table Header: Anggota Keluarga // ------------------------------- $row = 8; $headers = [ 'NO', 'NIK', 'NAMA LENGKAP', 'JENIS KELAMIN', 'TEMPAT LAHIR', 'TANGGAL LAHIR', 'HUBUNGAN KELUARGA', 'KETERANGAN' ]; $col = 'A'; foreach ($headers as $header) $sheet->setCellValue($col . $row, $header); $sheet->getStyle($col . $row)->getFont()->setBold(true); $sheet->getStyle($col . $row)->getAlignment()->setHorizontal(Alignment::HORIZONTAL_CENTER); $sheet->getStyle($col . $row)->getFill()->setFillType(Fill::FILL_SOLID)->getStartColor()->setARGB('FFD9E1F2'); $col++;
wb.save("Blangko_KK_Kosong.xlsx") <button onclick="downloadKK()">📥 Download Blangko KK Kosong (Excel)</button> <script> function downloadKK() window.location.href = 'download_kk_blank.php'; Download Blangko Kartu Keluarga Kosong Excel
$row++; $sheet->setCellValue("A$row", 'Alamat:'); $sheet->setCellValue("B$row", '_________________________'); $sheet->mergeCells("B$row:H$row");
$row++; $sheet->setCellValue("A$row", 'Kab/Kota:'); $sheet->setCellValue("B$row", ' '); $sheet->setCellValue("D$row", 'Provinsi:'); $sheet->setCellValue("E$row", ' '); $sheet->setCellValue("G$row", 'Kode Pos:'); $sheet->setCellValue("H$row", '_____'); // ------------------------------- // 5
// ------------------------------- // 2. Kepala Keluarga Info // ------------------------------- $row = 4; $sheet->setCellValue("A$row", 'Nama Kepala Keluarga:'); $sheet->setCellValue("B$row", '_________________________'); $sheet->mergeCells("B$row:H$row"); $sheet->getStyle("A$row")->getFont()->setBold(true);
// Set title $sheet->setTitle('Blangko KK'); $row, $header); $sheet->getStyle($col
// Create new Spreadsheet $spreadsheet = new Spreadsheet(); $sheet = $spreadsheet->getActiveSheet();
Name: Download Blangko Kartu Keluarga Kosong (Excel) Purpose: Provide an empty KK form template with official-like structure (header, family member table, columns for NIK, name, status, birth details, etc.). Output: .xlsx file ready for users to fill. 2. Implementation (PHP + PhpSpreadsheet) Step 1: Install PhpSpreadsheet composer require phpoffice/phpspreadsheet Step 2: Create Download Script ( download_kk_blank.php ) <?php require 'vendor/autoload.php'; use PhpOffice\PhpSpreadsheet\Spreadsheet; use PhpOffice\PhpSpreadsheet\Writer\Xlsx; use PhpOffice\PhpSpreadsheet\Style\Alignment; use PhpOffice\PhpSpreadsheet\Style\Border; use PhpOffice\PhpSpreadsheet\Style\Fill;
$sheet->getStyle("A$dataRow:H$dataRow")->getBorders()->getAllBorders()->setBorderStyle(Border::BORDER_THIN);