2014-02-18 16:40
浏览 16


I'm having some problems with my code in PHPexcel on generating report. I've got numbers like 0001,0002,0087 in a textbox and when I transfer it to Excel, to make a report the output is 1,2,87. Why is that?

my var to pass value to generate excel report using PHPExcel

$aic = isset($_POST['aic'.$n]) ? $_POST['aic'.$n] : "";

图片转代码服务由CSDN问答提供 功能建议

我在PHPexcel中生成报告时遇到了一些问题。 我在文本框中有 0001 0002 0087 等数字,当我将它传输到Excel时,要生成一个报告,输出是 <代码> 1 ,<代码> 2 ,<代码> 87 。 为什么会这样?


  $ aic = isset($ _ POST ['aic  '。$ n])?  $ _POST ['aic'。$ n]:“”; 
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

2条回答 默认 最新

  • dongwo5110 2014-02-18 16:55

    I think setting your cell format to 4 digits number should do the trick. Try this:

    打赏 评论
  • duandie0921 2014-02-18 17:08

    The answer to your problem is given in the documentation ;)

    There are 2 ways of achieving that:

    Set the data type as string

    // Set cell A8 with a numeric value, but tell PHPExcel it should be treated as a string

    or set a specific number format:

    // Set cell A9 with a numeric value
    $objPHPExcel->getActiveSheet()->setCellValue('A9', 1513789642);
    // Set a number format mask to display the value as 11 digits with leading zeroes
    打赏 评论

相关推荐 更多相似问题