关于华表的自定义函数的问题
华表给出的例子中都是有参数的自定义函数
我按照他给的例子也作了一个 "HLB(....) "的函数,返回了数据库中的值,
但是到了无参数函数时出现问题:xmlhttp.setRequestHeader 类型不匹配 各位帮忙
Function HTTPPOST(functionName,params)
URL = "CustomizedFun.asmx/ " & functionName
Set xmlhttp = CreateObject( "Microsoft.XMLHTTP ")
xmlhttp.Open "POST ",URL,False
xmlhttp.setRequestHeader "Content-Type ", "application/x-www-form-urlencoded "
params_len=LEN(Params)
xmlhttp.setRequestHeader "Content-Length ",params_len
xmlhttp.Send(params)
Set x = xmlhttp.responseXML
alert(x.childNodes(1).text)
'那么如何知道是否调用成功呢,状态为200说明调用成功,500则说明出错
alert(xmlhttp.Status)
'alert(xmlhttp.StatusText)
Set xmlhttp = Nothing
HTTPPOST=x.childNodes(1).text
' end if
End Function
Function HLB(row,column,sheet,reportid,year)
'row1=int(row)
'column1=int(column)
'row=5
'column=6
'ret= "prefix "& DCellWeb1.GetCellDouble(row,column,0)
'msgbox ret
'url= "CustomizedFun.asmx/HLB?arg1= "&arg1
str = "row= " & row & "& " & "column= " & column & "& " & "sheet= " & sheet & "& " & "reportid= " & reportid & "& " & "year= " & year
HLB= HTTPPOST( "HLB ",str)
end function
Function bb_year(null)
bb_year= HTTPPOST( "bb_year ",null)
end function
Sub DCellWeb1_CalcFunc(ByVal name, ByVal rettype, ByVal paranum)
Select Case name
Case "HLB "
paranum=5
para1 = DCellWeb1.GetFuncDoublePara(0, isDefault)
para2 = DCellWeb1.GetFuncDoublePara(1, isDefault)
para3 = DCellWeb1.GetFuncDoublePara(2, isDefault)
para4 = DCellWeb1.GetFuncStringPara(3, isDefault)
para5 = DCellWeb1.GetFuncDoublePara(4, isDefault)
ret=HLB(para1,para2,para3,para4,para5)
'alert(para1)
DCellWeb1.SetFuncResult 11,ret,1
alert(ret)
Case "bb_year "
paranum=0
ret =bb_year(null)
DCellWeb1.SetFuncResult 11,ret,1
alert(ret)
End Select
End Sub
Sub getdefinedstr(name)
Select Case name
Case "HLB "
fun_para= "(double row,double column,double sheet,string reportid,double year) "
fun_description= "说明: 返回指定位置指定年度的值;参数:(行,列,页,报表编号);返回值类型:数值型 "
Case "bb_year "
fun_para= "() "
fun_description= "说明: 返回指打开报表的年度值;参数:无;返回值类型:数值型 "
End Select
Str = " " "自定义函数 " " Any " & name & fun_para
Str = Str & vbCrLf & "BEGIN_HELP "
Str = Str & vbCrLf & name &fun_para
Str = Str & vbCrLf & "函数内容: "
Str = Str & vbCrLf & fun_description
Str = Str & vbCrLf & "END_HELP "
DCellWeb1.DefineFunctions Str
End Sub
Sub window_onload
getdefinedstr( "HLB ")
getdefinedstr( "bb_year ")
End Sub
后台:
[WebMethod]
public string HLB(int row,int column,int sheet,string reportid,int year)
{
return CustomizedFunction.HLB(row,column,sheet,reportid,year);
}//这个成功了
[WebMethod]
public string bb_year()
{
return CustomizedFunction.bb_year();
}
[解决办法]
代码太多看的晕
[解决办法]
弱弱的问一句,这个控件有前途吗?
支持VBScript,JSScript
http://221.137.151.84/test1.htm