-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathxll_template.cpp
More file actions
46 lines (41 loc) · 1.39 KB
/
xll_template.cpp
File metadata and controls
46 lines (41 loc) · 1.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// xll_template.cpp - Sample xll project.
#include <cmath> // for `double tgamma(double)`
#include "xll_template.h"
using namespace xll;
AddIn xai_tgamma(
// Return double, C++ name of function, Excel name.
Function(XLL_DOUBLE, "xll_tgamma", "TGAMMA")
// Array of function arguments.
.Arguments({
Arg(XLL_DOUBLE, "x", "is the value for which you want to calculate Gamma.")
})
// Function Wizard help.
.FunctionHelp("Return the Gamma function value.")
// Function Wizard category.
.Category("MATH")
// URL linked to `Help on this function`.
.HelpTopic("https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/tgamma-tgammaf-tgammal")
);
// WINAPI calling convention must be specified
double WINAPI xll_tgamma(double x)
{
#pragma XLLEXPORT // must be specified to export function
return tgamma(x);
}
// Press Alt-F8 then type 'XLL.MACRO' to call 'xll_macro'
// See https://xlladdins.github.io/Excel4Macros/
AddIn xai_macro(
// C++ function, Excel name of macro
Macro("xll_macro", "XLL.MACRO")
);
// Macros must have `int WINAPI (*)(void)` signature.
int WINAPI xll_macro(void)
{
#pragma XLLEXPORT
// https://xlladdins.github.io/Excel4Macros/reftext.html
// A1 style instead of default R1C1.
OPER reftext = Excel(xlfReftext, Excel(xlfActiveCell), OPER(true));
// UTF-8 strings can be used.
Excel(xlcAlert, OPER("XLL.MACRO called with активный 细胞: ") & reftext);
return TRUE;
}