ValueError when using .rows on sheet with hyperlinks

Issue #328 resolved
Anonymous created an issue

I have a workbook containing a worksheet with hyperlinks. When loading the workbook (use_iterators=True and data_only=True) and reading rows of sheet called "Modification Summary", I get a ValueError.

Comments (12)

  1. Charlie Clark

    I can confirm this with the following code:

    from openpyxl import load_workbook
    wb = load_workbook("Issues/bug328.xlsx", read_only=True, data_only=True)
    ws = wb['Modification Summary']
    for row in ws.rows:
        for cell in row:

    The traceback is

    Traceback (most recent call last):
      File "/Applications/", line 1, in <module>
        # Used internally for debug sandbox under external interpreter
      File "/Users/charlieclark/Projects/openpyxl/openpyxl/worksheet/", line 186, in get_squared_range
        retrieved_columns = dict([(c.column, c) for c in cells])
      File "/Users/charlieclark/Projects/openpyxl/openpyxl/worksheet/", line 186, in <listcomp>
        retrieved_columns = dict([(c.column, c) for c in cells])
      File "/Users/charlieclark/Projects/openpyxl/openpyxl/worksheet/", line 222, in get_cells
        value, data_type, style_id)
      File "/Users/charlieclark/Projects/openpyxl/openpyxl/cell/", line 20, in __init__
      File "/Users/charlieclark/Projects/openpyxl/openpyxl/cell/", line 92, in _set_value
        value = float(value)
    builtins.ValueError: could not convert string to float:

    Doesn't happen with when not read_only.

  2. Eric Gazoni

    looked at the issue, it's because we assume that a formula always gives back a numerical value, while it could (in this case) be a link with no "cache" to cast to int/float. I'm working on a fix, just have to figure out how to correct the assumption without breaking something else in the process ;-)

  3. Charlie Clark

    Standard cells use a regex to check for numerical values in such cases. This can probably be added to the the ReadOnlyCell as el.FindText('v') will always return an empty string for empty tags and only None if there is no such tag.

  4. Log in to comment