Share The Excel export example in PHP and the excel export example in php. PHP export Excel example sharing, php export excel example download phpexcel_1.8.0_doc.zip phpexcel.codeplex.com, upload the Classes in the decompressed folder to the root directory of the website, PHP export Excel example sharing, php export excel example
Download phpexcel_1.8.0_doc.zip extension:
Export file Excel. php
Require_once dirname (_ FILE __). '/Classes/PHPExcel. php '; // introduce PHPExcel ..... the process of retrieving data from the database is omitted here. $ a is the array to be exported ...... $ numArr = array ('A', 'B', 'C', 'D', 'e', 'F', 'G', 'H ', 'I', 'J', 'K', 'L', 'M', 'n', 'O', 'P', 'Q', 'R ','s ', 'T', 'u', 'V', 'W', 'X', 'y', 'z', 'A',' AB ', 'AC', 'AD', 'AE', 'AF', 'AG', 'AH', 'Ai', 'AJ ', 'AK', 'Al ', 'AM', 'Any', 'ao', 'AP ', 'Aq', 'ar ', 'as', 'at', 'Au', 'Av ', 'aw', 'ax', 'ay', 'az'); // Create new PHPExcel object $ objPHPExcel = new PHPExcel (); $ arr = array ('Order No ', 'order time ', 'city', 'region', 'customer name', 'consignee', 'Contact number', 'shipping address', 'erp customer name ', 'logistics system customer name', 'activity project', 'brand', 'model', 'Color', 'logistics system model', 'Order quantity ', 'unit price ', 'pay-as-you-go users', 'hongba', 'Price rebates ', 'Shipping', 'amount received', 'payment method ', 'Order source', 'Upstream Manufacturers ', 'In warehouse? ', 'waybill no.', 'Order status', 'confirmation time', 'Last status confirmation time', 'Description', 'corresponding service ', 'customer service', 'Merchant message', 'Order summary', 'Salesman', 'Contact information'); // output the title echo date ('H: I: s '), "Add some data", EOL; // set the line feed $ objPHPExcel-> getActiveSheet ()-> getStyle ('h')-> getAlignment () -> setWrapText (true); $ objPHPExcel-> getActiveSheet ()-> getStyle ('Y')-> getAlignment ()-> setWrapText (true ); // Set the column width $ objPHPExcel-> setActiveSheetIndex (0)-> getColumnDimension ('A')-> setWidth (15); $ objPHPExcel-> setActiveSheetIndex (0) -> getColumnDimension ('B')-> setWidth (20); $ objPHPExcel-> setActiveSheetIndex (0)-> getColumnDimension ('g')-> setWidth (15 ); $ objPHPExcel-> setActiveSheetIndex (0)-> getColumnDimension ('h')-> setWidth (40); $ objPHPExcel-> setActiveSheetIndex (0)-> getColumnDimension ('I ') -> setWidth (15); $ objPHPExcel-> setActiveSheetIndex (0)-> getColumnDimension ('J')-> setWidth (15 ); // output the first line $ objPHPExcel-> setActiveSheetIndex (0)-> setCellValue ('A1', $ arr [0])-> setCellValue ('B1 ', $ arr [1])-> setCellValue ('C1', $ arr [2])-> setCellValue ('d1 ', $ arr [3]) -> setCellValue ('e1 ', $ arr [4])-> setCellValue ('F1', $ arr [5])-> setCellValue ('G1 ', $ arr [6])-> setCellValue ('h1 ', $ arr [7])-> setCellValue ('i1', $ arr [8]) -> setCellValue ('j1', $ arr [9])-> setCellValue ('k1 ', $ arr [10])-> setCellValue ('l1 ', $ arr [11]); // Output Content for ($ I = 0; $ I
SetActiveSheetIndex (0)-> setCellValue ($ numArr [0]. ($ I + 2), $ a [$ I] ['Order _ sn '])-> setCellValue ($ numArr [1]. ($ I + 2), $ a [$ I] ['add _ time'])-> setCellValue ($ numArr [2]. ($ I + 2), $ a [$ I] ['city'])-> setCellValue ($ numArr [3]. ($ I + 2), $ a [$ I] ['region _ name'])-> setCellValue ($ numArr [4]. ($ I + 2), $ a [$ I] ['Company'])-> setCellValue ($ numArr [5]. ($ I + 2), $ a [$ I] ['consignee'])-> setCellValue ($ numArr [6]. ($ I + 2), $ a [$ I] ['mobile'])-> s EtCellValue ($ numArr [7]. ($ I + 2), $ a [$ I] ['address'])-> setCellValue ($ numArr [8]. ($ I + 2), '')-> setCellValue ($ numArr [9]. ($ I + 2), '')-> setCellValue ($ numArr [10]. ($ I + 2), '')-> setCellValue ($ numArr [11]. ($ I + 2), $ a [$ I] ['brand _ name']);} // Rename worksheetecho date ('H: I: s '), "Rename worksheet", EOL; $ dirName = date ("Ymd"); // Directory Name $ fileName = date ("YmdHis "); // file name $ objPHPExcel-> getActiveSheet ()-> setTitle ($ fileName); // Set active sheet index to the first sheet, so Excel opens this as the first sheet $ objPHPExcel-> setActiveSheetIndex (0); // Save Excel 2007 fileecho date ('H: i: s'), "Write to Excel2007 format", EOL; $ callStartTime = microtime (true); if (! Opendir ('.. /excel /'. $ dirName) {mkdir ('.. /excel /'. $ dirName) ;}$ objWriter = PHPExcel_IOFactory: createWriter ($ objPHPExcel, 'excel2007 '); $ objWriter-> save ('.. /excel /'. $ dirName. '/'.w.filename.'.xlsx'); $ end = getCurrentTime (); $ spend = $ end-$ begin; if ($ spend> 30) {echo 'script if (confirm ("execution timeout! ") {Window. history. back (-1);} script '; exit;} header ('Location: http ://'. $ _ SERVER ['http _ host']. '/excel /'. $ dirName. '/'.w.filename.'.xlsx ');
Php excel export
Simply send the EXCEL header to the browser
Header ("Content-type: application/vnd. ms-excel ");
Header ("Content-Disposition: filename=aa.xls ");
A complicated slogan may not be clear.
Urgent php export to generate excel code
You can use phpexcel for output. the official address phpexcel.codeplex.com/has the download usage method in the upper right corner: SetOffice2003Compatibility (true ); //*************************************/ /set the basic attributes of the document $ objProps = $ objExcel-> getProperties (); $ objProps-> setCreator ("Zeal Li"); $ objProps-> setLastModifiedBy ("Zeal Li"); $ objProps-> setTitle ("Office XLS Test Document "); $ objProps-> setSubject (& q ...... remaining full text>
Http://www.bkjia.com/PHPjc/865614.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/865614.htmlTechArticlePHP export Excel example share, php export excel example download phpexcel_1.8.0_doc.zip http://phpexcel.codeplex.com/, will be the root directory of the files in the folder to the website ,...