嗨,伙计们,我陷入了这种糟糕的境地,我必须在特定单元格坐标的 excel 中放置多个列表,并且在任何地方都找不到任何解决方案
当前实施:
@xl_func("string key: object", macro=True)
def calc(key) -> object:
result = [[1, 2], [3, 4]]
from pyxll import xl_app, XLCell
caller = xlfCaller()
address = caller.address
xl = xl_app()
xl_range = xl.Range(address)
one_below = xl_range.GetOffset(RowOffset=1, ColumnOffset=0)
XLCell.from_range(one_below)
cell = XLCell.from_range(one_below)
cell.options(type="var", auto_resize=True).value = result
return "123"
此代码非常适用于一组数据。但现在我想在特定的单元格坐标上添加多个这样的数据集。如果可能的话,如下所示:
@xl_func("string key: object", macro=True)
def calc(key) -> object:
result = [[1, 2], [3, 4]]
from pyxll import xl_app, XLCell
caller = xlfCaller()
address = caller.address
xl = xl_app()
xl_range = xl.Range(address)
one_below = xl_range.GetOffset(RowOffset=1, ColumnOffset=0)
XLCell.from_range(one_below)
cell = XLCell.from_range(one_below)
#This need to go between A1:A2 to B1:B2
cell.options(type="var", auto_resize=True).value = result
#This need to go between D1:D2 to E1:E2
cell.options(type="var", auto_resize=True).value = result2
#This need to go between F1:F2 to G1:G2
cell.options(type="var", auto_resize=True).value = result3
return "123"
Env:
Python 3.8.6 32 bit
Pyxll 5.0.5 32 bit