question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Feature request: allow cell errors to be ignored

See original GitHub issue

I need to produce a spreadsheet where cells contain long numerical strings, representing object IDs.

If a value is added to the cell as an int, precision is lost and the value is shown with scientific notation. Eg 12345678901234567890 is stored as 12345678901234500000 and is rendered as 1.23457E+19.

If a value is added to the cell as a str, then we avoid the precision problems, but Excel displays a warning about a number being stored as text.

image

My current workaround is to hack Worksheet._assemble_xml_file so that it adds XML like the following:

  <ignoredErrors>
    <ignoredError sqref="A:A" numberStoredAsText="1"/>
    <ignoredError sqref="D:D" numberStoredAsText="1"/>
  </ignoredErrors>

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:2
  • Comments:10 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
jmcnamaracommented, Aug 12, 2020

Just to let you know that I am working on this feature and it will be in the next release.

2reactions
inglespcommented, Aug 10, 2020

@Hugovdberg I have a function called monkey_path_worksheet:

def monkey_patch_worksheet(ws):
    _old_write_page_margins = ws._write_page_margins

    def _write_page_margins_and_other_stuff(self):
        _old_write_page_margins()

        self._xml_start_tag("ignoredErrors")

        for col in self.ignore_error_cols:
            col_name = xlsxwriter.utility.xl_col_to_name(col)

            attributes = [
                ("sqref", f"{col_name}:{col_name}"),
                ("numberStoredAsText", "1"),
            ]
            self._xml_empty_tag("ignoredError", attributes)
        self._write_sheet_view()
        self._xml_end_tag("ignoredErrors")

    ws._write_page_margins = types.MethodType(_write_page_margins_and_other_stuff, ws)

This changes the _write_page_margins method on the worksheet class so that it also adds the ignoredErrors element.

I use it like this:

ws = wb.add_worksheet(tab_name)
monkey_patch_worksheet(ws)
ws.ignore_error_cols = [1, 2, 3]  # change this to match your needs!

Does that help?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Interest in ignore errors feature - Google Groups
The IgnoredError.sqref definition is wrong (sqref = CellRange, no call) and to fix that, you need to redeclare the class as the metaclass...
Read more >
Power Query M Primer (Part 15): Error Handling | Ben Gribaudo
Suppose the expression defining a table column value errors for one cell out of the entire table. In an exception-based world, this error...
Read more >
More on data validation - Microsoft Support
Excel ignores the data validation until you correct the error. Cells referenced in formulas are correct - If a referenced cell changes so...
Read more >
Video: Input and error messages - Microsoft Support
To help people decide what drop-down list option to select, and even to let them know that a cell contains a drop-down list,...
Read more >
How to Stop or Control Green Error Checking Markers in Excel
If a user has clicked the Smart Tag in a cell and selected Ignore Error for specific cells, this can be reset: In...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found