Message: undefined index: wc_order_id

Saya ingin download excel namun ada error Message: Undefined index: wc_order_id ini adalah controler saya

public function createExcel($awals, $akhirs, $status) {
		$fileName = 'Reservation.xlsx';
		$data['data'] = $this->M_reservation->all_order($awals, $akhirs, $status) ;

		$spreadsheet = new Spreadsheet();
                $sheet = $spreadsheet->getActiveSheet();
		$total = 0;

       	$sheet->setCellValue('A1', 'No');
        $sheet->setCellValue('B1', 'Booking ID');
        $sheet->setCellValue('C1', 'Order Date');
        $sheet->setCellValue('D1', 'Client Name');
        $sheet->setCellValue('E1', 'Client Email');
        $sheet->setCellValue('F1', 'Phone');
        $sheet->setCellValue('G1', 'Inclution');
        $sheet->setCellValue('H1', 'Room name');
        $sheet->setCellValue('I1', 'Bed Order');
        $sheet->setCellValue('J1', 'Status');
        $sheet->setCellValue('K1', 'Total Order');
        $sheet->getColumnDimension("A")->setAutoSize(true);
        $sheet->getColumnDimension("B")->setAutoSize(true);
        $sheet->getColumnDimension("C")->setAutoSize(true);
        $sheet->getColumnDimension("D")->setAutoSize(true);
        $sheet->getColumnDimension("E")->setAutoSize(true);
        $sheet->getColumnDimension("F")->setAutoSize(true);
        $sheet->getColumnDimension("G")->setAutoSize(true);
        $sheet->getColumnDimension("H")->setAutoSize(true);
        $sheet->getColumnDimension("I")->setAutoSize(true);
        $sheet->getColumnDimension("J")->setAutoSize(true);
        $sheet->getColumnDimension("K")->setAutoSize(true);
        $sheet->getStyle("A1:K1")->getFont()->setBold(true);

        $rows = 2;
        $no = 1;
        $total=0;
        foreach ($data as $val){
            $sheet->setCellValue('A' . $rows, $no++);
            $sheet->setCellValue('B' . $rows, $val['wc_order_id']);
            $sheet->setCellValue('C' . $rows, $val['post_date']);
            $sheet->setCellValue('D' . $rows, $val['display_name']);
            $sheet->setCellValue('E' . $rows, $val['user_email']);
	    $sheet->setCellValue('F' . $rows, $val['meta_value']);
            $sheet->setCellValue('G' . $rows, $val['display_name']);
            $sheet->setCellValue('H' . $rows, $val['post_title']);
            $sheet->setCellValue('I' . $rows, $val['room_num_search']);
            $sheet->setCellValue('J' . $rows, $val['status']);
            $sheet->setCellValue('K' . $rows, $val['total_order']);
            $total = $total+$val['total_order'];


            $rows++;


        }
        $sheet->setCellValue('B'.$rows , "Total");
        $sheet->setCellValue('K'.$rows , $total);



        $writer = new Xlsx($spreadsheet);
		header('Content-Type: application/vnd.ms-excel');
	    header('Content-Disposition: attachment;filename="Reservation.xlsx"');
	    header('Cache-Control: max-age=0');
	    ob_clean();
	  $writer->save('php://output');
    }

saat di print_r(array_values($data)); exit; data sudah menampilkan data yang benar Bagaimana solusinya

avatar present
@present

15 Kontribusi 1 Poin

Dipost 4 tahun yang lalu

Belum ada Jawaban. Jadi yang pertama Jawaban

Login untuk ikut Jawaban