当前位置:网站首页>High performance + million level Excel data import and export
High performance + million level Excel data import and export
2022-06-25 12:36:00 【Velly_ zheng】
High performance + Million level excel Data import and export
Content introduction
【 Reprint 】https://learnku.com/articles/38582
github Address
https://github.com/viest/php-ext-xlswriter
Use document address
【 Reprint 】https://xlswriter-docs.viest.me/zh-cn
Installation precautions
Only with mac give an example
Look at the official documents , I used the following steps myself. Anyway, the installation failed 
In the local mac Installing extensions on your PC , It didn't work . however , There's another way , Simple , Fast and effective .
My local address is laradock Environmental Science , If someone is like me , You can keep looking down
- 1. Direct editing laradock In the document env, And modify php-fpm And workspace To configure
Such as :
.env file :
### WORKSPACE #############################################
WORKSPACE_INSTALL_XLSWRITER=true
### PHP_FPM ###############################################
PHP_FPM_INSTALL_PHP_XLSWRITER=true
Insert a sentence here : Why? workspace Also install
This is because when used xlswriter when , Use the locally configured domain name , Is take the laradock Containers , And the code is in workspace In the container , So if workspace This plug-in is not installed in the container , The code will still prompt that the plug-in does not exist
- 2. modify laradock The root directory docker-compose.yml file
### PHP-FPM ##############################################
php-fpm:
build:
context: ./php-fpm
args:
- INSTALL_XLSWRITER=${
PHP_FPM_INSTALL_PHP_XLSWRITER}
### Workspace Utilities ##################################
workspace:
build:
context: ./workspace
args:
- INSTALL_XLSWRITER=${
WORKSPACE_INSTALL_XLSWRITER}
- 3. Modify the root directory php-fpm/Dockerfile and workspace/Dockerfile
php-fpm/Dockerfile
#####################################
# xlswriter:
#####################################
USER root
ARG INSTALL_XLSWRITER=false
RUN if [ ${
INSTALL_XLSWRITER} = true ]; then \
pecl install xlswriter \
&& printf "extension=xlswriter.so\n" > $PHP_INI_DIR/conf.d/xlswriter.ini \
&& php -m | grep -q 'xlswriter' \
;fi
/workspace/Dockerfile
#####################################
# xlswriter:
#####################################
USER root
ARG INSTALL_XLSWRITER=false
RUN if [ ${
INSTALL_XLSWRITER} = true ]; then \
pecl install xlswriter \
&& printf "extension=xlswriter.so\n" > /etc/php/${
LARADOCK_PHP_VERSION}/cli/conf.d/xlswriter.ini \
&& php -m | grep -q 'xlswriter' \
;fi
- 4. After saving successfully , recompile ,docker-compose build php-fpm And docker-compose build workspace
- 5. Into the container , perform php -m command , Check if the plug-in is installed successfully
ide Prompt relevant codes in
composer require viest/php-ext-xlswriter-ide-helper:dev-master
download demo
Generate fileObject
pubic function generateFileObject(){
$config = ['path' => config('*.*.path')];
$excel = new \Vtiful\Kernel\Excel($config);
return $excel->constMemory($this->fileName);
}
addStyle
private function addStyle(Object $fileObject){
$fileHandle = $fileObject->getHandle();
$format = new \Vtiful\Kernel\Format($fileHandle);
// Combination style , font size , The font color , The background color , bold
$boldColorStyle = $format->bold()->fontSize(14)->fontColor(\Vtiful\Kernel\Format::COLOR_ORANGE)
->align(\Vtiful\Kernel\Format::FORMAT_ALIGN_VERTICAL_CENTER)
->align(\Vtiful\Kernel\Format::FORMAT_ALIGN_CENTER)->toResource();
return $fileObject->setRow('A1',30, $boldColorStyle)
->header($this->header)
->gridline(\Vtiful\Kernel\Excel::GRIDLINES_SHOW_ALL);
}
use
$fileObject = $this->generateFileObject();
$fileObject = $this->addStyle($fileObject);
$fileObject->data($data);
$fileObject->output();
among $data To set or sql The result of the inquiry is result
边栏推荐
- Mpai data science platform random forest classification \ explanation of regression parameter adjustment
- Recyclerview scrolls to the specified location
- Service charge and time setting code sharing involved in crmeb withdrawal process
- Zunpin Yongyao advertising e-commerce system -- Zunpin Yongyao advertising e-commerce app system development source code sharing
- Penetration tool environment - installing sqli labs in centos7 environment
- Why should Apple change objc_ Type declaration for msgsend
- New and old cluster migration of Minio data
- R language uses the multinom function of NNET package to build an unordered multi classification logistic regression model, and uses the summary function to obtain the summary statistical information
- Zhangxiaobai's road of penetration (VI) -- the idea and process of SQL injection and the concat series functions and information of SQL_ Schema database explanation
- Array reorder based on a field
猜你喜欢

MySQL common interview questions

mysql FIND_ IN_ Set function

揭秘GaussDB(for Redis):全面對比Codis

Uncover gaussdb (for redis): comprehensive comparison of CODIS

Why do we do autocorrelation analysis? Explain application scenarios and specific operations

Zhangxiaobai's road of penetration (IV) -- detailed explanation of XSS cross site script vulnerabilities

ECSHOP upload video_ ECSHOP video list, video classification, video related product guide

一篇文章讲清楚MySQL的聚簇/联合/覆盖索引、回表、索引下推
![[oceanbase] Introduction to oceanbase and its comparison with MySQL](/img/1c/bd2bcddb7af4647407d2bc351f5f5d.png)
[oceanbase] Introduction to oceanbase and its comparison with MySQL

一款好用的印章设计工具 --(可转为ofd文件)
随机推荐
R language uses the multinom function of NNET package to build an unordered multi classification logistic regression model, and uses the summary function to obtain the summary statistical information
The source code of the hottest online disk money making system in 2022 imitates Lanzou online disk / Chengtong online disk / sharing money making cloud disk system / online disk VIP Download System
Arm V7 continuous load / store
Rank sum ratio comprehensive evaluation method for common models in mathematical modeling
Understanding and construction of devsecops and Devops
Service charge and time setting code sharing involved in crmeb withdrawal process
Jeecgboot startup popup configuration is still incorrect
Arm V7 coprocessor
一篇文章讲清楚MySQL的聚簇/联合/覆盖索引、回表、索引下推
Laravel is not logged in and cannot access the background by entering the URL
Implementing Domain Driven Design - using the ABP framework - Summary of a series of articles
Tidb common commands
Total number of MySQL statistics, used and unused
Possible causes of wechat applet decryption failure
Thinkphp3 reinforcement i() function filter single quotation marks
Mind mapping video
Yunfan mall -- Yunfan mall system development source code sharing
Wait for the end of the network request in the uniapp Onshow method before executing the subsequent code content
2022 meisai e topic ideas sharing + translation
Kotlin study notes