PHP code example of opensite / pexcel

1. Go to this page and download the library: Download opensite/pexcel library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

opensite / pexcel example snippets




use pexcel;


/**
 * 导出类型
 * 导出文件名
 * 重设默认配置
 */  
$excel = new Excel("xls","导出数据",$config);

// 发送单个sheet
/**
 * data array 导出单个sheet 的数据
 * $sheet string sheet工作表名称 默认为:sheet1
 */
$excel->export($data);

// 导出多个sheet
/**
 * $data string 为多维数组
 * $param $data:
 * [
 *  	[ //每个sheet对应的导出数据
 *			['name','age','test'],
 *			[''lucky',19,'test']
 *		],
 *		[
 *			['id','name','score'],
 *			[1,'lucky',90],
 *			[2,'nancy',99]
 *		]
 * ]
 * $sheets array 多个sheet时的工作表名称 默认为该类型默认sheet名
 */
$excel->exportSheet($data,$sheets);