需要选择整个范围(固定为从单元格开始,但可以向左或向右延伸)
以下代码正常工作并从单元格B2(第2行B列)开始选择表格的最后一行和最后一列
#already opened handle to excel app
set appHandle ::tcom::handle0x04C65180
[[$appHandle Range B2] Select
set xlToRight -4161
[[$appHandle Selection] End $xlToRight] Select
set xlDown -4121
[[$appHandle Selection] End $xlDown ] Select
但它不是选择细胞。有没有办法选择这个范围。
答案 0 :(得分:0)
看起来像粗暴的黑客
#Following proc returns alphabet character for column number
proc colName {col} {
return [format %c [expr [scan A %c] + ($col%26) - 1]]
}
set endCol [colName [[[$appHandle Range B2] End $xlToRight] Column]]
set endRow [[[$appHandle Range B2] End $xlDown] Row]
[$appHandle Range B2 $endCol$endRow] Select