PHPExcel How to apply styles and set cell width and cell height to cell generated dynamically

后端 未结 2 1142
面向向阳花
面向向阳花 2020-12-29 10:31

I have form that I generate its content to Excel through PHPExcel, my problem is that how can I set width and height and also styles to the heading cells.

the excel

2条回答
  •  我在风中等你
    2020-12-29 10:52

    You can use

    $objWorksheet->getActiveSheet()->getRowDimension('1')->setRowHeight(40);
    $objWorksheet->getActiveSheet()->getColumnDimension('A')->setWidth(100);
    

    or define auto-size:

    $objWorksheet->getRowDimension('1')->setRowHeight(-1);
    

提交回复
热议问题