'i am using a phpexcel and dompdf library to generate excell as well as pdf to download together in 1 function but it will download only one at time

i am using a phpexcel and dompdf library to generate excell as well as pdf to download together to the client side in 1 function but it will download only either phpexcel or dompdf but i want to download both together.i am having a data calculation part but i am not mention in these code because its working .

i want to know that can i download both file together in the one function please help me i am new to the php

public function create_order_submit()
{
       
       
        // ******************************************** generating Excell file and store in the cpanel folder assets ********************************************
      
        $this->load->library("excel");
        $object = new PHPExcel();
        
        $object->setActiveSheetIndex(0);
         
        $folder_path = 'assets/file';
        $object_writer = PHPExcel_IOFactory::createWriter($object, 'Excel5');

        $folder_path = 'assets/file';
        $object_writer = PHPExcel_IOFactory::createWriter($object, 'Excel5');
  
       
        $object_writer->save(str_replace(__FILE__,$folder_path.'/'.$file_name,__FILE__));
        
        header('Content-Type: application/vnd.ms-excel');
        header("Content-Disposition: attachment;filename=$file_name");
        $object_writer->save('php://output');
        
        // **************************************************Dompdf********************************************
        
      
        $html = "some data";
        $filename = "product_info.pdf";
        $this->load->library('pdf');
        $this->pdf->createPDF($html, $filename);

       // **************************************************emial********************************************
    
        $this->db->where('id',$this->uri->segment('3'));
        $user_data = $this->db->get('customer_login_detail')->row();
        
        $message="Name:- $user_data->name<br>Phone:- $user_data->phone<br>Country Code:- $user_data->country_code";
        $from_email = "[email protected]"; 
        $to_email = "[email protected]"; 
        //[email protected]
        
        //Load email library 
        //$this->load->library('email'); 
   
        $this->email->from($from_email, 'Arif Shaikh'); 
        $this->email->to($to_email);
        $this->email->subject('Al-nuaim Product Order'); 
        $this->email->message($message); 
        $this->email->set_mailtype("html");
        $this->email->attach('assets/file/'.$file_name);
        //Send mail 
        if($this->email->send()) 
        {
            //echo "email_sent","Email sent successfully."; 
            redirect('welcome/create_order/'.$user_id);
        }
  }


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source