@@ -81,7 +81,8 @@ import framework;
81
81
import core.stdc.wchar_ : wcslen;
82
82
import core.stdc.wctype :towlower;
83
83
import std.format ;
84
- // import generic;
84
+ import xlld.wrap;
85
+
85
86
enum GWLP_WNDPROC =- 4 ;
86
87
enum MAXWORD = 0xFFFF ;
87
88
debug =0 ;
@@ -152,7 +153,7 @@ wchar[20] g_szBuffer = ""w;
152
153
g_rgWorksheetFuncsRows define the number of rows in the table. The
153
154
g_rgWorksheetFuncsCols represents the number of columns in the table.
154
155
*/
155
- enum g_rgWorksheetFuncsRows =3 ;
156
+ enum g_rgWorksheetFuncsRows =5 ;
156
157
enum g_rgWorksheetFuncsCols =10 ;
157
158
158
159
__gshared wstring [g_rgWorksheetFuncsCols][g_rgWorksheetFuncsRows] g_rgWorksheetFuncs =
@@ -180,6 +181,30 @@ __gshared wstring[g_rgWorksheetFuncsCols][g_rgWorksheetFuncsRows] g_rgWorksheetF
180
181
" Adds the arguments" w,
181
182
" Number1,number2,... are 1 to 29 arguments for which you want to sum." w
182
183
],
184
+ [ " lastErrorMessage" w,
185
+ " Q" w, // up to 255 args in Excel 2007 and later,
186
+ // upto 29 args in Excel 2003 and earlier versions
187
+ " lastErrorMessage" w,
188
+ " " w,
189
+ " 1" w,
190
+ " Generic Add-In" w,
191
+ " " w,
192
+ " " w,
193
+ " Return last D error message" w,
194
+ " " w,
195
+ ],
196
+ [ " WrapSquare3" w,
197
+ " QQQQQQQQQQQQQQQQQQQQQQQQQQQQQQ" w, // up to 255 args in Excel 2007 and later,
198
+ // upto 29 args in Excel 2003 and earlier versions
199
+ " WrapSquare3" w,
200
+ " number1,number2,..." w,
201
+ " 1" w,
202
+ " Generic Add-In" w,
203
+ " " w,
204
+ " " w,
205
+ " Sum of squares of the arguments" w,
206
+ " Number1,number2,... are 1 to 29 arguments for which you want to sum." w
207
+ ],
183
208
[ " FuncFib" w,
184
209
" UU" w,
185
210
" FuncFib" w,
@@ -448,7 +473,8 @@ extern(Windows) BOOL /*APIENTRY*/ DllMain( HANDLE hDLL, DWORD dwReason, LPVOID l
448
473
extern (Windows ) int /* WINAPI*/ xlAutoOpen()
449
474
{
450
475
import std.conv ;
451
-
476
+ import core.runtime :rt_init;
477
+ rt_init();
452
478
static XLOPER12 xDLL, // name of this DLL //
453
479
xMenu, // xltypeMulti containing the menu //
454
480
xTool, // xltypeMulti containing the toolbar //
@@ -674,6 +700,9 @@ extern(Windows) int /*WINAPI*/ xlAutoClose()
674
700
Excel12f(xlFree, cast (XLOPER12 * )0 , [cast (LPXLOPER12 ) &xRes]);
675
701
}
676
702
703
+ import core.runtime :rt_term;
704
+ rt_term();
705
+
677
706
return 1 ;
678
707
}
679
708
@@ -1284,6 +1313,35 @@ extern(Windows) LPXLOPER12 /*WINAPI*/ Func1 (LPXLOPER12 x)
1284
1313
History: Date Author Reason
1285
1314
*/
1286
1315
1316
+ extern (Windows ) LPXLOPER12 WrapSquare3(
1317
+ LPXLOPER12 px1,LPXLOPER12 px2,LPXLOPER12 px3,LPXLOPER12 px4,
1318
+ LPXLOPER12 px5,LPXLOPER12 px6,LPXLOPER12 px7,LPXLOPER12 px8,
1319
+ LPXLOPER12 px9,LPXLOPER12 px10,LPXLOPER12 px11,LPXLOPER12 px12,
1320
+ LPXLOPER12 px13,LPXLOPER12 px14,LPXLOPER12 px15,LPXLOPER12 px16,
1321
+ LPXLOPER12 px17,LPXLOPER12 px18,LPXLOPER12 px19,LPXLOPER12 px20,
1322
+ LPXLOPER12 px21,LPXLOPER12 px22,LPXLOPER12 px23,LPXLOPER12 px24,
1323
+ LPXLOPER12 px25,LPXLOPER12 px26,LPXLOPER12 px27,LPXLOPER12 px28,
1324
+ LPXLOPER12 px29)
1325
+ {
1326
+ import std.algorithm :map,sum;
1327
+ import std.experimental.allocator ;
1328
+ import std.conv :to;
1329
+ auto args=px1.fromXLOPER12! (double []);
1330
+ double [][] retD;
1331
+ if (args.length== 0 )
1332
+ return makeXLOPER12Error (100 ," you must pass at least one argument" );
1333
+ retD.length=args.length;
1334
+ foreach (i;0 .. args.length)
1335
+ {
1336
+ retD[i].length=args.length;
1337
+ foreach (j;0 .. args.length)
1338
+ {
1339
+ retD[i][j]=args[0 .. j+ 1 ].map! (arg=> arg* arg).sum;
1340
+ }
1341
+ }
1342
+ return makeXLOPER12 (retD);
1343
+ }
1344
+
1287
1345
extern (Windows ) LPXLOPER12 /* WINAPI*/ FuncSum(
1288
1346
LPXLOPER12 px1,LPXLOPER12 px2,LPXLOPER12 px3,LPXLOPER12 px4,
1289
1347
LPXLOPER12 px5,LPXLOPER12 px6,LPXLOPER12 px7,LPXLOPER12 px8,
0 commit comments