![](/img/trans.png)
[英]How to find co-ordinates of a specific Landmark point in Opencv Python
[英]how to place multiple list on a specific cell co-ordinates using pyxll functions
嗨,伙計們,我陷入了這種糟糕的境地,我必須在 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
您可以將 XLCell.from_range 傳遞給 COM 范圍 object 或地址作為字符串。
c = XLCell.from_range("A1")
c.options(auto_resize=True).value = x
此外,您可以使用 Application.Range 從地址獲取 COM 范圍,例如:
xl = xl_app()
r = xl.Range("A1")
r.Value = x
# or using XLCell
c = XLCell.from_range(r)
c.options(auto_resize=True).value = x
如果需要,您還可以在地址中包含工作簿和工作表,例如“[Book1]Sheet1.A1”。
有關詳細信息,請參閱https://www.pyxll.com/docs/api/classes.html#pyxll.XLCell.from_range 。
此常見問題解答文章也應有助於https://support.pyxll.com/hc/en-gb/articles/360044507453-Writing-arrays-back-to-Excel
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.