PHP Excel设置任何样式

时间:2019-04-05 13:18:42

标签: php phpexcel

我正在尝试导出excel文件, 我设置了任何样式,但是样式不起作用。 我该如何解决这个问题?

$phpExcel = new PHPExcel();
$phpExcel->setActiveSheetIndex(0)
            ->setCellValue('A2', "Ամսաթիվ")
            ->setCellValue('B2', "Փաստա\nթղթի N")
            ->setCellValue('C2', "Գնորդ");
$yellowStyles = [
            'fill' => [
                'type' => PHPExcel_Style_Fill::FILL_SOLID,
                'color' => array('rgb' => 'ffff99')
            ],
            'font'  => [
                'bold'  => true,
                'color' => array('rgb' => '000000'),
                'size'  => 8,
                'name'  => 'Tahoma',
            ],
            'alignment' => $defaultAlignment
        ];

$phpExcel->getActiveSheet()->getStyle("A2")->applyFromArray($yellowStyles);

  $objWriter = PHPExcel_IOFactory::createWriter($phpExcel, 'CSV');

enter code here
        $file = UIS_TEMP_DIR.DS.'report_hc_'.$year.'_'.$month.'.xls';
        $objWriter->save($file);

0 个答案:

没有答案