PHPExcel converts dot after writing in comma

被刻印的时光 ゝ 提交于 2019-12-13 02:51:53

问题


I generate an Excel file with importing a csv file. In CSV has contents with following numbers
4.0238484
5.3833888
dot seperated
But if I write an Excel file than the column show me the numbers in following format
4,0238484
5,3833888
I want the dot instead of comma.
How can I make it?
PHPExcel Version 1.7.7


回答1:


Check the locale settings for the version of MS Excel that you are using to view the generated file: if it's set to a locale that uses a decimal comma rather than a decimal point, then this is what you will see. Floating point numbers in PHPExcel are managed with a decimal point (PHP doesn't offer any alternative for numbers), but MS Excel has its own formatting rules based on locale.




回答2:


In PhpSpreadsheet (next generation of PhpExcel) you can avoid it's by this:

$sheet->setCellValueExplicitByColumnAndRow(__COL_INDEX__, __ROW_INDEX__, __SOME_DATA__, DataType::TYPE_STRING);

setCellValueExplicitByColumnAndRow can force turn your data into string



来源:https://stackoverflow.com/questions/30185253/phpexcel-converts-dot-after-writing-in-comma

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!