Luau API
xllify.ExcelFunction()
Register a function for Excel, aka: xllify.fn
xllify.ExcelFunction(metadata, function_body)
xllify.fn(metadata, function_body)Metadata fields:
name(string) - Excel function name (e.g., "MyFunc")description(string) - Function description (optional)category(string) - Excel category (optional)execution_type(string) - "sync" or "async" (default: "sync")
xllify.ExcelFunction({
name = "ADD",
description = "Add two numbers",
category = "Math"
}, function(x, y)
return x + y
end)xllify.ExcelFunction({
name = "DELAYED_MESSAGE",
description = "Returns a message after a delay",
execution_type = "async"
}, function(seconds, message)
async.sleep(seconds) -- Non-blocking sleep
return message
end)Built-in properties
xllify.version
Get xllify version:
xllify.ExcelFunction({
name = "GetVersion"
}, function()
return xllify.version
end)Async functions
Async functions (with execution_type = "async") can use non-blocking operations via the async namespace.
async.sleep()
Non-blocking sleep (async functions only):
async.sleep(seconds)Example:
xllify.ExcelFunction({
name = "COUNTDOWN",
execution_type = "async"
}, function(start)
for i = start, 1, -1 do
async.sleep(1)
end
return "Done!"
end)async.http_get()
Non-blocking HTTP GET (async functions only, Windows only):
result = async.http_get(url)Returns a table with:
status- HTTP status codebody- Response body (if successful)error- Error message (if failed)
xllify.ExcelFunction({
name = "FETCH_DATA",
execution_type = "async"
}, function(url)
local result = async.http_get(url)
if result.error then
error(result.error)
end
return result.body
end)async.http_post()
Non-blocking HTTP POST (async functions only, Windows only):
result = async.http_post(url, body, content_type)Parameters:
url- URL to POST tobody- Request bodycontent_type- Content-Type header (optional, defaults to "application/json")
Returns same table structure as http_get().
Blocking functions
For non-async (sync) functions, blocking versions are available globally.
sleep()
Blocking sleep (sync functions only):
sleep(seconds)http.get()
Blocking HTTP GET (sync functions only):
result = http.get(url)http.post()
Blocking HTTP POST (sync functions only):
result = http.post(url, body, content_type)Standard libraries
All standard Luau libraries are available:
-- String
string.upper, string.lower, string.format, etc.
-- Table
table.insert, table.remove, table.concat, etc.
-- Math
math.sin, math.cos, math.sqrt, etc.
-- OS
os.time, os.date, etc.Logging
Use the log namespace to write log messages:
log.trace("Trace message")
log.debug("Debug message")
log.info("Info message")
log.warn("Warning message")
log.error("Error message")
log.critical("Critical message")Excel types
Number
number
String
string
Boolean
boolean
Range
table (2D array)
Empty
nil
Error handling
Use error() to return errors to Excel:
xllify.ExcelFunction({
name = "DIVIDE"
}, function(a, b)
if b == 0 then
error("Cannot divide by zero")
end
return a / b
end)Excel shows: #ERROR: Cannot divide by zero
Last updated