generated from xlladdins/xll_template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
xll_template.cpp
65 lines (55 loc) · 1.99 KB
/
xll_template.cpp
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
// 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")
.Documentation(R"xyzyx(
The <i>Gamma</i> function is \(\Gamma(x) = \int_0^\infty t^{x - 1} e^{-t}\,dt\), \(x \ge 0\).
If \(n\) is a natural number then \(\Gamma(n + 1) = n! = n(n - 1)\cdots 1\).
<p>
Any valid HTML using <a href="https://katex.org/" target="_blank">KaTeX</a> can
be used for documentation.
)xyzyx")
);
// 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;
}
#ifdef _DEBUG
// Create XML documentation and index.html in `$(TargetPath)` folder.
// Use `xsltproc file.xml -o file.html` to create HTML documentation.
Auto<Open> xao_template_docs([]() {
return Documentation("MATH", "Documentation for the xll_template add-in.");
});
#endif // _DEBUG