Hii 녀석들 나는이 나쁜 상황에 갇혀있어 특정 셀 좌표에서 여러 목록을 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 Range 개체 또는 주소를 문자열로 전달할 수 있습니다.
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 를 참조하십시오.
이 FAQ 문서는 https://support.pyxll.com/hc/en-gb/articles/360044507453-Writing-arrays-back-to-Excel 에도 도움이 됩니다.
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다