Date detection wrong on proper case color number format

Issue #865 resolved
Jan Simbera created an issue

In case the number format of the cell contains a color definition such as [Red], date format is incorrectly detected by the is_date_format() function from the styles\ module.

This can lead to ValueError on cell value retrieval if the cell contains a large or small enough number so that the Python datetime.datetime date boundaries are exceeded.

Updating the line 95 of the module to

COLORS = "(\[black|blue|cyan|green|magenta|red|white|yellow\])"

fixes the problem (due to lowercasing of the format, this regex never matched previously).

This triggers an error: cell containing a number -781682,44 with a number format ;[Red]\(#,##0.00\);.

Comments (3)

  1. CharlieC

    Thanks for the report but I can't reproduce it when dropping it into the tests. The regex uses re.IGNORECASE to handle colours correctly.

  2. Jan Simbera reporter

    Sorry, I was using alpha1 version where the IGNORECASE flag was not present. Thanks for pointing out!

  3. Log in to comment