When I export from the database into Excel writes this way?

0 like 0 dislike
14 views
5ae83da6ce2b2207146936.jpeg
Use the library PHPExcel.
require_once 'Classes/PHPExcel.php'; $phpExcel = new PHPExcel(); $res = array( '0' => array( 'data' => '20.11.2003', 'name' => 'Ivanov', 'mail' => 'ivano@exemle.com' ), '1' => array( 'data' => '20.13.2005', 'name' => 'Sidorov P. A', 'mail' => 'sidorov@exemle.com' ), '2' => array( 'data' => '23.11.2008', 'name' => 'Petrov', 'mail' => 'petrov@exemle.com' ) ); $objPHPExcel = new PHPExcel(); $objPHPExcel->getProperties()->setCreator("Maarten Balliauw") ->setLastModifiedBy("Maarten Balliauw") ->setTitle("Office 2007 XLSX Test Document") ->setSubject("Office 2007 XLSX Test Document") ->setDescription("Test document for Office 2007 XLSX, generated using PHP classes.") ->setKeywords("office 2007 openxml php") ->setCategory("Test result file"); $i = null; foreach($res as $val) { $i++; $objPHPExcel->setActiveSheetIndex(0)->setCellValue("A$i", $val[data]); $objPHPExcel->setActiveSheetIndex(0)->setCellValue("B$i", $val[name]); $objPHPExcel->setActiveSheetIndex(0)->setCellValue("C$i", $val[mail]); } $objPHPExcel->setActiveSheetIndex(0); header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'); header('Content-Disposition: attachment;filename="stat.xls"'); header('Cache-Control: max-age=0'); header('Cache-Control: max-age=1'); header ('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); // Date in the past header ('Last-Modified: '.gmdate('D, D M Y H:i:s').' GMT'); // always modified header ('Cache-Control: cache, must-revalidate'); // HTTP/1.1 header ('Pragma: public'); // HTTP/1.0 $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007'); $objWriter->save('php://output');
by | 14 views

1 Answer

0 like 0 dislike
patamusha it zip, compressed data, you on XLSX pulled
by

Related questions

0 like 0 dislike
2 answers
0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
110,608 questions
257,186 answers
0 comments
33,631 users