-
Notifications
You must be signed in to change notification settings - Fork 3.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ignore cell errors in Excel (e.g. "Number Stored as Text") #1141
Comments
Setting a style of |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. |
@MarkBaker I'm having similar issues but a different warning, that "The formula in this cell differs from the formula in this area of the spreadsheet." Are you aware of any way to disable these warnings entirely? Or a way to resolve them? I have a fairly complex and customized export that is seeing these errors more and more and my client has required me to fi the "little green triangles." Here is a sample: What's frustrating/confusing is that these errors don't seem to be consistent. For example, if you look at the first section, the Loan Amount and Initial Funding columns have no issues. However, the next section is displaying errors, despite the cell values following the exact same pattern, with the exception the first row has $0, and the next has a different value. Then if you look at the second section, the Spread column, has a warning because 4.25% is not the same as 4.50% so there is a warning. I have tried multiple combinations of styling, number formatting, etc. and cannot seem to eliminate these warnings. Here is a code sample for the screen shot:
Any feedback or input is greatly appreciated! |
Reopening; I will submit a PR later today to address this. The suggestion above to use |
Fix PHPOffice#1141, which had been closed as stale, but which I have reopened. Excel will show cells with certain "errors" with a green triangle in the upper left. The suggestion in the issue to use quotePrefix to suppress the numberStoredAsText error is ineffective. In Excel, the user can turn this indicator off for individual cells. Cells where this is turned off can be detected at read time, and PhpSpreadsheet will now process those. In addition, the user can explicitly set the ignored error as in Excel. ```php $cell->setIgnoredErrorNumberStoredAsText(true); ``` There are a number of different errors that can be ignored in this fashion. This PR implements `numberStoredAsText` (which is likely to be by far the most useful one), `formula`, `twoDigitTextYear`, and `evalError`, all of which are demonstrated in the new test spreadsheet. There are several others for which I am not able to create good examples; I have not implemented those, but they can be easily added if needed (`calculatedColumn`, `emptyCellReference`, `formulaRange`, `listDataValidation`, and `unlockedFormula`).
* Add Ability to Ignore Cell Errors in Excel Fix #1141, which had been closed as stale, but which I have reopened. Excel will show cells with certain "errors" with a green triangle in the upper left. The suggestion in the issue to use quotePrefix to suppress the numberStoredAsText error is ineffective. In Excel, the user can turn this indicator off for individual cells. Cells where this is turned off can be detected at read time, and PhpSpreadsheet will now process those. In addition, the user can explicitly set the ignored error as in Excel. ```php $cell->setIgnoredErrorNumberStoredAsText(true); ``` There are a number of different errors that can be ignored in this fashion. This PR implements `numberStoredAsText` (which is likely to be by far the most useful one), `formula`, `twoDigitTextYear`, and `evalError`, all of which are demonstrated in the new test spreadsheet. There are several others for which I am not able to create good examples; I have not implemented those, but they can be easily added if needed (`calculatedColumn`, `emptyCellReference`, `formulaRange`, `listDataValidation`, and `unlockedFormula`). * Scrutinizer A new change, a new Scrutinizer false positive. * Move Ignored Errors to Own Class In response to comments from @MarkBaker, implement ignoredError as a new class. This simplifies Cell by requiring only 1 new method, rather than 8+. This requires a slightly more complicated syntax. ```php $cell->getIgnoredErrors()->setNumberScoredAsText(true); ``` Mark had also suggested that there might be a pre-existing regexp for processing the cells/cellranges when reading the sqref attribute. Those in Calculation are too complicated (read "non-performant") for this piece of code; the one in Coordinates is slightly less complicated than Calculation, but still more complicated than the one I'm using, and doesn't handle ranges.
This is:
What is the expected behavior?
When a cell contains a value that looks like a number but is intentionally formatted as text (sometimes this is desirable because the values might not always be purely numeric and you don't want Excel to reformat them), and written to an XLSX file, Excel displays a warning beside the cell when viewing the worksheet.
Excel has an option to "Ignore" the error, which appears to be a flag that is then written to the cell. It would be great if this functionality could be exposed as part of the PhpSpreadsheet API.
For reference, there is a JavaScript project for writing XLSX files called SheetJS which has this feature, here is how they do it.
What is the current behavior?
The warning is visible to users next to Text formatted cells that Excel thinks are numbers, and there's nothing I can do about it. Users might choose to "Convert to Number" and create formatting problems (including data corruption if exported to CSV).
What are the steps to reproduce?
N/A
The text was updated successfully, but these errors were encountered: