Python Examples

Basic functions

basic.py
import xllify

@xllify.fn("xllipy.Hello")
def hello(name: str) -> str:
    return f"Hello, {name}!"

@xllify.fn("xllipy.Add")
def add(a: float, b: float) -> float:
    return a + b

Slow operations

All Python functions run asynchronously, so slow operations don't freeze Excel:

slow.py
@xllify.fn("xllipy.SlowCalc")
def slow_calc(seconds: float) -> str:
    import time
    time.sleep(seconds)
    return f"Done after {seconds}s"
circle-info

Excel shows #N/A while waiting, then updates when complete. Note that naively putting a sleep in a function WILL block the execution of other functions. It is best to spawn multiple processes. asyncio support is planned.

Working with ranges

Usage: =xllipy.MaxInRange(A1:Z100)

Black-Scholes option pricing

Usage: =xllipy.BSCall(100, 95, 0.25, 0.05, 0.2)

HTTP requests

Error handling

System info

Pandas integration

Last updated