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
- [x] a bug report
- [ ] a feature request
- [x] **not** a usage question (ask them on https://stackoverflow.com/questions/tagged/phpspreadsheet or https://gitter.im/PHPOffice/PhpSpreadsheet)
What is the expected behavior?
This is an offshoot of #2490. In that issue, the user reported that PhpSpreadsheet could not read an xls file, and the reason was because the file was in BIFF4 format, unsupported by PhpSpreadsheet, and basically obsolete since 1993. I suggested to use a conversion routine that comes with Excel to convert the file to xlsx format. I will upload the resulting file, which was satisfactory for the user.
But ... when I used PhpSpreadsheet to load and save that resulting file, the fill colors were wrong. Most of the cells use a solid yellow fill which is not present in the original. So, PhpSpreadsheet appears to have a bug, but ... not so fast! When I copy/paste the white background cell from A3 to a new spreadsheet, it arrives in the destination with a yellow background! So, something about the spreadsheet says "yellow background" to both Excel and PhpSpreadsheet, even though it has a white background.
I originally thought the problem had something to do with themes, but, when I substituted the theme from the original to the one created by PhpSpreadsheet, the yellow background was still there. Looking deeper, I believe I found the cause of the problem. The original styles.xml file contains a list of 64 indexed colors. This section is not typically found in the styles.xml file. Instead, a default set of indexed colors, numbered from 0 to 56, is used. When we encounter a color reference to index n, we actually use index n-7 from the default list. Not only is the list included in our problem file different from the default at several points, but it is also 7 entries longer, apparently at the beginning of the list, and I believe that the intention is that index n should be used, not n-7. The fill colors are described as indexes 13, 9, and 11; when the normal set is used these become mapped to indexes 6, 2, and 4, which are colors yellow, white, and green, which corresponds to how PhpSpreadsheet (and Excel when copying from this workbook to another) treat them. However, the colors actually used are F0FBFF (which is index 9 in this scheme), white (FFFFFF index 13 among others), and F0F0F0 (index 11); I think it is no coincidence that these are the precise color indexes which wind up mismapped.
I imagine that, knowing the problem, there are ways to deal with it. However, since this will probably involve changes to areas which I'm already changing in PR #2471, and since it seems to be a very rare problem, I am going to defer thinking about this one till after that has merged.
What is the current behavior?
See 'expected behavior'.
What are the steps to reproduce?
See 'expected behavior'.
Which versions of PhpSpreadsheet and PHP are affected?
FixPHPOffice#2499, which see for details of an obscure problem affecting both PhpSpreadsheet and Excel. Add support for palette contained in workbook styles. This seems to be a very rare occurrence, so allow it only when the palette contains exactly 64 entries. If there are other possibilities, we'll presumably have a new workbook to guide us how to handle them. Also add some tests for specification of indexed color without palette, another rarity (no in-range examples amongst our current files). Also change one private static array, initialized once at run-time and never changed, to a constant.
Fix#2499, which see for details of an obscure problem affecting both PhpSpreadsheet and Excel. Add support for palette contained in workbook styles. This seems to be a very rare occurrence, so allow it only when the palette contains exactly 64 entries. If there are other possibilities, we'll presumably have a new workbook to guide us how to handle them. Also add some tests for specification of indexed color without palette, another rarity (no in-range examples amongst our current files). Also change one private static array, initialized once at run-time and never changed, to a constant.
This is:
What is the expected behavior?
This is an offshoot of #2490. In that issue, the user reported that PhpSpreadsheet could not read an xls file, and the reason was because the file was in BIFF4 format, unsupported by PhpSpreadsheet, and basically obsolete since 1993. I suggested to use a conversion routine that comes with Excel to convert the file to xlsx format. I will upload the resulting file, which was satisfactory for the user.
But ... when I used PhpSpreadsheet to load and save that resulting file, the fill colors were wrong. Most of the cells use a solid yellow fill which is not present in the original. So, PhpSpreadsheet appears to have a bug, but ... not so fast! When I copy/paste the white background cell from A3 to a new spreadsheet, it arrives in the destination with a yellow background! So, something about the spreadsheet says "yellow background" to both Excel and PhpSpreadsheet, even though it has a white background.
I originally thought the problem had something to do with themes, but, when I substituted the theme from the original to the one created by PhpSpreadsheet, the yellow background was still there. Looking deeper, I believe I found the cause of the problem. The original styles.xml file contains a list of 64 indexed colors. This section is not typically found in the styles.xml file. Instead, a default set of indexed colors, numbered from 0 to 56, is used. When we encounter a color reference to index
n
, we actually use indexn-7
from the default list. Not only is the list included in our problem file different from the default at several points, but it is also 7 entries longer, apparently at the beginning of the list, and I believe that the intention is that indexn
should be used, notn-7
. The fill colors are described as indexes 13, 9, and 11; when the normal set is used these become mapped to indexes 6, 2, and 4, which are colors yellow, white, and green, which corresponds to how PhpSpreadsheet (and Excel when copying from this workbook to another) treat them. However, the colors actually used are F0FBFF (which is index 9 in this scheme), white (FFFFFF index 13 among others), and F0F0F0 (index 11); I think it is no coincidence that these are the precise color indexes which wind up mismapped.I imagine that, knowing the problem, there are ways to deal with it. However, since this will probably involve changes to areas which I'm already changing in PR #2471, and since it seems to be a very rare problem, I am going to defer thinking about this one till after that has merged.
What is the current behavior?
See 'expected behavior'.
What are the steps to reproduce?
See 'expected behavior'.
Which versions of PhpSpreadsheet and PHP are affected?
All.
issue.2490.xlsx
The text was updated successfully, but these errors were encountered: