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

                    ->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);

    

                $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('B2','日期:'.date("Y年m月j日"));

                $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('G2','第'.$current_page.'/'.$page_count.'页');

                $objectPHPExcel->setActiveSheetIndex(0)->getStyle('G2')

                    ->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT);

                    

                //表格头的输出

                $objectPHPExcel->getActiveSheet()->getColumnDimension('A')->setWidth(5);

                $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('B3','编号');

                $objectPHPExcel->getActiveSheet()->getColumnDimension('B')->setWidth(6.5);

                $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('C3','名称');

                $objectPHPExcel->getActiveSheet()->getColumnDimension('C')->setWidth(17);

                $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('D3','生产厂家');

                $objectPHPExcel->getActiveSheet()->getColumnDimension('D')->setWidth(22);

                $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('E3','单位');

                $objectPHPExcel->getActiveSheet()->getColumnDimension('E')->setWidth(15);

                $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('F3','单价');

                $objectPHPExcel->getActiveSheet()->getColumnDimension('F')->setWidth(15);

                $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('G3','在库数');

                $objectPHPExcel->getActiveSheet()->getColumnDimension('G')->setWidth(15);

                    

                //设置居中

                $objectPHPExcel->getActiveSheet()->getStyle('B3:G3')

                    ->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);

    

                //设置边框

                $objectPHPExcel->getActiveSheet()->getStyle('B3:G3' )

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

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