当前位置:网站首页>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
边栏推荐
- laravel 9
- Explain AHP in human language (very detailed principle + simple tool implementation)
- 15. Notes on the button style of WPF
- Installation and removal of MySQL under Windows
- If you also want to be we media, you might as well listen to Da Zhou's advice
- Gradle knowledge points
- When MySQL queries fields in JSON format, it takes a property value of JSON data
- How can we make an annual income of onemillion yuan by making our own media video?
- Mysql database logs binlog save aging (expire\u logs\u days)
- Huikan source code -- Huikan app system secondary development source code sharing
猜你喜欢

SDN system method | 9 Access network

Uncover gaussdb (for redis): comprehensive comparison of CODIS

Service charge and time setting code sharing involved in crmeb withdrawal process

Dark horse shopping mall ---1 Project introduction - environment construction

Zhangxiaobai's way of penetration (V) -- detailed explanation of upload vulnerability and parsing vulnerability

ECSHOP commodity wholesale multi attribute multi specification multi inventory batch purchase ECSHOP wholesale plug-in ECSHOP multi attribute order

Découvrir gaussdb (pour redis): une comparaison complète avec Codis

An article clearly explains MySQL's clustering / Federation / coverage index, back to table, and index push down

Total number of MySQL statistics, used and unused

K8s, docker compose install MySQL 8.0.18
随机推荐
Penetration tool environment - installing sqli labs in centos7 environment
Dark horse shopping mall ---1 Project introduction - environment construction
Zunpin Yongyao advertising e-commerce system -- Zunpin Yongyao advertising e-commerce app system development source code sharing
15. Notes on the button style of WPF
Summary of common MySQL database commands (from my own view)
2022 Baidu collection batch automatic push assistant
Concise H5 error page
Image tagging to obtain the coordinates of the image in the ImageView
The whole page turns gray
Laravel echart statistical chart line chart
ARM V7 ldr str 内存访问
An example of using dynamic datalist
Pycaret successfully resolved the problem that 'sklearn model_ selection._ Search 'import name "\u check\u param\u grid"
Understanding and construction of devsecops and Devops
JQ dynamic setting radio does not take effect when selected
Is it safe to open an account and buy stocks on the Internet?
Why should Apple change objc_ Type declaration for msgsend
laravel 9
2022 meisai D topic ideas sharing + translation
Recyclerview scrolls to the specified location