Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Sheet.names.add always on workbook level (Mac) #771
I do not have Windows. Is this reproducible in Windows?
Reproducing the error
The following code makes a workbook in which cell A1 on the first worksheet is the named range "cell". If you run this code, you can check in Excel that it works. However the last line, in which
>>> import xlwings >>> workbook = xlwings.Book() >>> sheet = workbook.sheets >>> sheet.names # Correctly empty  >>> sheet.names.add("cell", "=Sheet1!$A$1") <Name 'cell': =Sheet1!$A$1> >>> sheet.names # Should be [<Name 'cell': =Sheet1!$A$1>] instead 
Python 3.6.3 (default, Oct 4 2017, 06:09:15)
In case this helps with debugging, here's some more output from the same Python session I posted in the original bug report.
>>> sheet.range('cell').value = 17.2 >>> sheet.range('cell').value # Using the name of the range works 17.2 >>> sheet.names.impl <xlwings._xlmac.Names at 0x10667fb70> >>> sheet.names.impl.xl app(pid=85706).workbooks['Sheet95'].worksheets.named_items >>> type(sheet.names.impl.xl) appscript.reference.Reference >>> sheet.names.impl.xl.get() k.missing_value
I don't know anything about appscript or COM, but let me know if there's anything else I can do to help resolve this issue—the
I can't find documentation (beyond the source code) on how to run the xlwing tests. I don't have Anaconda, just the standard Python 3.6 installation on macOS (via Homebrew with XCode command line tools—nothing fancy or custom). I cloned the repository, set up a virtual environment called "venv" (
A new instance of Excel opens at the beginning. A new workbook (or two) pops open every time a test case executes, but there's always an error message that disappears too quickly for me to see it. When the tests are done executing 3.9 seconds later, I have 16 identical errors:
referenced this issue
Nov 2, 2017
Ok, got it. Don't forget here as well.
When you have a minute, would you please explain how to run the tests (re my earlier comment)? If I can get the tests to work, I can try to use your memo to put together a pull request (because then my team can use the
I use this script to run the tests: https://github.com/ZoomerAnalytics/xlwings/blob/master/runtests.py
It uses nose, however, it should be compatible with plain vanilla unittest.
I finally got the
Occasionally Excel crashes during the tests and I get the following error log from Excel:
This does not seem to produce a failed test. Strangely, however, there are only 16 tests in the
For what it's worth, runtests.py requires conda, which I don't have. However, reading the code, it looks like runtests.py just launches notestest for a few combinations of python versions (I only have Python 3.6 anyway). If all nosetest does is run the vanilla unittests under different Python configurations, then I should be able to run the tests under my installed python with