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

How to format cells in php

藏色散人
藏色散人Original
2020-08-01 09:58:553786browse

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);

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!

Statement:
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