PHPExcel - set cell type before writing a value in it

后端 未结 6 1315
南方客
南方客 2020-12-05 10:56

Do you know how can I set the cell type before writing a value in it? I would like to be able to set types like \"General\", \"Text\" and \"Number\".

Thank you.

6条回答
  •  孤城傲影
    2020-12-05 11:12

    For Numbers with leading zeroes and comma separated:

    You can put 'A' to affect the entire column'.

    $objPHPExcel->getActiveSheet()->getStyle('A1')->getNumberFormat()->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_NUMBER_COMMA_SEPARATED1);
    

    Then you can write to the cell as you normally would.

提交回复
热议问题