不知这样的效果如何?文件在附件,代码片段在下方:
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
LPXLOPER Add(LPXLOPER x1,LPXLOPER x2)
{
if (x1->xltype==xltypeErr)
{
return x1;
}
if (x2->xltype==xltypeErr)
{
return x2;
}
static XLOPER xlRet={0};
double d1=0,d2=0;
if ((x1->xltype&xltypeNum)==xltypeNum)
{
d1=x1->val.num;
}else if ((x1->xltype&xltypeInt)==xltypeInt)
{
d1=x1->val.w;
}else if ((x1->xltype&xltypeSRef)==xltypeSRef)
{
if (GetNumFromCell(x1,d1)==false)
{
xlRet.val.err=xlerrValue;
xlRet.xltype=xltypeErr;
return (LPXLOPER)&xlRet;
}
}else
{
xlRet.val.err=xlerrValue;
xlRet.xltype=xltypeErr;
return (LPXLOPER)&xlRet;
}
if ((x2->xltype&xltypeNum)==xltypeNum)
{
d2=x2->val.num;
}else if ((x2->xltype&xltypeInt)==xltypeInt)
{
d2=x2->val.w;
}else if ((x2->xltype&xltypeSRef)==xltypeSRef)
{
if (GetNumFromCell(x2,d2)==false)
{
xlRet.val.err=xlerrValue;
xlRet.xltype=xltypeErr;
return (LPXLOPER)&xlRet;
}
}else
{
xlRet.val.err=xlerrValue;
xlRet.xltype=xltypeErr;
return (LPXLOPER)&xlRet;
}
xlRet.xltype=xltypeNum;
xlRet.val.num=d1+d2;
return (LPXLOPER)&xlRet;
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
bool GetNumFromCell(LPXLOPER lpXloper,double & dValue)
{
XLOPER x_Tmp={0};
if ((lpXloper->xltype & xltypeSRef)==xltypeSRef)
{
if (xlretUncalced == Excel(xlCoerce, &x_Tmp, 2, lpXloper, TempInt(xltypeNum)))
{
return false;
}
if (x_Tmp.xltype==xltypeErr)
{
return false;
}
dValue=x_Tmp.val.num;
}else
{
return false;
}
return true;
}
很抱歉,回答者上传的附件已失效
- 相关评论
- 我要评论
-