Home > Backend Development > PHP Tutorial > PHPExcel export excel drop-down menu how to do excel2013 official download excel2007

PHPExcel export excel drop-down menu how to do excel2013 official download excel2007

WBOY
Release: 2016-07-29 08:55:15
Original
2293 people have browsed it

// PHPExcel export steps:
// One: Introduce the official website download class library
// Two: Instantiate the PHPExcel class (create a new excel table)
// Three: createSheet() method, setActveSheetIndex method, getActiveSheel Method (create a built-in table in the sheet)
// Four: setCellValue() method (fill data)
// Five: PHPExcel_IOFactory::createWriter() method, save() method (save the file)
$dir =dirname(__FILE__); //Find the path where the current script is located
require $dir."/PHPExcel/PHPExcel.php";//Introduce the file
$objPHPExcel=new PHPExcel();//Instantiate the PHPExcel class, which is equivalent to creating a new excel table on the desktop
$objSheet=$objPHPExcel->getActiveSheet();//Get the operation object of the current active sheet
$objSheet->setTitle("demo");//Set a name for the current active sheet
/*$objSheet-> ;setCellValue("A1","Name")->setCellValue("B1","Score");//Fill data into the current active sheet
$objSheet->setCellValue("A2","Zhang San") ->setCellValue("B1","98");//Fill data into the current active sheet*/
//Array format
$array=array(
                                                                    using using use using using ‐           ‐       ‐                                                   - "score"),
array("","张三","98"),
array("","李思","59"),
);
$objSheet->fromArray($array ); // Directly load data blocks to fill
/*
* Tip: If the amount of data in this array is large, the fromArray() method will occupy too much memory and will report a memory error.
It is recommended to use the setCellValue method
*/
$objWriter=五:PHPExcel_IOFactory::createWriter($objPHPExcel,"Excel2007");//Generate excel file according to the specified format
$objWriter->save($dir."demo.xlsx");
?>
The above introduces PHPExcel export, including excel content. I hope it will be helpful to friends who are interested in PHP tutorials.

Related labels:
source:php.cn
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template