domino从Excel导入数据

HTML部分
——————————————————————————————————————————————

1 <table style="WIDTH: 99%; BORDER-COLLAPSE: collapse" class="linkeytable">
2 <tbody>
3 <tr>
4 <td width="15%" align="right">导入文件:</td>
5 <td width="35%">
6 <input id="upfile" name="file" type="file" /></td>
7 </tr>
8 </tbody>
9 </table>

——————————————————————————————————————————————

JS部分
——————————————————————————————————————————————

 1 function ImportTest(){
 2 var tempStr="";
 3 var filePath=document.all.upfile.value;
 4 if(String(filePath)!=""){
 5 var oXL=new ActiveXObject("Excel.application");
 6 var oWB=oXL.Workbooks.open(filePath);
 7 oWB.worksheets(1).select();
 8 var oSheet=oWB.ActiveSheet;
 9 try{
10 var i=2;
11 while(String(oSheet.Cells(i,1).value)!="undefined"){
12 if(tempStr!="")tempStr+="#";
13 tempStr+=oSheet.Cells(i,1).value+"#";
14 tempStr+=oSheet.Cells(i,2).value+"#";
15 tempStr+=oSheet.Cells(i,3).value+"#";
16 tempStr+=oSheet.Cells(i,4).value+"#";
17 tempStr+="CompanyAsset";
18 i++;
19 }
20 }
21 catch(e){
22 alert("Error");
23 }
24 var url="/"+folder+"/app.nsf/WF_RunRule?openagent&RuleNum=RUh3c02001_004";
25 $(function(){
26 $.post(url,encodeURI(tempStr),function(){alert("导入成功");window.close();});
27 })
28 oWB.close();
29 oXL.Quit();
30 }
31 CollectGarbage(); 
32 //window.close();
33 opener.location.reload(); 
34 }

——————————————————————————————————————————————

LS部分
——————————————————————————————————————————————

Sub Initialize
On Error Goto errormsg
dim se as new notessession
dim db as notesdatabase
dim curdoc as notesdocument
set db=opendb("app.nsf")
set curdoc=se.Documentcontext

dim strFormular as string
dim vData as variant
dim vQry as string
strFormular="@URLDecode('Domino';Request_Content)"
vData=Evaluate(strFormular,curdoc)
vQry=vData(0)

dim sql as string
dim vStr as variant
dim i as integer,j as integer
vStr=split(vQry,"#")
i=ubound(vStr)+1
j=i/5-1

dim WF_Document as notesdocument
dim fldlst as new lcfieldlist
dim tmpdoc as notesdocument
for k=0 to j 
sql=|select * from h3c_PropertyInfo where number='|+vStr(k*5)+|'|
set tmpdoc=rdb.GetDocumentBySql(sql)
set WF_Document=db.createdocument()
WF_Document.WF_OrUNID=WF_Document.universalid
WF_Document.number=vStr(k*5)
WF_Document.status=vStr(k*5+1)
WF_Document.place=vStr(k*5+2)
WF_Document.connectors=vStr(k*5+3)
WF_Document.genre=vStr(k*5+4)
if not tmpdoc is nothing then
Dim useTime As New NotesDateTime(Cstr(tmpdoc.getdate(0)))
dim dateTime as new notesdatetime("")
datetime.LSLocalTime=Now
WF_Document.type=tmpdoc.type(0)
WF_Document.storager=tmpdoc.storager(0)
WF_Document.storagernumber=tmpdoc.storagernumber(0)
WF_Document.dept=tmpdoc.dept(0)
WF_Document.deptnumber=tmpdoc.deptnumber(0)
WF_Document.getdate=useTime.DateOnly
WF_Document.attachments=tmpdoc.attachments(0)
WF_Document.buff="未调拨"
WF_Document.WF_DOCCREATED=datetime.LSLocalTime
WF_Document.WF_AddName=WF_UserName
end if
call rdb.saveDocument(WF_Document,"h3c02001_Estate")
next
msgbox "h3c02001:OK"
Exit Sub
errormsg:
Msgbox "Rule Error:" & Str(Erl) & " " & Error
End Sub

posted @ 2013-04-19 16:54  guojian2080  阅读(2733)  评论(0编辑  收藏  举报