The Ecotect help file only contains an examples that shows how to write into an Excel spreadsheet.
The Lua 4 script editor has access to the LuaCOM library, which also has ways of reading data from Excel.
Below is an example that reads a value v from an excel spreadsheet: You can just copy and paste it into the ecotect script editor.
-- [[ ------------------------------------------------------------------
-- AUTOMATE MICROSOFT EXCEL FROM ECOTECT.
-- ]] ------------------------------------------------------------------
-- Check if excel is already running.
xl = luacom.GetObject("Excel.Application")
if xl == nil then
xl = luacom.CreateObject("Excel.Application")
end
if xl then
-- Uncomment this to open a document.
-- xl.Workbooks:Open("C:\\My Documents\\Temp.xls")
-- or a new workbook.
book = xl.Workbooks:Add()
sheet = book.Worksheets(1)
--Make Excel visible.
xl.Visible = true;
end
for row=1,30 do
for col=1,30 do
print(row)
sheet.Cells(row, col).Value2 = col + row
end
end
local range = sheet:Range("A1")
for row=1,30 do
for col=1,30 do
--!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
--THIS IS HOW YOU READ AN EXCEL VALUE INTO LUA:
local v = sheet.Cells(row, col).Value2
--!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
if v > 50 then
local cell = range:Offset(row-1, col-1)
cell:Select()
xl.Selection.Interior.Color = 65535
end
end
end
-- release COM objects
book = nil
xl = nil