尝试熟悉我的Mac(nl版)上的xlwings并阅读快速入门文档。
我可以读写单个cel。但是,当我尝试快速入门文档中的示例时,遇到了一个复杂的错误。 命令是:
sht.range('A1').value = [['Foo 1', 'Foo 2', 'Foo 3'], [10.0, 20.0, 30.0]]
我无法解决它,并期望sht.range('A1').expand().value
能给我:
[['Foo 1', 'Foo 2', 'Foo 3'], [10.0, 20.0, 30.0]]
完整的错误消息是:
EventError Traceback (most recent call last)
/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/aeosa/appscript/reference.py in __call__(self, *args, **kargs)
481 try:
--> 482 return self.AS_appdata.target().event(self._code, params, atts, codecs=self.AS_appdata).send(timeout, sendflags)
483 except aem.EventError as e:
/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/aeosa/aem/aemsend.py in send(self, timeout, flags)
91 errormsg = _defaultcodecs.unpack(errormsg)
---> 92 raise EventError(errornum, errormsg, eventresult)
93 if kae.keyAEResult in eventresult: # application has returned a value
EventError: Command failed: The object you are trying to access does not exist (-1728)
The above exception was the direct cause of the following exception:
CommandError Traceback (most recent call last)
<ipython-input-49-5623573f98f7> in <module>
----> 1 sht.range('A1').value = [1, 2, 3, 4, 5]
/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/xlwings/main.py in value(self, data)
1523 @value.setter
1524 def value(self, data):
-> 1525 conversion.write(data, self, self._options)
1526
1527 def expand(self, mode='table'):
/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/xlwings/conversion/__init__.py in write(value, rng, options)
41 pipeline = accessors.get(convert, convert).router(value, rng, options).writer(options)
42 ctx = ConversionContext(rng=rng, value=value)
---> 43 pipeline(ctx)
44 return ctx.value
/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/xlwings/conversion/framework.py in __call__(self, *args, **kwargs)
64 def __call__(self, *args, **kwargs):
65 for stage in self:
---> 66 stage(*args, **kwargs)
67
68
/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/xlwings/conversion/standard.py in __call__(self, ctx)
58 scalar = ctx.meta.get('scalar', False)
59 if not scalar:
---> 60 ctx.range = ctx.range.resize(len(ctx.value), len(ctx.value[0]))
61
62 self._write_value(ctx.range, ctx.value, scalar)
/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/xlwings/main.py in resize(self, row_size, column_size)
1700 column_size = self.shape[1]
1701
-> 1702 return Range(self(1, 1), self(row_size, column_size)).options(**self._options)
1703
1704 def offset(self, row_offset=0, column_offset=0):
/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/xlwings/main.py in __init__(self, cell1, cell2, **options)
993 if impl is None:
994 if cell2 is not None and isinstance(cell1, Range) and isinstance(cell2, Range):
--> 995 if cell1.sheet != cell2.sheet:
996 raise ValueError("Ranges are not on the same sheet")
997 impl = cell1.sheet.range(cell1, cell2).impl
/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/xlwings/main.py in __ne__(self, other)
785
786 def __ne__(self, other):
--> 787 return not self.__eq__(other)
788
789 def __hash__(self):
/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/xlwings/main.py in __eq__(self, other)
782
783 def __eq__(self, other):
--> 784 return isinstance(other, Sheet) and self.book == other.book and self.name == other.name
785
786 def __ne__(self, other):
/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/xlwings/main.py in name(self)
793 def name(self):
794 """Gets or sets the name of the Sheet."""
--> 795 return self.impl.name
796
797 @name.setter
/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/xlwings/_xlmac.py in name(self)
306 @property
307 def name(self):
--> 308 return self.xl.name.get()
309
310 @name.setter
/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/aeosa/appscript/reference.py in __call__(self, *args, **kargs)
516 return
517 raise CommandError(self, (args, kargs), e, self.AS_appdata) from e
--> 518 raise CommandError(self, (args, kargs), e, self.AS_appdata) from e
519
520 def AS_formatcommand(self, args):
CommandError: Command failed:
OSERROR: -1728
MESSAGE: The object you are trying to access does not exist
COMMAND: app(pid=62804).workbooks['**Map2**'].worksheets['**Sheet**'].name.get()