Home > Backend Development > PHP Problem > How to format cells in php

How to format cells in php

藏色散人
Release: 2023-03-03 16:40:01
Original
3769 people have browsed it

php method to set cell format: 1. Set the cell background color through the "setRGB('FFFF00');" method; 2. Merge cells through the "mergeCells('A1:F1')" method ;3. Set the font to be bold through the "setBold(true)" method.

How to format cells in php

php set cell format

Recommended: "PHP Video Tutorial"

PHPExcel Set style, background color, center, width, cell merge

    //设置第一行背景色为FFFF00
        $objPHPExcel->getActiveSheet()->getStyle('A1')->getFill()->setFillType(\PHPExcel_Style_Fill::FILL_SOLID)->getStartColor()->setRGB('FFFF00');
        //合并单元格
        $objPHPExcel->getActiveSheet()->mergeCells('A1:F1');
        //设置居中
        $objPHPExcel->getActiveSheet()->getStyle('A1:F1')->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
        $objPHPExcel->getActiveSheet()->getStyle('E2')->getFont()->setName('宋体') //字体
        // ->setBold(true); //字体加粗
        //设置宽度
        $objPHPExcel->getActiveSheet()->getColumnDimension('A')->setWidth(20);
Copy after login

The above is the detailed content of How to format cells in php. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
php
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