You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CHANGELOG.md
+11-1Lines changed: 11 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org).
10
10
### Added
11
11
12
12
- Add to all readers the option to allow or forbid fetching external images. This is unconditionally allowed now. The default will be set to "allow", so no code changes are necessary. However, we are giving consideration to changing the default. [PR #4543](https://github.com/PHPOffice/PhpSpreadsheet/pull/4543)
13
+
- Address Excel Inappropriate Number Format Substitution. [PR #4532](https://github.com/PHPOffice/PhpSpreadsheet/pull/4532)
13
14
14
15
### Removed
15
16
@@ -29,7 +30,16 @@ and this project adheres to [Semantic Versioning](https://semver.org).
29
30
30
31
### Fixed
31
32
32
-
- Nothing yet.
33
+
- Html Writer Conditional Formatting Inline Css. [Issue #4539](https://github.com/PHPOffice/PhpSpreadsheet/issues/4539)[PR #4541](https://github.com/PHPOffice/PhpSpreadsheet/pull/4541)
34
+
- Do not use htmlspecialchars when formatting XML. [Issue #4537](https://github.com/PHPOffice/PhpSpreadsheet/issues/4537)[PR #4540](https://github.com/PHPOffice/PhpSpreadsheet/pull/4540)
35
+
- Writer Html/Pdf support RTL alignment of tables. [Issue #1104](https://github.com/PHPOffice/PhpSpreadsheet/issues/1104)[PR #4535](https://github.com/PHPOffice/PhpSpreadsheet/pull/4535)
36
+
- Xlsx Reader use dynamic arrays if spreadsheet did so. [PR #4533](https://github.com/PHPOffice/PhpSpreadsheet/pull/4533)
- Micro-optimization in getSheetByName. [PR #4499](https://github.com/PHPOffice/PhpSpreadsheet/pull/4499)
40
+
- Bug in resizeMatricesExtend. [Issue #4451](https://github.com/PHPOffice/PhpSpreadsheet/issues/4451)[PR #4474](https://github.com/PHPOffice/PhpSpreadsheet/pull/4474)
41
+
- Allow Replace of Dummy Function with Custom Function. [PR #4544](https://github.com/PHPOffice/PhpSpreadsheet/pull/4544)
42
+
- Preserve 0x0a in Strings if Desired. [Issue #347](https://github.com/PHPOffice/PhpSpreadsheet/issues/347)[PR #4536](https://github.com/PHPOffice/PhpSpreadsheet/pull/4536)
This is documentation for some behavior in Excel itself which we
4
+
just do not understand, or which may come as a surprise to the user.
5
+
6
+
## Date Number Format
7
+
8
+
My system short date format is set to `yyyy-mm-dd`. Excel, for a very long time, did not include that amongst its formatting choices for dates, so it needed to be added as a custom format - no big deal. It has recently been added to the list of date formats, but ...
9
+
10
+
I used Excel to create a spreadsheet, and included some dates, specifying `yyyy-mm-dd` formatting. When I looked at the resulting spreadsheet, I was surprised to see that Excel had stored the style not as `yyyy-mm-dd`, but rather as builtin style 14 (system short date format). Apparently the fact that the Excel styling matched my system choice was sufficient for it to override my choice! This is an astonishingly user-hostile implementation. Even though there are formats which, by design, "respond to changes in regional date and time settings", and even though the format I selected was not among those, Excel decided it was appropriate to vary the display even when I said I wanted an unvarying format. I assume, but have not confirmed, that this applies to formats other than `yyyy-mm-dd`.
11
+
12
+
Note that this is not a problem when using PhpSpreadsheet to set the style, only when you let Excel do it. And, in that case, after a little experimentation, I figured out a format that Excel doesn't sabotage `[Black]yyyy-mm-dd`.
13
+
14
+
If you have a spreadsheet that has been altered in this way, it can be fixed with the following PhpSpreadsheet code:
15
+
```php
16
+
foreach ($spreadsheet->getCellXfCollection() as $style) {
17
+
$numberFormat = $style->getNumberFormat();
18
+
// okay to use NumberFormat::SHORT_DATE_INDEX below
19
+
if ($numberFormat->getBuiltInFormatCode() === 14) {
20
+
$numberFormat->setFormatCode('yyyy-mm-dd');
21
+
}
22
+
}
23
+
```
24
+
Starting with PhpSpreadsheet 4.5.0, this can be simplified to:
You have a time in one cell, and a time in another, and you want to subtract and display the result in `h:mm` format. No problem if the result is positive. But, if it's negative, Excel just fills the cell with `#`. There is a solution of sorts. If you use a 1904 base date (default on Mac), the negative interval will work just fine. Alas, no dice if you use a 1900 base data (default on Windows). No idea why they can't fix that - the existing implementation can't really be something that anybody actually wants. Note that it is *not* safe to change the base date for an existing spreadsheet, so, if this is something you want to do, make sure you change the base date before populating any data.
35
+
36
+
## Long-ago Dates
37
+
38
+
Excel does not support dates before either 1900-01-01 (Windows default) or 1904-01-01 (Mac default). For the 1900 base year, there is the additional problem that non-existent date 1900-02-29 is squeezed between 1900-02-28 and 1900-03-01.
39
+
40
+
## Weird Fractions
41
+
42
+
Similar fraction formats have inconsistent results in Excel. For example, if a cell contains the value 1 and the cell's format is `0 0/0`, it will display as `1 0/1`. But, if the cell's format is `? ??/???`, it will display as `1`. See [this issue](https://github.com/PHPOffice/PhpSpreadsheet/issues/3625), which remains open because, in the absence of usable documentation, we aren't sure how to handle things.
43
+
44
+
## COUNTIF and Text Cells
45
+
46
+
In Excel, COUNTIF appears to ignore text cells, behavior which doesn't seem to be documented anywhere. See [this issue](https://github.com/PHPOffice/PhpSpreadsheet/issues/3802), which remains open because, in the absence of usable documentation, we aren't sure how to handle things.
Copy file name to clipboardExpand all lines: docs/topics/The Dating Game.md
+9-9Lines changed: 9 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -14,20 +14,20 @@ Open/Libre Office and Gnumeric don't have this limitation, and negative date/tim
14
14
To write a date in a cell using PhpSpreadsheet, we need to calculate the serialized Excel datestamp for that date. Methods to do this are available in the Shared\Date class, which provides a number of methods for conversion between different date options typically used in PHP applications (Unix timestamp, PHP DateTime objects and some recognisable formatted strings) and the Excel serialized value; and vice versa.
15
15
16
16
- Shared\Date::convertIsoDate()
17
-
- Converts a date/time in [ISO-8601 standard format](https://en.wikipedia.org/wiki/ISO_8601) to an Excel serialized timestamp
17
+
- Converts a date/time in [ISO-8601 standard format](https://en.wikipedia.org/wiki/ISO_8601) to an Excel serialized timestamp
18
18
- Shared\Date::PHPToExcel()
19
-
- Converts a Unix timestamp, a PHP DateTime object, or a recognisable formatted string to an Excel serialized timestamp
19
+
- Converts a Unix timestamp, a PHP DateTime object, or a recognisable formatted string to an Excel serialized timestamp
20
20
- Shared\Date::dateTimeToExcel()
21
-
- Converts a Unix timestamp to an Excel serialized timestamp
21
+
- Converts a Unix timestamp to an Excel serialized timestamp
22
22
- Shared\Date::timestampToExcel()
23
-
- Converts a PHP DateTime object to an Excel serialized timestamp
23
+
- Converts a PHP DateTime object to an Excel serialized timestamp
24
24
- Shared\Date::formattedPHPToExcel()
25
-
- Converts year, month, day, hour, minute, and second to an Excel serialized timestamp
25
+
- Converts year, month, day, hour, minute, and second to an Excel serialized timestamp
26
26
- Shared\Date::excelToDateTimeObject()
27
-
- Converts an Excel serialized timestamp to a PHP DateTime object
27
+
- Converts an Excel serialized timestamp to a PHP DateTime object
28
28
- Shared\Date::excelToTimestamp()
29
-
- Converts an Excel serialized timestamp to a Unix timestamp.
30
-
- The use of Unix timestamps, and therefore this function, is discouraged: they are not Y2038-safe on a 32-bit system, and have no timezone info.
29
+
- Converts an Excel serialized timestamp to a Unix timestamp.
30
+
- The use of Unix timestamps, and therefore this function, is discouraged: they are not Y2038-safe on a 32-bit system, and have no timezone info.
31
31
32
32
We probably also want to set the number format mask for the cell so that it will be displayed as a human-readable date.
33
33
```php
@@ -184,7 +184,7 @@ MS Excel allows any separator character between hours/minutes/seconds; PhpSpread
184
184
185
185
### Duration (Elapsed Time)
186
186
187
-
Excel also supports formatting a value as a duration; a total number of hours, minutes or seconds rather than a time of day.
187
+
Excel also supports formatting a value as a duration; a total number of hours, minutes or seconds rather than a time of day. However, please note that negative durations are supported only if using base year 1904 (Mac default).
0 commit comments