簡體   English   中英

AppleScript:如何以$ A $ 1格式返回Excel單元格引用

[英]Applescript: how to return Excel cell reference in $A$1 format

我正在嘗試編寫一個Applescript,以循環遍歷Excel電子表格范圍中的每個單元格,並以“ $ A $ 1”格式記錄單元格值和單元格地址。 我可以獲得單元格的值,並且可以獲得對單元格位置的完整引用(例如,應用程序“ Microsoft Excel”的活動工作簿的工作表“ Sheet1”的范圍“ A2:B10”的單元格“ $ A $ 2”),但我不知道如何僅提取單元格引用(例如,“ $ A $ 2”)。

set addressList to {}
tell application "Microsoft Excel"
    tell sheet "Sheet1" of active workbook
        set myRange to range "A2:B10"
        repeat with j from 1 to count of every cell in myRange
            set end of addressList to cell j of myRange
        end repeat
    end tell
end tell
addressList

使用get address命令

set addressList to {}
tell application "Microsoft Excel"
    tell sheet "Sheet1" of active workbook
        set myRange to range "A2:B10"
        repeat with j from 1 to count of every cell in myRange
            set end of addressList to get address of cell j of myRange
        end repeat
    end tell
end tell
addressList

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM