File tree 2 files changed +39
-3
lines changed
2 files changed +39
-3
lines changed Original file line number Diff line number Diff line change 1
1
// sort.cpp - std::sort from the STL
2
- // !!! Write xll_sort that calls std::sort and hook it up to XLL.SORT in Excel.
2
+ #include < algorithm>
3
+ #include < xutility>
4
+ #include " G5260.h"
5
+
6
+ using namespace xll ;
7
+
8
+ AddIn xai_sort (
9
+ Function (XLL_LPOPER, L" ?xll_sort" , L" XLL.SORT" )
10
+ .Arg(XLL_LPOPER, L" range" , L" is a range." )
11
+ .FunctionHelp(L" Sort entries from range." )
12
+ .Category(CATEGORY)
13
+ );
14
+ LPOPER WINAPI xll_sort (LPOPER po)
15
+ {
16
+ #pragma XLLEXPORT
17
+ static OPER o;
18
+
19
+ try {
20
+ std::sort (po->begin (), po->end ());
21
+ if (po->rows () == 1 ) {
22
+ o.resize (1 , po->columns ());
23
+ }
24
+ else {
25
+ o.resize (po->rows (), po->columns ());
26
+ }
27
+ std::copy (po->begin (), po->end (), o.begin ());
28
+ }
29
+ catch (const std::exception & ex) {
30
+ XLL_ERROR (ex.what ());
31
+ o = OPER (xlerr::NA);
32
+ }
33
+
34
+ return &o;
35
+ }
36
+
Original file line number Diff line number Diff line change 1
1
// unique.cpp - std::unique from the STL
2
+ #include < algorithm>
3
+ #include < xutility>
2
4
#include " G5260.h"
3
5
4
6
using namespace xll ;
@@ -17,10 +19,10 @@ LPOPER WINAPI xll_unique(LPOPER po)
17
19
try {
18
20
auto e = std::unique (po->begin (), po->end ());
19
21
if (po->rows () == 1 ) {
20
- o.resize (1 , std::distance (po->begin (), e));
22
+ o.resize (1 , (COL) std::distance (po->begin (), e));
21
23
}
22
24
else {
23
- o.resize (std::distance (po->begin (), e), 1 );
25
+ o.resize ((RW) std::distance (po->begin (), e), 1 );
24
26
}
25
27
std::copy (po->begin (), e, o.begin ());
26
28
}
You can’t perform that action at this time.
0 commit comments