Call Julia from Microsoft Excel worksheets and from VBA.
CallFromExcel is an Excel add-in that lets you use any Julia function in a worksheet formula. For example, =JuliaEval("using LinearAlgebra") loads one of Julia's standard libraries, then =JuliaCall("eigvals", A1:J10) passes a range to Julia as a matrix and returns its eigenvalues to the worksheet (as complex numbers, if the matrix isn't symmetric) - something Excel has no built-in function for. Keep your front end in Excel, and do the heavy computation in Julia. A Julia tab on Excel's ribbon starts Julia and loads your Julia files. Installation doesn't need admin rights.
CallFromExcel is compatible with Excel's dynamic array formulas, and supports 64-bit Excel for Windows (not Mac, not 32-bit Excel). It works with Julia running under either Windows or Linux (via WSL).
CallFromExcel is the successor to JuliaExcel, with its Excel add-in rewritten from VBA to C# for speed. See Upgrading from JuliaExcel.
Demo
Installation
Installation (Linux)
The Julia ribbon tab
Upgrading from JuliaExcel
Functions
Example VBA
Function Documentation
Performance
Alternatives
Compatibility
Attaching to a Julia session already running elsewhere
Debugging
Marshalling
How CallFromExcel works
Viewing the code
Here's a quick demonstration of CallFromExcel's functions in action.
- See how the Julia session on the left responds to the action in Excel on the right, once
display_results(true)has been called (the formula at B6 does this). - The annotations in brown text ("Formula at...") are to make what's happening in the demo clearer. They won't appear when you try CallFromExcel for yourself!
- Replay the GIF by refreshing your browser (F5).
Installation does not require admin rights on the PC.
- Both Julia and Microsoft Office must be installed on your PC.
- Close Excel - installation fails if Excel is running.
- Launch Julia, and copy-paste the following commands into the REPL. To paste into the REPL, right-click.
using Pkg
Pkg.add("CallFromExcel")
using CallFromExcel
CallFromExcel.installme()
Pkg.add installs the Julia package, and installme() installs the Excel add-in.
- Launch Excel. Check that it shows a Julia tab on the ribbon, and that typing
=Juliainto a worksheet cell makes the auto-complete offerJuliaCall,JuliaEval,JuliaIncludeetc. - After updating CallFromExcel (e.g. with
Pkg.update()), close Excel and runusing CallFromExcel; CallFromExcel.installme()again: the add-in and the Julia package must be the same version, and if they aren't, Excel says so. Do the same if the functions go missing from Excel. - To uninstall the Excel add-in, close Excel and find CallFromExcel in Windows' Settings > Apps > Installed apps. This also removes the ribbon's saved settings. The Julia package is separate: remove it with
using Pkg; Pkg.rm("CallFromExcel").
As an alternative to calling Julia running in a Windows process, CallFromExcel can call Julia running in a Linux process under Windows Subsystem for Linux (WSL). If that's your preference, then in addition to the steps described above, you need to:
- If necessary, install WSL with the default Linux distribution, Ubuntu.
- Install Julia under WSL by running
curl -fsSL https://install.julialang.org | shat the Ubuntu prompt, per the official instructions. This installsjuliaup, which putsjuliaon the PATH automatically. - At the Julia prompt (under WSL) install CallFromExcel by copy-pasting
using Pkg; Pkg.add("CallFromExcel")into the REPL.
The add-in adds a Julia tab to Excel's ribbon:
| Control | What it does |
|---|---|
| Launch Julia | Starts Julia for this Excel session, using the Launch Settings. |
| Launch Settings... | Sets the project folder, other command line options, packages to load, whether to run under WSL, and so on. The settings are saved for you on this PC. |
| Show Julia | Brings Julia's window to the front. |
| Close Julia | Closes Julia, after asking for confirmation. |
| Display Results | Shows each call from Excel, and its result, in Julia's window - as CallFromExcel.display_results(true) does. |
| File, Browse, Include | Choose a Julia file - typed, pasted, browsed to or picked from recently used files - and include it, as JuliaInclude does. Include doesn't trigger recalculation. |
| Help | Opens this page. |
| About | Shows the versions of the add-in, and of the CallFromExcel package and Julia in the Julia session it is connected to, and a link to this page. |
Launch Julia and a JuliaLaunch formula start Julia in the same way, but each with its own settings: a formula uses only its own arguments, so a workbook records how Julia should start and does so the same way on every PC, while the ribbon's Launch Settings are yours.
CallFromExcel replaces JuliaExcel. Its worksheet functions have the same names, but some changes are needed to workbooks and code written for JuliaExcel.
Installation. Installing CallFromExcel (see Installation) also uninstalls JuliaExcel's Excel add-in, JuliaExcel.xlam. The JuliaExcel Julia package is no longer used, and can be removed with using Pkg; Pkg.rm("JuliaExcel").
Worksheet formulas. In a workbook saved with JuliaExcel, Excel records the location of JuliaExcel.xlam in each formula that uses its functions, so after upgrading a formula such as =JuliaLaunch() appears as ='C:\Users\Public\JuliaExcel\JuliaExcel.xlam'!JuliaLaunch(). Remove that path with Find and Replace (Ctrl+H): set "Within" to Workbook and "Look in" to Formulas, and replace the text 'C:\Users\Public\JuliaExcel\JuliaExcel.xlam'! with nothing.
VBA.
- Replace the reference to JuliaExcel with one to CallFromExcel (VBA editor, Tools menu -> References).
- Create an object to call CallFromExcel's functions through, and put it in front of each call, so
JuliaCall("f", x)becomesjl.JuliaCall("f", x)- see Example VBA:Dim jl As New CallFromExcel.ComServer
- From VBA,
JuliaCall,JuliaCallVBA,JuliaCallNamedArgsandJuliaCallNamedArgsVBAtake at most 30 arguments after the function name.
Julia. Functions and variables formerly accessed as JuliaExcel.xxx, such as JuliaExcel.serve_xl() and JuliaExcel.last_answer, are now CallFromExcel.xxx, after using CallFromExcel.
CallFromExcel makes the following functions available from Excel worksheets and from VBA, except that the three ending in VBA can only be called from VBA:
| Name | Description |
|---|---|
| JuliaLaunch | Launches a local Julia session which listens to the current Excel session and responds to calls to JuliaEval etc. |
| JuliaInclude | Load a Julia source file into the Julia process, to make additional functions available via JuliaEval and JuliaCall. |
| JuliaEval | Evaluate a Julia expression and return the result to an Excel worksheet. |
| JuliaCall | Call a named Julia function, passing in data from the worksheet. Returns an error string for results that cannot be displayed on a worksheet (nested arrays, dictionaries etc.). JuliaCallVBA lifts those restrictions. |
| JuliaSetVar | Set a global variable in the Julia process. |
| JuliaEvalVBA | Evaluate a Julia expression from VBA. Differs from JuliaCall in handling of 1-d arrays and strings longer than 32,767 characters. May return data of types that cannot be displayed on a worksheet, such as a dictionary or an array of arrays. |
| JuliaCallVBA | Call a named Julia function from VBA. Differs from JuliaCall in handling of 1-d arrays and strings longer than 32,767 characters. May return data of types that cannot be displayed on a worksheet, such as a dictionary, an array of arrays, or arrays of dimension up to 9. |
| JuliaCallNamedArgs | Call a named Julia function, passing positional and named arguments from the worksheet. The argument ";" marks where the named arguments start, given as name-value pairs. A named argument whose value is ";" must be the last pair. |
| JuliaCallNamedArgsVBA | Call a named Julia function from VBA, passing positional and named arguments, with ";" marking where the named arguments start. Differs from JuliaCallNamedArgs in the same ways that JuliaCallVBA differs from JuliaCall. |
| JuliaIsRunning | Returns TRUE if an instance of Julia is running and "listening" to the current Excel session, or FALSE otherwise. |
| JuliaExcelPID | Returns the process id of the current Excel session. Only needed if more than one Excel instance is running - pass it to serve_xl to say which one to attach to. |
The VBA code below makes a call to JuliaLaunch and JuliaEvalVBA and then pastes the result to range A1:J10 in a new worksheet. VBA reaches CallFromExcel's functions through an object created with CreateObject("CallFromExcel.ComServer"), which needs no reference. Alternatively, add a reference to CallFromExcel (VBA editor, Tools menu -> References) and declare Dim jl As New CallFromExcel.ComServer: the VBA editor then shows each function's arguments as you type. But a workbook with that reference won't compile on a PC without CallFromExcel installed.
Sub Demo()
Dim jl As Object, ResultFromJulia As Variant, PasteHere As Range
Set jl = CreateObject("CallFromExcel.ComServer")
jl.JuliaLaunch
ResultFromJulia = jl.JuliaEvalVBA("(1:10).^(1:10)'")
Set PasteHere = Application.Workbooks.Add.Worksheets(1) _
.Cells(1, 1).Resize(UBound(ResultFromJulia, 1), _
UBound(ResultFromJulia, 2))
PasteHere.Value = ResultFromJulia
End SubLaunches a local Julia session which listens to the current Excel session and responds to calls to JuliaEval etc. Uses only its own arguments, not the ribbon's Launch Settings (see The Julia ribbon tab).
JuliaLaunch([UseLinux], [MinimiseWindow], [CommandLineOptions], [Packages], [BashStatements], [TimeOut])
| Argument | Description |
|---|---|
UseLinux |
TRUE to run Julia as a Linux process under Windows Subsystem for Linux; FALSE (the default) to run as a Windows process. |
MinimiseWindow |
If TRUE, then the Julia session window is minimised; if FALSE (the default) then the window is sized normally. |
CommandLineOptions |
Command line options for Julia, e.g. --project=C:\MyProject or --banner=no. A --project folder must exist; --project=@temp starts Julia in a temporary environment, deleted when Julia exits (Julia 1.11 or later).If CommandLineOptions has no --threads option, --threads=auto,1 is added: Julia's usual threads, plus one interactive thread, which HTTP.jl recommends for servers. To choose the number of threads yourself, give your own --threads option, e.g. --threads=8,1 (the ,1 keeps the interactive thread). See Julia's command line options. |
Packages |
Packages to load, which must be installed in Julia's active environment (set by the --project command line option) or the default environment. Delimit multiple packages with commas. With --project=@temp, any that aren't installed are installed into the temporary environment, preferring versions you already have, so they're already precompiled. |
BashStatements |
Relevant only when UseLinux is TRUE. Bash statements executed prior to launching Julia, which can be used to set environment variables. Example: export JULIA_PKG_DEVDIR=/mnt/c/Projects. Delimit multiple statements with the line feed character. |
TimeOut |
The number of seconds to wait for Julia to fully start (including any package precompilation) before JuliaLaunch gives up waiting and returns an informational message rather than an error - Julia is not killed, and calling JuliaLaunch or JuliaEval again once it has finished starting will work normally. If Julia exits during start-up, e.g. because of an invalid command line option, JuliaLaunch reports an error straight away. TimeOut is optional and defaults to 30. |
Load a Julia source file into the Julia process, to make additional functions available via JuliaEval and JuliaCall.
JuliaInclude(FileName)
| Argument | Description |
|---|---|
FileName |
The full name of the file to be included. |
The ribbon's Include button does the same for the file in its File box, without needing a formula.
Evaluate a Julia expression and return the result to an Excel worksheet.
JuliaEval(JuliaExpression)
| Argument | Description |
|---|---|
JuliaExpression |
Any valid Julia code, as a string. Can also be a one-column range to evaluate multiple Julia statements. |
Call a named Julia function, passing in data from the worksheet. Returns an error string for results that cannot be displayed on a worksheet (nested arrays, dictionaries etc.). JuliaCallVBA lifts those restrictions.
JuliaCall(JuliaFunction, [Arg1], [Arg2], ...)
| Argument | Description |
|---|---|
JuliaFunction |
The name of a Julia function visible from the Julia REPL. |
Args... |
Zero or more arguments. Each may be a number, string, Boolean, empty cell, array or range. A range's values are passed as Excel stores them (its Value2), so cells formatted as dates arrive as serial numbers, not as Julia Dates. |
Set a global variable in the Julia process.
JuliaSetVar(VariableName, RefersTo)
| Argument | Description |
|---|---|
VariableName |
The name of the variable to be set. Must follow Julia's rules for allowed variable names. |
RefersTo |
A range, number, string, Boolean, empty cell or array of such types. As for JuliaCall, cells formatted as dates arrive as serial numbers. When called from VBA, nested arrays are supported. |
Evaluate a Julia expression from VBA. Differs from JuliaCall in handling of 1-d arrays and strings longer than 32,767 characters. May return data of types that cannot be displayed on a worksheet, such as a dictionary or an array of arrays.
jl.JuliaEvalVBA(JuliaExpression)
| Argument | Description |
|---|---|
JuliaExpression |
Any valid Julia code, as a string. Can also be a one-column range to evaluate multiple Julia statements. |
Call a named Julia function from VBA. Differs from JuliaCall in handling of 1-d arrays and strings longer than 32,767 characters. May return data of types that cannot be displayed on a worksheet, such as a dictionary, an array of arrays, or arrays of dimension up to 9.
jl.JuliaCallVBA(JuliaFunction, [Arg1], [Arg2], ...)
| Argument | Description |
|---|---|
JuliaFunction |
The name of a Julia function visible from the Julia REPL. |
Args... |
Zero or more arguments. Each may be a number, string, Boolean, empty cell, array or range. A range's values are passed as Excel stores them (its Value2), so cells formatted as dates arrive as serial numbers, not as Julia Dates. |
Call a named Julia function, passing positional and named arguments from the worksheet. The argument ";" marks where the named arguments start, given as name-value pairs. A named argument whose value is ";" must be the last pair.
JuliaCallNamedArgs(JuliaFunction, [Arg1], ..., ";", Name1, Value1, ...)
| Argument | Description |
|---|---|
JuliaFunction |
The name of a Julia function visible from the Julia REPL. |
Args... |
Zero or more positional arguments, then ";", then pairs of name and value, e.g. "a",1,"b",2. Names must be valid Julia identifiers. Each argument may be a number, string, Boolean, empty cell, array or range. |
Named arguments are what Julia's documentation and error messages call keyword arguments. The ";" mirrors Julia's own call syntax, so for example =JuliaCallNamedArgs("sort", A1:A10, ";", "rev", TRUE) calls sort(A1:A10; rev=true). The ";" is required, and must be followed by at least one name-value pair, so an even number of arguments. Otherwise JuliaCallNamedArgs returns an error saying so, rather than letting the call go ahead with misplaced arguments. To call a function without named arguments, use JuliaCall.
Julia finds the ";" by searching backwards from the end of the arguments, in steps of two (since name-value pairs follow it), and stops at the first ";" it finds. So a ";" among the positional arguments is never mistaken for the marker: =JuliaCallNamedArgs("split", A1, ";", ";", "keepempty", FALSE) calls split(A1, ";"; keepempty=false). The cost is that if a named argument's value is ";", that pair must be given last, since a ";" value in any earlier pair would be found first and taken as the marker.
A trailing . on the function name broadcasts over the positional arguments, as for JuliaCall. As with f.(x; k=v) in Julia, the named arguments are passed unchanged to every call rather than broadcast over.
Call a named Julia function from VBA, passing positional and named arguments, with ";" marking where the named arguments start. Differs from JuliaCallNamedArgs in the same ways that JuliaCallVBA differs from JuliaCall.
jl.JuliaCallNamedArgsVBA(JuliaFunction, [Arg1], ..., ";", Name1, Value1, ...)
| Argument | Description |
|---|---|
JuliaFunction |
The name of a Julia function visible from the Julia REPL. |
Args... |
Zero or more positional arguments, then ";", then pairs of name and value, e.g. "a",1,"b",2. Names must be valid Julia identifiers. Each argument may be a number, string, Boolean, empty cell, array or range. |
Returns TRUE if an instance of Julia is running and "listening" to the current Excel session, or FALSE otherwise.
JuliaIsRunning()
Returns the process id of the current Excel session. You'll rarely need this directly: CallFromExcel.serve_xl() finds the running Excel process automatically when only one is open. It's only when more than one Excel instance is running that you need it, to tell CallFromExcel.serve_xl explicitly which one to attach to - see Attaching to a Julia session already running elsewhere.
JuliaExcelPID()
Calls are fast: a simple call takes under a millisecond, and =JuliaCall("sort", A1:A1000000) sorts a million numbers in about 0.4 seconds, including sending them to Julia and back. That's faster than Excel's own =SORT(A1:A1000000), which takes about 0.6 seconds, and about a third of the time taken by CallFromExcel's predecessor, JuliaExcel. See the changelog for more timings.
Apart from CallFromExcel's own predecessor, JuliaExcel, there is one other method of calling Julia from Excel of which I am aware:
https://github.com/JuliaComputing/JuliaInXL.jl
JuliaComputing (now JuliaHub) made JuliaInXL open source in October 2021; it previously required a licence for commercial use. When last checked (November 2026), JuliaInXL did not support dynamic array formulas or calling Julia from VBA. Filling those gaps was why I wrote JuliaExcel, this project's predecessor, in 2021.
Early versions of JuliaExcel were slower than JuliaInXL, both in latency and in moving data between Excel and Julia. That has since reversed: in tests (see workbooks/CallFromExcel-Compare.xlsm), CallFromExcel was between 1.6 and 16 times faster. For example, =jlcall("sort", A1:A1000000) takes about 4.5 seconds, and =JuliaCall("sort", A1:A1000000) about 0.4 seconds.
CallFromExcel requires 64-bit Excel for Windows - the default for Microsoft 365 - and has been tested on Excel under Microsoft 365. It is not compatible with 32-bit Excel: the installer checks, and stops with an error if Excel is 32-bit. It requires Excel 2016 or later, and should work on 64-bit Excel 2016, 2019 and 2021, but has not been tested on them.
Normally JuliaLaunch starts its own dedicated Julia process. If you'd rather use a Julia session you already have open - for example one running inside VS Code, where you can set breakpoints and step through code - you can attach that session to Excel instead:
using CallFromExcel
serve_xl()With no argument, serve_xl finds the single running Excel process automatically and attaches to it, also switching display_results on - since seeing each call arrive is exactly what you want when attached like this for interactive debugging. Pass false to leave display_results off: serve_xl(false).
If more than one Excel process is running, serve_xl won't guess - it throws, telling you to pass the process id explicitly instead: serve_xl(true, pid), getting pid from Excel's JuliaExcelPID() worksheet function.
Back in Excel, JuliaCall/JuliaEval/etc. now talk to the attached session directly - there's no need to call JuliaLaunch at all, though if you do (e.g. from existing VBA code), it will detect the attached session and use it rather than starting a new one.
If Excel is already being served by another Julia session (e.g. one launched via JuliaLaunch, or attached earlier with serve_xl itself), serve_xl throws rather than starting a second, useless listener - stop the other session first (e.g. call stop_server() there, or close it).
Other functions for managing a session started this way:
CallFromExcel.stop_server()stops the session listening to Excel, without closing Julia itself.CallFromExcel.server_status()reports whether a server is currently running, which Excel process id it's serving, on which port, and the currentdisplay_resultssetting.
On the ribbon, Display Results works with an attached session, but Show Julia can't find its window, and Close Julia closes it - Julia and all - rather than just detaching it. To detach, call stop_server() in the session instead.
When the Excel being served closes, the session stops serving it by itself, whether it was attached with serve_xl or started by JuliaLaunch. Julia stays open, so nothing in it is lost. (Not under WSL, where Julia can't watch a Windows process.)
Every call to JuliaCall/JuliaCallVBA/JuliaEval/JuliaEvalVBA leaves a trace behind in Julia, so a problem can be debugged at the REPL without needing to repeat the call from Excel:
CallFromExcel.last_questionis the expression that was evaluated - either the exact string passed toJuliaEval/JuliaEvalVBA, or, forJuliaCall/JuliaCallVBA, a reconstructed call such asmyfunction(CallFromExcel.args_from_xl...).CallFromExcel.last_answeris the value that was returned to Excel.CallFromExcel.args_from_xlholds the arguments most recently passed from Excel toJuliaCall/JuliaCallVBA, or the positional arguments forJuliaCallNamedArgs/JuliaCallNamedArgsVBA. For those,CallFromExcel.kwargs_from_xlholds the named arguments as aNamedTuple, andlast_questionis a call such asmyfunction(args_from_xl...; kwargs_from_xl...).CallFromExcel.answer_again()evaluateslast_questionagain, and you can wrap it with@enteror your own debugging tools.
All of these only reflect the most recent call, so debug before making another one. Call CallFromExcel.display_results(true), or tick Display Results on the ribbon, to also have each call and its result echoed to the Julia console as it happens.
Two questions arose during implementation. First, what Julia type should data from a worksheet or VBA arrive as? Mostly that's easy to decide, but should a single-column or single-row range, or a one-dimensional VBA array, have one dimension or two in Julia? Second, in the other direction, how should a Julia vector come back to Excel?
The design had three objectives:
- Round-tripping:
=JuliaCall("identity",x)should return an identical copy ofx, whatever its shape. - Natural matrix arithmetic:
=JuliaCall("*",Range1,Range2)should give the same result as=MMULT(Range1,Range2), since*in Julia is matrix multiplication. - Julia's dot syntax for broadcasting should work from
JuliaCall.
This scheme achieves them:
- Scalars marshal back and forth as scalars.
- Ranges or arrays with more than one row and more than one column marshal back and forth as two-dimensional arrays.
- A single-column range arrives in Julia as a vector, and a Julia vector returns to the worksheet as a single column.
- A single-row range arrives in Julia as a two-dimensional array with one row.
From VBA, one-dimensional arrays arrive in Julia as vectors, and JuliaCallVBA and JuliaEvalVBA return Julia vectors as one-dimensional arrays, so VBA variables round-trip too.
Click the black triangles below to see illustrations.
Excel stores every number on a worksheet as a double-precision float, so numbers passed from a worksheet to JuliaCall, JuliaCallNamedArgs or JuliaSetVar always arrive in Julia as Float64, even whole numbers such as 2. This includes the results of other functions in the same formula, since Excel converts a function's result to a worksheet value before passing it on. So =JuliaCall("typeof", JuliaEval("2")) returns Float64, even though JuliaEval("2") returns an Int64 to VBA.
This matters when calling a Julia function that requires an integer, whether as a positional argument (e.g. rand(3)) or a named one (e.g. round(x; digits=2), split(s, ","; limit=2)). Passing Float64 gives a MethodError or TypeError. There are two workarounds:
- Write the whole call in
JuliaEval, e.g.=JuliaEval("rand(3)"), if the integer is a constant. - Write a small Julia function that converts, e.g.
myrand(n) = rand(Int(n)), loaded withJuliaInclude, and call that instead.
From VBA, numbers keep their VBA type: Integer arrives as Int16, Long as Int32, LongLong as Int64, Single as Float32 and Double as Float64. So pass a LongLong (e.g. 2^ or CLngLng(n)) where Julia needs an Int64. Note that a literal such as 2 in VBA code is an Integer, which arrives as Int16 - some Julia functions, such as split, require an Int64 and won't accept that either.
Julia's integer arithmetic wraps around on overflow rather than raising an error, and the narrower the type, the sooner that happens. So from VBA, jl.JuliaCall("*", 200, 200) returns -25536, since both arguments arrive as Int16, where VBA itself would raise an Overflow error. Pass LongLong or Double values when results may be large.
Excel has no complex number type. Its functions such as IMREAL, IMAGINARY and IMSUM work on text such as "3+4i" instead. So complex numbers in Julia return to Excel as text in exactly the format of Excel's own COMPLEX function, e.g. "3+4i", "-i" or "1.5+i", with 15 significant digits. As with COMPLEX, a number with a zero imaginary part returns as text without one, e.g. "3". Text in this form passed from Excel to Julia arrives as a String, not as a complex number.
Dates and times returned from Julia to a worksheet become Excel date serial numbers in the 1900 date system, Excel's default on Windows. In a workbook set to the 1904 date system (File > Options > Advanced > "Use 1904 date system"), they display 4 years and 1 day late. Dates passed from a worksheet to Julia arrive as plain numbers, as Excel stores them, whichever date system the workbook uses. Calls from VBA are unaffected, since VBA dates aren't serial numbers.
CallFromExcel's Excel add-in is written in C#, using Excel-DNA. Its worksheet functions are registered with Excel through the Excel SDK, and VBA calls the same code through the object created by CreateObject("CallFromExcel.ComServer"). The Julia ribbon tab is part of the same add-in, and its buttons use the same code too. The add-in communicates with Julia over a local HTTP connection:
JuliaLaunchstarts a Julia process (as a normal Windows process, or under WSL) running a small HTTP server (CallFromExcel.start_server()) on a free local port, and writes that port number to a file so the add-in can find it. If a session for the current Excel process already appears to be running,JuliaLaunchchecks that it's actually responding before reusing it, rather than starting a duplicate.JuliaEvalPOSTs the Julia expression as plain text to the server's/evalendpoint. The Julia functionsrv_eval_inner(incomms.jl) evaluates it withMeta.parseall/evaland returns the result - encoded in CallFromExcel's own wire format - in the HTTP response body.JuliaCallandJuliaCallVBAinstead encode the function name and its arguments (marshalled per the rules described in Marshalling) into that same wire format and POST it to the/callendpoint.srv_call_innerdecodes it and invokes the named function directly, returning the result the same way. This avoidsMeta.parseing a literal expression, which is slow for calls passing large arrays.JuliaCallNamedArgsandJuliaCallNamedArgsVBAencode their arguments the same way but POST them to the/callkwendpoint, where Julia splits them at the";"into positional and named arguments.- The add-in decodes the response body into worksheet values or VBA variables.
Other points to note:
- The wire format distinguishes the types VBA does (e.g.
LongfromDouble), and supports 2-D arrays (a worksheet range) and Excel error values. JSON, the obvious alternative, has only nested 1-D arrays and a much thinner type system. Arrays of numbers are sent in bulk, without per-element type or length information, and Julia ranges such as1:1000000are sent as just their first value, step and length. - Each
JuliaEval/JuliaCallis a synchronous HTTP request/response, over connections kept open between calls. If Julia isn't there to answer (e.g. after=JuliaEval("exit()")), the call returns an error saying so. - Running Julia inside Excel's own process, via Julia embedding, would avoid the HTTP round trip altogether. But Julia could then only be restarted by restarting Excel and there would be no separate Julia REPL to watch or debug in.
The Excel add-in is written in C#, using Excel-DNA; its source is in the dotnet-addin folder of this repository. Julia source code is always visible on your PC, and the @functionloc macro is an easy way to locate the code of any function you're interested in.
Philip Swannell
8 December 2021
Last updated 12 November 2026
