nithinmurali / pygsheets

Google Sheets Python API v4
https://pygsheets.readthedocs.io/en/latest
Other
1.5k stars 220 forks source link

add_chart support for referencing data in another worksheet #333

Open DreadPirateShawn opened 5 years ago

DreadPirateShawn commented 5 years ago

Is your feature request related to a problem? Please describe. I'm trying to add a worksheet with a chart that references data from another worksheet. However, the add_chart method doesn't allow addresses from another worksheet, only local addresses.

The crux of the problem appears to be that the domain and ranges are passed directly to format_addr, which doesn't handle worksheet names.

In [1]: from pygsheets.utils import format_addr

In [2]: format_addr("A2")
Out[2]: (2, 1)

In [3]: format_addr("'Monthly'!A2")
---------------------------------------------------------------------------
IncorrectCellLabel                        Traceback (most recent call last)
<ipython-input-4-e13c9af34530> in <module>()
----> 1 format_addr("'Monthly'!A2")

/highland/jira-to-sheets/venv/lib/python2.7/site-packages/pygsheets/utils.pyc in format_addr(addr, output)
    121                         col += (ord(c) - _MAGIC_NUMBER) * (26 ** i)
    122                 else:
--> 123                     raise IncorrectCellLabel(addr)
    124                 return int(row), int(col)
    125             elif output == 'label':

IncorrectCellLabel: 'Monthly'!A2

Describe the solution you'd like I'd like to be able to pass a crange object to add_chart for the domain and ranges params.

Any other info Nope.

nithinmurali commented 5 years ago

Adding support for cranges looks like a good solution.