loadMembers(); $spreadsheet = new Spreadsheet(); $sheet = $spreadsheet->getActiveSheet(); $columnHeaders = ['Nachname', 'Vorname', 'Straße', 'Plz', 'Ort', 'Geburtsdatum', 'Telefon', 'Mitgliedsbeitrag', 'Bank', 'IBAN', 'BIC', 'Kontoinhaber', 'Status der Mitgliedschaft', 'Start der Mitgliedschaft', 'Letzte Zahlung', 'Position' ]; $sheet->fromArray([$columnHeaders], null, 'A1'); $sheet->fromArray($members, null, 'A2'); $writer = new Xlsx($spreadsheet); header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'); header('Content-Disposition: attachment;filename="excel_file.xlsx"'); header('Cache-Control: max-age=0'); $writer->save('php://output'); } private function loadMembers(): array { $query = <<dbConnection, $query); $entries = []; while ($row = mysqli_fetch_assoc($result)) { $entries[] = [ 'first_name' => $this->decode($row['first_name'], $row['salt']), 'last_name' => $this->decode($row['last_name'], $row['salt']), 'street' => $this->decode($row['street'], $row['salt']), 'zip' => $this->decode($row['zip'], $row['salt']), 'town' => $this->decode($row['town'], $row['salt']), 'birthdate' => $this->decode($row['birthdate'], $row['salt']), 'phone' => $this->decode($row['phone'], $row['salt']), 'email' => $this->decode($row['email'], $row['salt']), // 'child_name' => $this->decode($row['child_name'], $row['salt']), // 'child_street' => $this->decode($row['child_street'], $row['salt']), 'subscription' => $this->decode($row['subscription'], $row['salt']), 'iban' => $this->decode($row['iban'], $row['salt']), 'bank_name' => $this->decode($row['bank_name'], $row['salt']), 'bic' => $this->decode($row['bic'], $row['salt']), 'account_member_name' => $this->decode($row['account_member_name'], $row['salt']), 'status_text' => $row['status_text'], 'membership_start' => $row['membership_start'], 'last_payment' => $row['last_payment'], 'description' => $row['description'], ]; } return $entries; } }