Guest User

Untitled

a guest
Jan 18th, 2019
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. array(9) { [0]=> string(1) "1" [1]=> string(24) "Company" [2]=> string(9) " 12345689" [3]=> string(9) "Name" [4]=> string(1) "4" [5]=> string(26) "careerintern2017@gmail.com"}
  2.  
  3. id | ent_name | ent_num | owner | ent_c | email
  4. -------------------------------------------------------------------------
  5. 1 | Company | 123456789| Name | 4 | careerintern2017@gmail.com
  6. -------------------------------------------------------------------------
  7.  
  8. $excel_file_path = "ent_info/ent_info_list.xlsx";
  9. $spreadsheet = PhpOfficePhpSpreadsheetIOFactory::load($excel_file_path);
  10. $row_num = $spreadsheet->setActiveSheetIndex(0)->getHighestRow();
  11. $row_num =$row_num+1;
  12. $col_num=0;
  13. $counter=1;
  14. $sheet = $spreadsheet->getActiveSheet();
  15. foreach($array as $data){
  16. $pos = get_excel_col($col_num).$row_num;
  17. //$pos = A2, B2, C2 .... (for example)
  18. $sheet->setCellValue($pos, $data);
  19. if($counter==6){
  20. $row_num++;
  21. $col_num=0;
  22. }
  23. $col_num++;
  24. $counter++;
  25. }
  26. $writer = PhpOfficePhpSpreadsheetIOFactory::createWriter($spreadsheet, "Xlsx");
  27. $writer->save($excel_file_path);
Add Comment
Please, Sign In to add comment