Guest User

export.php

a guest
Nov 13th, 2019
135
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public function export_data()
  2. {
  3. # code...
  4. $data["export"] = $this->mod->data_excel();
  5. $this->load->model("M_Deposit_transaction");
  6. $this->load->library("excel");
  7. $object = new PHPExcel();
  8. $object->setActiveSheetIndex(0);
  9. $table_columns = array("Tgl Trx", "Kode","Agen","Pengirim","Penerima","Nominal","Status");
  10. $column = 0;
  11.  
  12. foreach($table_columns as $field){
  13.  
  14. $object->getActiveSheet()->setCellValueByColumnAndRow($column, 1, $field);
  15.  
  16. $column++;
  17.  
  18. }
  19.  
  20. $employee_data = $this->excel_export_model->fetch_data();
  21. $excel_row = 2;
  22. foreach($employee_data as $row){
  23.  
  24. $object->getActiveSheet()->setCellValueByColumnAndRow(0, $excel_row, $row->name);
  25.  
  26. $object->getActiveSheet()->setCellValueByColumnAndRow(1, $excel_row, $row->email);
  27.  
  28. $excel_row++;
  29.  
  30. }
  31.  
  32. $object_writer = PHPExcel_IOFactory::createWriter($object, 'Excel5');
  33. header('Content-Type: application/vnd.ms-excel');
  34. header('Content-Disposition: attachment;filename="Rekap Transaksi Data.xls"');
  35. $object_writer->save('php://output');
  36. }
  37.  
  38. //$data['title']='Tabel tiket_dipesan';
  39. //print('<pre>'); print_r($data); exit();
  40. //$this->load->view('tiket_dipesan/tiket_dipesan_tampil');
RAW Paste Data