-
-
Notifications
You must be signed in to change notification settings - Fork 499
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
mac: cannot handle sheet names with spaces inside #889
Comments
The followin diff seems to "fix" it: @@ -1033,6 +1035,9 @@ class Name(object):
@property
def refers_to_range(self):
ref = self.refers_to[1:].split('!')
+ sheetname = ref[0]
+ if sheetname.startswith("'") and sheetname.endswith("'"):
+ ref[0] = sheetname[1:-1]
book = self.parent if isinstance(self.parent, Book) else self.parent.book
return Range(Sheet(book, ref[0]), ref[1]) |
Can you please include a self contained example? I can't replicated with the following code:
neither with
maybe you're mixing workbook and sheet scope? |
That was done with a real xl file. I don't understand the "mixing workbook and sheet scope" part. What's happening is an iteration on the names of a workbook, like that: for xlname in wb.names:
sheet_name = xlname.refers_to_range.sheet.name |
Can you please upload a sample spreadsheet with code to replicate the issue. |
Within this book we have a sheet named "ba bar" and a named cell within. While iterating on the names, we get to the issue: b = xlwings.Book('book.xlsx')
for n in b.names:
print(n.refers_to_range) => Traceback (most recent call last): The above exception was the direct cause of the following exception:
|
thanks! will look into it |
fix sheetnames with spaces for refers_to_range, closes #889
More precisely, given two sheets:
<Name 'rc_past': =through_time!$E$5:$F$11>
<Name 'rw_digit': ='space bar'!$E$8:$E$17>
when asking
.refers_to_range.sheet.name
on the second, one gets a nastyThe text was updated successfully, but these errors were encountered: