Giter Club home page Giter Club logo

helloworldxll's Introduction

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.

  • Load the solution in Visual Studio.
  • Build the solution (Menu: Build... Build Solution)
  • In Excel, open the Add-Ins dialog (this can be done quickly with Alt-T, I)
  • Click "Browse..."
  • Select the XLL at "C:\Users\Jameson\Documents\Visual Studio 2015\Projects\HelloWorldXll\x64\Debug\HelloWorldXll.xll". Click OK.
  • If Excel asks "A file name '...' already exists in this location. Do you want to replace it?", click Yes.
  • Click Ok.
  • Excel should display a dialog that says "Hello world". This is from the XLL. Click OK to dismiss the dialog.

Creation instructions

  • Create a new solution (Mone: File... New... Project)
  • In Templates... Other Languages... Visual C++ select Win32. Select Win32 Project. Set Name to "HelloWorldXll". Set Solution name to "HelloWorldXll". Ensure "Create directory for solution" is checked. Click OK. Note: These instructions assume the Location is set to "C:\Users\Jameson\Documents\Visual Studio 2015\Projects". Adjust the steps below according to the location you use.
  • Click Next at the Overview page.
  • Select Application type "DLL". Clear the checkboxes for Precompiled header and Security Development Lifecycle. Click Finish.
  • In the Solution Explorer, right click the HelloWorldXll and select Properties.
  • Select Configuration "All Configurations" and Platform "x64".
  • In Configuration Properties...General, Set Target Extension to ".xll".
  • In Configuration Properties...C/C++...General, select "Additional Include Directories", click the dropdown arrow on the right, select "Edit...". In the Additional Include Directories dialog, click the New Line icon (it looks like a folder with a red star, in the top-right corner of the window). This will create a new line in the top input box (the ungreyed one). Click the "..." button on the right of that line, which will open a Select Directory dialog. Navigate to "C:\2010 Office System Developer Resources\Excel2010XLLSDK\INCLUDE" and click "Select Folder". Click OK to set the Additional Include Directories.
  • In Configuration Proporties...Linker..Input, edit the "Additional Dependencies" as with the previous step. In the top edit box (the ungreyed one), add the text "C:\2010 Office System Developer Resources\Excel2010XLLSDK\LIB\x64\XLCALL32.LIB". Click OK to set the Additional Dependencies.
  • In stdafx.h, add the following lines at the end of the file:
#include <stdlib.h>
#include "xlcall.h"
  • In HelloWorldXll.cpp add the following lines at the end of the file:
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;
}
  • In the Solution Explorer, right click the HelloWorldXll and select Add..New Item.
  • In the Add New Item dialog, in the tree on the left, select Visual C++... Code. Then select Module-Definition File (.def). Set Name to "HelloWorldXll.def". Click Add.
  • Change the contents of HelloWorldXll.def to:
EXPORTS
	xlAutoOpen

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

helloworldxll's People

Contributors

edparcell avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.