GNSTLIB for Microsoft Excel¶
Overview¶
Excel for Microsoft Excel is supported for Excel 2007
One of the major benefits of the GNSTLIB library is its inherent flexibility; it can be used by programmers developing in traditional languages, or by users of modern software packages and programming environments, like Microsoft Excel.
GNSTLIB is the most powerful tool available for Excel, combining the power of Gurobi with the ease of use and presentation capabilities of Excel.
To make using the GNSTLIB library easy, we provide the LIBRARY as a Dynamic Link Library (DLL).
Microsoft Excel users can use the GNSTLIB DLL to extend the set of functions of the Excel spreadsheet. To insert code into Excel it is necessary to open a Module sheet (the easiest way). In the following sections we describe a simple example, call the GNSTLIB function gamma.
The gnstlib.xlsm and all supporting files are located in the folder or directory gnstlib\gnstlib_excel
Linking GNSTLIB to Excel¶
Before you can use GNSTLIB for Microsoft Excel, you must first build GNSTLIB library DLL. This section contains the steps required for doing this with Visual Studio 2017 and Excel 2013.
Buidling with Visual C++ (Visual Studio)¶
#include "gnstlib.hpp"
double __stdcall gnstlib_gamma(double& x, int& err_id)
{
return GNSTLIB::gamma(x, err_id);
}
LIBRARY "gnstlib"
EXPORTS
GNSTLIB_XLS_gamma = gnstlib_gamma
...

Excel VBA¶
Option Explicit
' Gamma function
Private Declare PtrSafe Function GNSTLIB_XLS_gamma Lib "gnstlib.dll" (ByRef x As Double, Byref err_id As Integer) As Double
Public Function GNSTLIB_gamma(x As Double) As Double
Dim err_id As Integer
GNSTLIB_gamma = GNSTLIB_XLS_gamma(x, err_id)
End Function
Complex arguments may be handled using the user-defined type CMPLX in the Module file Cplx.bas (Complex type in Excel is a string...) consistency functions...