遍历/遍历所有行和列,如果匹配则执行某些操作

时间:2019-03-06 03:07:49

标签: php excel phpexcel

我想要做的是当匹配值时更改字体粗细。

这是我的代码

$objWorksheet = $objPHPExcel->getActiveSheet();
    foreach ($objWorksheet->getRowIterator() as $row) {
        $cellIterator = $row->getCellIterator();
        foreach ($cellIterator as $cell) {
            $value = $cell->getValue();

            if( 'Total Order Value' == $value){
                $objPHPExcel->getActiveSheet()->getStyle( $cell )->applyFromArray(
                    array(
                        'font'  => array(
                        'bold'  => true
                        )
                    )
                );

            } else {
                //what you want to happen, if it is false
            }

        }
    }

Sample output

0 个答案:

没有答案