Skip to content
master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
xlloop/xllua/
xlloop/xllua/

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
lib
 
 
src
 
 
 
 
 
 
 
 
 
 
 
 
 
 

XLLua - xll, excel addin framework for Lua

XLLua is a framework for writing your own excel user-defined functions (UDF's) in Lua.

It allows the developer to:

  • Easily extend Excel by writing Lua functions that can be exposed as Excel functions
  • Use Excel as an application prototype framework (call lua functions, build tables)

How to use XLLua

First download the latest version of the addin (XLLua-version.xll) at: https://github.com/poidasmith/xlloop/downloads

When the addin is loaded by Excel it will search for a Lua file with the same name as the addin and in the same directory (with just the extension as .lua instead of .xll)

The addin will call dofile on this script during initialization. All function registration should occur at this point.

A simple addin that registers a new Excel function called 'MyFunc' is just:

-- set debug output on (use dbgview tool from sysinternals to view logging)
xllua.options.debug = true

local function myfunc( args )
	xllua.debug_printf( "myfunc: %s\n", xllua.stringit( args ) )
	xllua.debug_printf( "to_table: %s\n", xllua.stringit( xllua.to_table( args[1] ) ) );
	return "Hello Excel from Lua!"
end

-- register the above function in Excel 
xllua.reg_funs( {
	MyFunc  = myfunc,
} )

-- log something so we can check that our addin has been loaded
xllua.debug_printf( "testing testing...\n" )

return 1 

How to Install

To run the example do the following:

  1. Download the XLL from: https://github.com/poidasmith/xlloop/downloads
  2. Save it to a folder
  3. In the same folder create a script with the same name as the XLL but with a .lua extension (eg. XLLua-0.0.1.lua).
  4. Copy above code into your .lua script
  5. Open excel, go to Tools -> Addins
  6. Browse for the XLL and click ok

You should now be able to invoke =MyFunc() a sheet.