PHP excel export

Source: Internet
Author: User
Tags php excel
PHP exports excel through the PHPExcel class, while some simplified processing of PHPExcel, basically can meet the data export excel function. View php import exce

PHP exports excel through the PHPExcel class, while some simplified processing of PHPExcel, basically can meet the data export excel function. View php import excel

File: http://pan.baidu.com/share/link? Consumer id = 1345826295 & uk = 2332350821

The code is as follows:


 GetProperties (); $ objProps-> setCreator ("Lao Mao"); $ objProps-> setLastModifiedBy ("Lao Mao "); $ objProps-> setTitle ("Office XLS Test Document"); $ objProps-> setSubject ("Office XLS Test Document, Demo"); $ objProps-> setDescription ("Test document, generated by PHPExcel. "); $ objProps-> setKeywords (" office excel PHPExcel "); $ objProps-> setCategory (" Test "); // set the current sheet index, used for subsequent content operations. // Display the call only when multiple sheets are used. // By default, PHPExcel will automatically create the first sheet and set SheetIndex = 0 $ objPHPExcel-> setActiveSheetIndex (0 ); // Set the name of the current active sheet $ objActSheet = $ objPHPExcel-> getActiveSheet (); $ objActSheet-> setTitle ('test Sheet '); // Set the cell content // The data here can be read from the database, and then processed cyclically $ objPHPExcel-> getActiveSheet ()-> SetCellValue ('A1', 'A1 '); $ objPHPExcel-> getActiveSheet ()-> SetCellValue ('A2 ', 'A2'); $ objPHPExcel-> getActiveSheet ()-> SetCellValue ('A3 ', 'A3 '); $ objPHPExcel-> getActiveSheet ()-> SetCellValue ('A4 ', 'A4'); $ objPHPExcel-> getActiveSheet ()-> SetCellValue ('a5 ', 'a5 '); $ objPHPExcel-> getActiveSheet ()-> SetCellValue ('b1 ', 'b1'); $ objPHPExcel-> getActiveSheet ()-> SetCellValue ('B2', 'B2 '); $ objPHPExcel-> getActiveSheet ()-> SetCellValue ('b3', 'b3'); $ objPHPExcel-> getActiveSheet ()-> SetCellValue ('B4 ', 'B4 '); $ objPHPExcel-> getActiveSheet ()-> SetCellValue ('b5 ', 'b5'); $ objPHPExcel-> getActiveSheet ()-> SetCellValue ('C1', 'C1 '); $ objPHPExcel-> getActiveSheet ()-> SetCellValue ('C2 ', 'C2'); $ objPHPExcel-> getActiveSheet ()-> SetCellValue ('C3', 'C3 '); $ objPHPExcel-> getActiveSheet ()-> SetCellValue ('C4 ', 'C4'); $ objPHPExcel-> getActiveSheet ()-> SetCellValue ('c5 ', 'c5 '); // output the document $ objWriter = new PHPExcel_Writer_Excel5 ($ objPHPExcel); // Set the header information and output it to the browser // header ('content-Type: application/vnd. ms-excel '); // header ("Content-Disposition: attachment; filename=demo.xls"); // header ('cache-Control: max-age = 0 '); // $ objWriter-> save ('php: // output'); // save to a location $ objWriter-> save (dirname (_ FILE __). '/demo.xls ');

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.