実行中のExcel 2007 ドキュメントのセルから値を読み取ろうとしています。LuaのWinAPI 拡張機能を使用しています。私は現在、Windows XP コンピューターで実行しています (それが問題であれば、WinAPI は XP 以降で動作するようです。
これは私のExcel文書です:
これは私のLuaコードです:
require 'winapi'
w = winapi.find_window_match('Book1') -- Specify the name of the window
w:show() -- Set the visability
w:set_foreground() -- Bring this window to the foreground
handle = w:get_handle() -- Get window handle
t = {} -- Create a table
w:enum_children(function(w) table.insert(t,w) end) -- Enumerate all children
for k,v in pairs(t) do -- Print out all pairs in the table
print("",k,"=",v)
end
これは私のLuaコード出力です:
各セルを見つけるために再帰的に列挙する方法を知っている人はいますか? または、これについてもっと良い方法はありますか?私が欲しいテキストは「1234」です。私は Unix の方が好きなので、Windows プログラミングはあまりやったことがありませんが、正しい方向に進んでいるようです。ここから先の展開がわからない!