PHPExcel - set cell type before writing a value in it

后端 未结 6 1304
南方客
南方客 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:19

    Followed Mark's advise and did this to set the default number formatting to text in the whole workbook:

    $objPHPExcel = new PHPExcel(); 
    $objPHPExcel->getDefaultStyle()
        ->getNumberFormat()
        ->setFormatCode(
            PHPExcel_Style_NumberFormat::FORMAT_TEXT
        );
    

    And it works flawlessly. Thank you, Mark Baker.

提交回复
热议问题