Explicitly set a cell’s datatype as text for number values

前端 未结 2 1558
礼貌的吻别
礼貌的吻别 2020-12-21 17:50

I want to explicitly set a cell’s datatype as a text for number values.

I am fetching data from my MySQL database and exporting to excel file using PHPExcel Library.

相关标签:
2条回答
  • 2020-12-21 18:23
    $objPHPExcel->getActiveSheet()
    ->getStyle('A'.$i)
    ->getNumberFormat()
    ->setFormatCode(
        PHPExcel_Style_NumberFormat::FORMAT_TEXT
    );
    
    0 讨论(0)
  • 2020-12-21 18:29

    I've not tested it, but possibly setting the cell as "quotePrefix" may prevent MS Excel from trying to convert the datatype when editing it with MS Excel

    $objPHPExcel->getActiveSheet()
        ->getStyle('A2:O128')
        ->setQuotePrefix(true);
    

    Excel2007 only

    0 讨论(0)
提交回复
热议问题