diff --git a/frappe/utils/csvutils.py b/frappe/utils/csvutils.py index 1d326bd1c5..f73f80582a 100644 --- a/frappe/utils/csvutils.py +++ b/frappe/utils/csvutils.py @@ -175,12 +175,18 @@ def getlink(doctype, name): return '%(name)s' % locals() def get_csv_content_from_google_sheets(url): + # https://docs.google.com/spreadsheets/d/{sheetid}}/edit#gid={gid} validate_google_sheets_url(url) - + # get gid, defaults to first sheet + if "gid=" in url: + gid = url.rsplit('gid=', 1)[1] + else: + gid = 0 # remove /edit path url = url.rsplit('/edit', 1)[0] - # add /export path, defaults to first sheet - url = url + '/export?format=csv&gid=0' + # add /export path, + url = url + '/export?format=csv&gid={0}'.format(gid) + headers = { 'Accept': 'text/csv' }