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

accounting for white spaces in ranges #137

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

igheorghita
Copy link
Contributor

Previously, we had the following behavior for variations of '=SUM(Sheet2!A1:A2)':

from openpyxl import Workbook
wb = Workbook()
wb.create_sheet('Sheet1')
wb.create_sheet('Sheet2')
ws = wb['Sheet2']
ws['A1'], ws['A2'] = 1, 2

ws = wb['Sheet1']
ws['A1'] = f'=SUM(\'Sheet2\' !A1:A2)'    # FAILED - this one is a syntax error in Excel too, but you're prompted to correct it
ws['A2'] = f'=SUM(\'Sheet2\'! A1:A2)'    # #NAME?
ws['A3'] = f'=SUM(\'Sheet2\'!A1 :A2)'    # FAILED
ws['A4'] = f'=SUM(\'Sheet2\'!A1: A2)'    # #NAME?
ws['A5'] = f'=SUM(\'Sheet2\'!A1 : A2)'   # FAILED

Now these should all work (i.e., evaluate to 3). They'll also work with multiple whitespaces because the openpyxl tokenizer tokenizes it the same way.

I had to add the any(c in '!:' for c in (last_token.value[-1], next_token.value[0]) condition because without it other tests fail - like this possibility '=SUM((A:A A1:B1))'

@codecov-commenter
Copy link

codecov-commenter commented Oct 30, 2021

Codecov Report

Merging #137 (a967e2c) into master (6ce2bc2) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##            master      #137   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           17        17           
  Lines         3757      3766    +9     
  Branches       912       914    +2     
=========================================
+ Hits          3757      3766    +9     
Impacted Files Coverage Δ
src/pycel/excelformula.py 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6ce2bc2...a967e2c. Read the comment docs.

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

Successfully merging this pull request may close these issues.

Minor issue regarding whitespace parsing
2 participants