简体   繁体   English

PHP-像读取xls文件一样读取PHPExcel上的单元格

[英]PHP - Read cell on PHPExcel as it is on xls file

I have some cell on excel file with General format. 我在具有常规格式的excel文件上有一些单元格。 The value of this cell is 该单元格的值是

1,99
10,88

Using phpexcel, When I read the cell i got: 使用phpexcel,当我阅读单元格时:

1.99
10.88

How can I get the original value 1,99 ? 我怎样才能得到1,99的原始值?

I did try 我确实尝试过

$sheet->getCell("C2")->getValue();
$sheet->getCell("C2")->getFormattedValue()

But both return the 但是两者都返回

1.99
10.88

PHPExcel cannot possibly know the locale setting that are configured for any users version of MS Excel, and handling of locale-specific formattings (such as decimal commas rather than points) is specific to an instance of MS Excel itself. PHPExcel 可能无法知道为任何用户版本的MS Excel配置的语言环境设置,并且特定于语言环境的格式(例如十进制逗号而不是点)的处理特定于MS Excel本身的实例。 If I opened that same file in my copy of MS Excel, then I would see a decimal point... ie local settings aren't defined in the file, they're purely in the MS Excel GUI. 如果我在MS Excel副本中打开了相同的文件,那么我会看到一个小数点...即,本地设置未在文件中定义,它们完全在MS Excel GUI中。

If you need to format specific to a users locale, then retrieve the raw data using getValue() , and use PHP's Intl NumberFormatter to localise the format. 如果您需要特定于用户区域设置的格式,请使用getValue()检索原始数据,然后使用PHP的Intl NumberFormatter来对格式进行本地化。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM