测试结果
先上测试结果
8核16G的服务器
表 | 字段数 | 消耗时间/秒 | 数量/万 | CPU增加/百分百 |
---|---|---|---|---|
单表 | 4 | 25 | 100 | 10-30 |
单表连7张表 | 21 | 31 | 8 | 10-20 |
安装
1.composer
安装
安装到项目
composer require viest/php-ext-xlswriter-ide-helper
2.php
扩展安装,Centos
环境
php
扩展安装
- 1.参考,这是官方Ubuntu的安装方法
下载
wget https://pecl.php.net/get/xlswriter-1.3.3.2.tgz
解压
tar zxvf xlswriter-1.3.3.2.tgz
进入目录
cd xlswriter-1.3.3.2
编译
注意
php目录
替换为自己服务器上php
安装的目录
php目录/bin/phpize && ./configure --with-php-config=php目录/bin/php-config --enable-reader
安装
make && make install
安装成功返回
If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the `-LLIBDIR'
flag during linking and do at least one of the following:
- add LIBDIR to the `LD_LIBRARY_PATH' environment variable
during execution
- add LIBDIR to the `LD_RUN_PATH' environment variable
during linking
- use the `-Wl,--rpath -Wl,LIBDIR' linker flag
- have your system administrator add LIBDIR to `/etc/ld.so.conf'
See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------
Build complete.
Don't forget to run 'make test'.
Installing shared extensions: php目录/lib/php/extensions/no-debug-non-zts-20160303/
修改php.ini
extension = php目录/lib/php/extensions/no-debug-non-zts-20160303/xlswriter.so
3.官方代码示例
$config = ['path' => '/home/viest'];
$excel = new \Vtiful\Kernel\Excel($config);
// fileName 会自动创建一个工作表,你可以自定义该工作表名称,工作表名称为可选参数
$filePath = $excel->fileName('tutorial01.xlsx', 'sheet1')
->header(['Item', 'Cost'])
->data([
['Rent', 1000],
['Gas', 100],
['Food', 300],
['Gym', 50],
])
->output();
4.我封装的代码
安装
composer require pl/laravel-admin-api