Excel XLL SDK

You can use the Microsoft Excel XLL Software Development Kit and the C API to create high-performance worksheet functions.
You can use the SDK to create DLLs that can integrate directly into Excel.
These DLLs have the file extension ".xll".
These DLLs provide the most direct and fastest interface for the addition of high-performance user defined functions.

link - learn.microsoft.com/en-us/office/client-developer/excel/excel-xll-sdk-api-function-reference 

Versions

There have been four versions of the SDK.
Excel 2013 - (Excel 15) Latest Version
Excel 2010 - (Excel 14 or 10.0) no longer available for download.
Excel 2007 - (Excel 12 or 8.1) no longer available for download.
Excel 1997 - (Excel or 8.0) no longer available for download.


Download

The Microsoft Excel 2013 XLL SDK contains source files for three projects.
A Framework library that is designed to speed up the writing of XLLs, and two sample projects, Example and Generic.

link - microsoft.com/en-us/download/details.aspx?id=35567 

SAMPLES\FRAMEWRK\ - Contains a project that can be built to a library, FRAMEWRK.lib, which can then be linked into other XLL projects.
This library contains a number of tools for writing XLLs easier and is used in both of the other projects in conjunction with the header file FRAMEWRK.h.
SAMPLES\EXAMPLE\ - Contains a project that can be built to an XLL, EXAMPLE.xll.
The XLL contains many examples of the use of the Framework library, and example implementations of the XLL add-in interface functions such as xlAutoOpen.
SAMPLES\GENERIC\ - Contains a project that can be built to an XLL, GENERIC.xll.
The XLL demonstrates several example functions and commands and is a good starting point for writing your own XLLs.


Visual Studio 2022

Downlod the SDK to the following folder: C:\XLL\
Create a new project
language - C++, platform - Windows, project - Library
Dynamic Link Library (DLL)
Enter a project name and place the solution and project in the same folder


Precompiled Headers

Switch off precompiled headers
Change the project properties and add this folder.

Configuration Properties > C/C++ > Precompiled Headers 
Precompiled Header - Not Using Precompiled Headers
Precompiled Header File - (blank)

xlcall.h

This file is part of the Excel 2013 SDK.
This is a header file that contains all the necessary data structures, constant definitions and enumerations that are used by Excel.
It also contains all the C API interface functions that are needed for information to pass between Excel and the DLL.
We don't need to add this file to the actual project we just need to be able to link to this file.
This file is linked at compile time and the code is embedded into your solution.
Change the project properties and add this folder.

Configuration Properties > C/C++ > General 
Additional Include Directories - C:\XLL\Excel2013XLLSDK\Include\

xlcall32.lib

This file is part of the Excel 2013 SDK.
This is a static import library that contains all the symbol definitions and function declarations that are implemented in the xlcall32.dll
We don't need to add this file to the actual project we just need to be able to link to this file.
This file is linked at compile time and the code is embedded into your solution.
Change the project properties and add this folder.

Configuration Properties > Linker > General 
Additional Library Directories - C:\XLL\Excel2013XLLSDK\LIB\x64\

xlcall.cpp

This file is part of the Excel 2013 SDK.
This is a source file that contains the code for the Excel12() and Excel12v() functions.
This file is necessary because these two functions are not exported by the xlcall32.lib or xlcall32.dll files.
This file needs to be added to your project and is therefore dynamically linked to the Excel callback.
Copy the following files and paste them into the project folder

C:\XLL\Excel2013XLLSDK\SRC\xlcall.cpp 

Add the following existing item to the project.

C:\Users\"username"\source\repos\"myprojectname"\ 

example.c

Copy the following files and paste them into the project folder

C:\XLL\Excel2013XLLSDK\Samples\example\example.c 

Add the following existing item to the project.

C:\Users\"username"\source\repos\"myprojectname"\ 

Change the angle brackets and replace them with quotes

#include <framewrk.h> 
#include "framewrk.h"

example.def

Add the following existing item to the project.

C:\XLL\Excel2013XLLSDK\Samples\example\example.def 

Change the project properties and add the module definition file

Configuration Properties > Linker > Input 
Module Definition File = example.def

framewrk.c

Copy the following file and paste them into the project folder

C:\XLL\Excel2013XLLSDK\SAMPLES\FRAMEWRK\FRAMEWRK.h 

Add the following existing item to the project.

C:\Users\"username"\source\repos\"myprojectname"\ 

Remove this header from the top of the file

#include <xlcall.cpp> 

Change the angle brackets and replace them with quotes

#include <framewrk.h> 
#include "framewrk.h"

Change the angle brackets and replace them with quotes

#include <memorymanager.h> 
#include "memorymanager.h"

On line 251 change the "Excel4v" reference to "Excel12v".

xlret = Excel12v(xlfn,pxResult,count,(LPXLOPER *)ppxArgs); 

On line 990 change the "Excel4v" reference to "Excel12v".

wRet = Excel4(xlSheetId, lpx, 0); 

Add Files

C:\XLL\Excel2013XLLSDK\SAMPLES\FRAMEWRK\FRAMEWRK.h 
C:\XLL\Excel2013XLLSDK\SAMPLES\FRAMEWRK\FRAMEWRK.c
C:\XLL\Excel2013XLLSDK\SAMPLES\FRAMEWRK\MemoryManager.h
C:\XLL\Excel2013XLLSDK\SAMPLES\FRAMEWRK\MemoryManager.cpp
C:\XLL\Excel2013XLLSDK\SAMPLES\FRAMEWRK\MemoryPool.h
C:\XLL\Excel2013XLLSDK\SAMPLES\FRAMEWRK\MemoryPool.cpp

Add the following existing items to the project.

C:\Users\"username"\source\repos\"myprojectname"\ 

Remove Files

Remove the following files from the project:

framework.h 
pch.h
dllmain.cpp
pch.cpp

Build Solution

Select (Build > Build Solution)



Loading in Excel


Project Properties > Configuration Properties > Debugging 

Command = C:\Program Files\Microsoft Office\root\Office16\EXCEL.EXE




Calling conventions

Any function that you want to call from Excel must include the modifier "__stdcall"


#define EXPORT cmment(linker, "/EXPORT:"__FUNCTION__"="__FUNCDNAME__") 
double __stdcall MyDllFunction(double Any)
{
#pragma EXPORT
}


Other

functions might be
* in a cell formula
* named range definition
* conditional formatting expression


functions calls from a dialog box
special considerations for:
* Paste Special, Formulas
* Replace dialog box
* Insert Function (previously called Function Wizard or Paste Function)


Developing Add-ins (XLLs) in Excel 2007

link - learn.microsoft.com/en-us/previous-versions/office/developer/office-2007/aa730920(v=office.12) 

© 2025 Better Solutions Limited. All Rights Reserved. © 2025 Better Solutions Limited TopPrevNext