PHP export excel php uses phpexcel to export excel files
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-07-25 08:54:43
Original
1020 people have browsed it
-
-
//Load the PHPExcel class - require './phpexcel/PHPExcel.php';
//Create an excel object instance
- $objPHPExcel = new PHPExcel();
//Set the basic properties of the document
- $objProps = $objPHPExcel->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"); p>
//Set the current sheet index for subsequent content operations.
- //Generally, display calls are only needed when using multiple sheets.
- //By default, PHPExcel will automatically create the first sheet with SheetIndex=0
- $objPHPExcel->setActiveSheetIndex(0);
//Set the name of the current active sheet
- $objActSheet = $objPHPExcel->getActiveSheet();
- $objActSheet->setTitle('Test Sheet');
//Set cell content
- //The data here can Read from the database and then perform loop processing
- //by bbs.it-home.org
- $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 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 certain location
- $objWriter->save(dirname(__FILE__) . '/demo.xls');< /p>
-
Copy code
|
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
-
2024-10-22 09:46:29
-
2024-10-13 13:53:41
-
2024-10-12 12:15:51
-
2024-10-11 22:47:31
-
2024-10-11 19:36:51
-
2024-10-11 15:50:41
-
2024-10-11 15:07:41
-
2024-10-11 14:21:21
-
2024-10-11 12:59:11
-
2024-10-11 12:17:31