Yii框架中使用PHPExcel导出Excel文件(4)

                    ->getBorders()->getBottom()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);

            $objectPHPExcel->getActiveSheet()->getStyle('B'.($n+4).':G'.$currentRowNum )

                    ->getBorders()->getVertical()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);

            $n = $n +1;    

        }

    

        //设置分页显示

        //$objectPHPExcel->getActiveSheet()->setBreak( 'I55' , PHPExcel_Worksheet::BREAK_ROW );

        //$objectPHPExcel->getActiveSheet()->setBreak( 'I10' , PHPExcel_Worksheet::BREAK_COLUMN );

        $objectPHPExcel->getActiveSheet()->getPageSetup()->setHorizontalCentered(true);

        $objectPHPExcel->getActiveSheet()->getPageSetup()->setVerticalCentered(false);

    

    

        ob_end_clean();

        ob_start();

    

        header('Content-Type : application/vnd.ms-excel');

        header('Content-Disposition:attachment;filename="'.'产品信息表-'.date("Y年m月j日").'.xls"');

        $objWriter= PHPExcel_IOFactory::createWriter($objectPHPExcel,'Excel5');

        $objWriter->save('php://output');

代码执行后,会直接生成Excel,并提示下载或打开。

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/11221.html