-
-
Notifications
You must be signed in to change notification settings - Fork 24
number overflow bug #17
Comments
This does not relate to this package. Consider reporting it to phpoffice/phpspreadsheet. |
are you kidding?
any way, I appreciate for the package. |
Expanentianal representation of the large data, e.g.
Usage of the |
I'm just a user. the best thing is I don't need to discuss with you. the package may sometimes not performance as user think. we put a string in , and out put an number. change or not change, it's up to you. |
no matter number +1 provide a configuration for datatype. |
Hello, I have a question about the format of spreadsheet. I use the package to export a excel, it may look like this:
$exporter = new Spreadsheet([ 'dataProvider' => $dataProvider, 'columns' => [ 'id', 'idCard', ] ]);
The idCard is an 18-digit number。but when I download the excel ,it show like this:
I just want it process the idCard as a string, this format is not I want. now the value is 411627200002085000. in fact, the value of idCard here is "411627200002084831". I think this bug is the number have overflowed。i think if I set the number format to text, it may work well. so I change code to this:
$exporter = new Spreadsheet([ 'dataProvider' => $dataProvider, 'columns' => [ 'id', [ 'attribute' => 'idCard', 'contentOptions' => [ 'numberFormat' => [ 'formatCode' => \PhpOffice\PhpSpreadsheet\Style\NumberFormat::FORMAT_TEXT, ], ], ] ] ]);
the result change to this, it changed the format to text, but it still an Incorrect value.
I checked the code, and i think the reason is the number is too big. when we set value to cell ,it has already overflowed. and then ,I set the format to text, the value can't change to the original value, so the text is wrong. the code is in "yii2tech/spreadsheet/src/Spreadsheet.php",
public function renderCell($cell, $content, $style = []) { $sheet = $this->getDocument()->getActiveSheet(); $sheet->setCellValue($cell, $content); $this->applyCellStyle($cell, $style); return $this; }
when we set cellvalue ,the value has already overflowed, and then I can do noting to change the value to original value. I try to use setCellValueExplicit, and it work well.
Could you please change the function setCellValue to setCellValueExplicit, so I can set the value explicit?
The text was updated successfully, but these errors were encountered: