Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spaces in sheets names #50

Closed
lfaucheux opened this issue Jun 5, 2020 · 2 comments
Closed

Spaces in sheets names #50

lfaucheux opened this issue Jun 5, 2020 · 2 comments
Assignees
Labels

Comments

@lfaucheux
Copy link

lfaucheux commented Jun 5, 2020

Nice package!

One really simple question. What about space-contained sheets names ? I mean

>>> import formulas
>>> formulas.Parser().ast("=SUM(sheetname!A3)")[1].compile().inputs
OrderedDict([('SHEETNAME!A3', <Ranges>(SHEETNAME!A3))])

works fine. But,

>>> problematic = "'sheet name'!A3"
>>> formulas.Parser().ast(f"=SUM({problematic})")[1].compile().inputs
OrderedDict([('SHEET NAME!A3', None)])
                               ^^^^

doesn't. What's strange is that

>>> formulas.Ranges().push(problematic)
<Ranges>(SHEET NAME!A3)

does the job for what I can tell.

@lfaucheux lfaucheux changed the title Spaces in sheets names Spaces in sheets names [temp. fixed] Jun 5, 2020
@lfaucheux lfaucheux changed the title Spaces in sheets names [temp. fixed] Spaces in sheets names Jun 5, 2020
@lfaucheux
Copy link
Author

lfaucheux commented Jun 5, 2020

Another dirty hack: at line 199 of tokens/operand.py, redefining _build_id as follows

def _build_id(ref, sheet='', excel=''):
    if excel or sheet:
        sheet = sheet.replace("''", "'")
    if excel:
        sheet = "[%s]%s" % (excel, sheet)
        if not fxl.tokens.operand._re_build_id.match(excel):
            sheet = "'%s'" % sheet
    elif sheet and ' ' in sheet:
        sheet = "'%s'" % sheet
    return '!'.join(s for s in (sheet, ref) if s)

Until you fix that, I will patch as shown above, which may not be the best option since I miss the global picture. Anyway, a big thank you for formulas.

@vinci1it2000
Copy link
Owner

Thanks for your finding! The correction is close to your proposal.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants