Home

Awesome

Hello World XLL

This is a simple XLL, showing how to create an XLL from scratch.

Requirements

Reference

For further details on creating XLLs, dealing with XLOPERs and correct memory handling, I recommend Steve Dalton's excellent Financial Applications using Excel Add-in Development in C/C++

Build and Load Instructions

Instructions assume the solution is at "C:\Users\Jameson\Documents\Visual Studio 2015\Projects\HelloWorldXll\HelloWorldXll.sln". Adjust the steps below according to the location your cloned this project on your system.

Creation instructions

#include <stdlib.h>
#include "xlcall.h"
short __stdcall xlAutoOpen()
{
	char *text= "Hello world";
	size_t text_len = strlen(text);
	XLOPER message;
	message.xltype = xltypeStr;
	message.val.str = (char *)malloc(text_len + 2);
	memcpy(message.val.str + 1, text, text_len + 1);
	message.val.str[0] = (char)text_len;
	XLOPER dialog_type;
	dialog_type.xltype = xltypeInt;
	dialog_type.val.w = 2;
	Excel4(xlcAlert, NULL, 2, &message, &dialog_type);
	return 1;
}
EXPORTS
	xlAutoOpen

The solution is now ready to build and load using the instructions above.