-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SetCalculatedValue Avoid Casting String to Numeric (#3685)
Fix #3658. Readers will call `setCalculatedValue` to save the original calculated value for a cell that contains a formula; this affects the result of `getOldCalculatedValue`. The set routine automatically casts numeric values to float, which is not appropriate when the calculated value is explicitly set to a string type. An optional parameter is added to the set routine to indicate whether a cast is appropriate (default is true so userland uses of this method will remain unaffected). The readers for Xlsx, Xls, Xml, Ods, and Slk are all changed to set the new parameter appropriately. Gnumeric saves the formula, but does not appear to save the result, so no change is needed there. Html and Csv save the result but not the formula (for preCalculateFormulas true - they save the formula but not the result for false), so no change is needed for them. It is not clear what the use case is for oldCalculatedValue, but it does date back to PhpExcel. A possible use case is demonstrated in the new tests - Excel function INFO is not implemented, so getCalculatedValue will generally return null on such a cell, but will return oldCalculatedValue when it sees that the function is not implemented but oldCalculatedValue has been set (typically by loading an existing spreadsheet), so the result that is on the spreadsheet will be available to the program which loaded it. Reading a spreadsheet which has been created with preCalculateFormulas false will, or at least should, result in a null oldCalculatedValue. This was true for Xls, Xml, and Slk. Xlsx was actually storing 0 in this situation; that wasn't precisely a problem, but it wasn't necessary and seems misleading. Xlsx Writer is changed to no longer set a value in this situation. This is technically a break, but the existing code was wrong; one unit test needed a very minor modification as a result of this change.
- Loading branch information
Showing
15 changed files
with
314 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,4 +37,10 @@ | |
[ | ||
[null], | ||
], | ||
'issue3568' => [ | ||
['="00"&B1', '123'], | ||
], | ||
'unimplemented function' => [ | ||
['=INFO("SYSTEM")'], | ||
], | ||
]; |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
ID;PWXL;N;E | ||
P;PGeneral | ||
P;P0 | ||
P;P0.00 | ||
P;P#,##0 | ||
P;P#,##0.00 | ||
P;P#,##0_);;\(#,##0\) | ||
P;P#,##0_);;[Red]\(#,##0\) | ||
P;P#,##0.00_);;\(#,##0.00\) | ||
P;P#,##0.00_);;[Red]\(#,##0.00\) | ||
P;P"$"#,##0_);;\("$"#,##0\) | ||
P;P"$"#,##0_);;[Red]\("$"#,##0\) | ||
P;P"$"#,##0.00_);;\("$"#,##0.00\) | ||
P;P"$"#,##0.00_);;[Red]\("$"#,##0.00\) | ||
P;P0% | ||
P;P0.00% | ||
P;P0.00E+00 | ||
P;P##0.0E+0 | ||
P;P#\ ?/? | ||
P;P#\ ??/?? | ||
P;Pyyyy/mm/dd | ||
P;Pdd/mmm/yy | ||
P;Pdd/mmm | ||
P;Pmmm/yy | ||
P;Ph:mm\ AM/PM | ||
P;Ph:mm:ss\ AM/PM | ||
P;Ph:mm | ||
P;Ph:mm:ss | ||
P;Pyyyy/mm/dd\ h:mm | ||
P;Pmm:ss | ||
P;Pmm:ss.0 | ||
P;P@ | ||
P;P[h]:mm:ss | ||
P;P_("$"* #,##0_);;_("$"* \(#,##0\);;_("$"* "-"_);;_(@_) | ||
P;P_(* #,##0_);;_(* \(#,##0\);;_(* "-"_);;_(@_) | ||
P;P_("$"* #,##0.00_);;_("$"* \(#,##0.00\);;_("$"* "-"??_);;_(@_) | ||
P;P_(* #,##0.00_);;_(* \(#,##0.00\);;_(* "-"??_);;_(@_) | ||
P;FCalibri;M220;L9 | ||
P;FCalibri;M220;L9 | ||
P;FCalibri;M220;L9 | ||
P;FCalibri;M220;L9 | ||
P;ECalibri;M220;L9 | ||
P;ECalibri Light;M360;L55 | ||
P;ECalibri;M300;SB;L55 | ||
P;ECalibri;M260;SB;L55 | ||
P;ECalibri;M220;SB;L55 | ||
P;ECalibri;M220;L18 | ||
P;ECalibri;M220;L21 | ||
P;ECalibri;M220;L61 | ||
P;ECalibri;M220;L63 | ||
P;ECalibri;M220;SB;L64 | ||
P;ECalibri;M220;SB;L53 | ||
P;ECalibri;M220;L53 | ||
P;ECalibri;M220;SB;L10 | ||
P;ECalibri;M220;L11 | ||
P;ECalibri;M220;SI;L24 | ||
P;ECalibri;M220;SB;L9 | ||
P;ECalibri;M220;L10 | ||
P;ECalibri;M220;L9 | ||
P;ECalibri Light;M360;L55 | ||
P;ECalibri;M300;SB;L55 | ||
P;ECalibri;M260;SB;L55 | ||
P;ECalibri;M220;SB;L55 | ||
P;ECalibri;M220;L18 | ||
P;ECalibri;M220;L21 | ||
P;ECalibri;M220;L61 | ||
P;ECalibri;M220;L63 | ||
P;ECalibri;M220;SB;L64 | ||
P;ECalibri;M220;SB;L53 | ||
P;ECalibri;M220;L53 | ||
P;ECalibri;M220;SB;L10 | ||
P;ECalibri;M220;L11 | ||
P;ECalibri;M220;SI;L24 | ||
P;ECalibri;M220;SB;L9 | ||
P;ECalibri;M220;L10 | ||
P;ESegoe UI;M200;L9 | ||
P;ECalibri;M220;L9 | ||
F;P0;DG0G8;M290 | ||
B;Y4;X1;D0 0 3 0 | ||
O;L;D;V0;G100 0.001 | ||
C;Y1;X1;K123 | ||
C;Y2;K124;ER[-1]C+1 | ||
C;Y3;K"00123";E"00"&R[-2]C | ||
C;Y4;K"pcdos";EINFO("SYSTEM") | ||
E |
Binary file not shown.
Binary file not shown.
Oops, something went wrong.