Download Blangko Kartu Keluarga Kosong Excel (TRUSTED × 2024)

// Set title $sheet->setTitle('Blangko KK');

// Create new Spreadsheet $spreadsheet = new Spreadsheet(); $sheet = $spreadsheet->getActiveSheet();

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';

// ------------------------------- // 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++; Download Blangko Kartu Keluarga Kosong Excel

$sheet->mergeCells('A2:H2'); $sheet->setCellValue('A2', 'KELUARGA INTI / KELUARGA LAINNYA'); $sheet->getStyle('A2')->getFont()->setItalic(true); $sheet->getStyle('A2')->getAlignment()->setHorizontal(Alignment::HORIZONTAL_CENTER);

// ------------------------------- // 4. Empty Rows (for 10 family members) // ------------------------------- for ($i = 1; $i <= 10; $i++) $dataRow = $row + $i; $sheet->setCellValue("A$dataRow", $i); for ($colIdx = 'B'; $colIdx <= 'H'; $colIdx++) $sheet->setCellValue($colIdx . $dataRow, '');

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; $filename . '"')

// ------------------------------- // 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)');

// Auto-size columns foreach (range('A', 'H') as $col) $sheet->getColumnDimension($col)->setAutoSize(true);

$sheet->getStyle("A$dataRow:H$dataRow")->getBorders()->getAllBorders()->setBorderStyle(Border::BORDER_THIN); '____ / ____')

// ------------------------------- // 6. Output File // ------------------------------- $filename = 'Blangko_KK_Kosong_' . date('Ymd') . '.xlsx'; header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'); header('Content-Disposition: attachment;filename="' . $filename . '"'); header('Cache-Control: max-age=0');

$row++; $sheet->setCellValue("A$row", 'RT/RW:'); $sheet->setCellValue("B$row", '____ / ____'); $sheet->setCellValue("D$row", 'Kel/Desa:'); $sheet->setCellValue("E$row", ' '); $sheet->setCellValue("G$row", 'Kecamatan:'); $sheet->setCellValue("H$row", ' ');