PHPExcel:双精度/浮点的科学记数法
问题如下: 我们正在创建类 testObject 的实例并用 double 填充 var。
TestExcel 类从 PhpExcel 扩展,当将对象 testObject 提交到构造函数中时,我们在执行 var_dump 时会得到 var 的科学记数法。
任何人都可以帮助我们吗? 我和我的同事不明白如何通过扩展 phpExcel 类来更改实例的内容。
当我们不进行扩展时,var_dump 返回正确的表示法。 -- 200000 进行扩展时我们得到科学记数法——2.0E+5
// instance of the testObject
$number = new testObject();
$number->setNumber((double)200000);
// contruct testExcelClass
$excel = new TestExcel($number);
// Class TestObject
class testObject {
private $number;
public function setNumber($number){
$this->number = $number;
}
public function getNumber(){
return $this->number;
}
}
// class test excell extends from phpexcel (http://www.codeplex.com/PHPExcel)
class TestExcel extends PHPExcel {
private $number;
public function __construct($number){
parent::__construct();
$this->number = $number;
print_r($this->number); exit();
}
}
The problem is the following:
We are creating an instance of a class testObject and fill a var with a double.
A class TestExcel extends from PhpExcel and when submitting the object testObject into the constructor we get a scientific notation of the var when we do a var_dump.
Can anyone help us out. My colleagues and I don't understand how it is possible that the content of an instance can be changed by extending the phpExcel class.
When we don't do the extension, the var_dump returns the correct notation. -- 200000
When doing the extension we get the scientific notation -- 2.0E+5
// instance of the testObject
$number = new testObject();
$number->setNumber((double)200000);
// contruct testExcelClass
$excel = new TestExcel($number);
// Class TestObject
class testObject {
private $number;
public function setNumber($number){
$this->number = $number;
}
public function getNumber(){
return $this->number;
}
}
// class test excell extends from phpexcel (http://www.codeplex.com/PHPExcel)
class TestExcel extends PHPExcel {
private $number;
public function __construct($number){
parent::__construct();
$this->number = $number;
print_r($this->number); exit();
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可能应该设置单元格的格式以具有所需的数字格式。 我不确定确切的功能,请检查文档。
you should probably set formatting of the cell to have the desired number format. i am not sure about the exact function, check the docs.
这似乎是 PHP 5.2.6 中显示错误符号的问题。
php 5.2.8 解决了这个错误。
it seemed to be a problem in PHP 5.2.6 that displayed the wrong notation.
php 5.2.8 solved this bug.