下面是我临时写的一个外部脚本,你可以参考这个来做:
记录是放在Excel中,通过vbs读取Excel来进行提交记录,实现导入效果,
使用请先修改
复制内容到剪贴板
代码:
On Error Resume Next
Dim intLoopCount, endLoopCount, Dir, objExcel, objWorkbook, fso
Dim sessionObj, entityObj
Dim i
'This is to skip the header row
intLoopCount = 3
endLoopCount = 10
Set objExcel = CreateObject("Excel.Application")
Set sessionObj = CreateObject("ClearQuest.Session")
Set fso = CreateObject("Scripting.FileSystemObject")
' Login
sessionObj.UserLogon "admin", "admin", "tmm", AD_PRIVATE_SESSION, "pcd"
'Gets the directory where our script is running from
dir = fso.GetParentFolderName(Wscript.ScriptFullName)
'Open our EXCEL file
Set objWorkbook = objExcel.Workbooks.Open(dir & "\recordlist.xls")
For i = intLoopCount To endLoopCount
Set entityObj = sessionObj.BuildEntity("Defect")
' Assume there are 5 columns
entityObj.SetFieldValue "headline", objExcel.Cells(i, 1).Value
entityObj.SetFieldValue "priority", objExcel.Cells(i, 2).Value
entityObj.SetFieldValue "owner", objExcel.Cells(i, 3).Value
entityObj.SetFieldValue "releaseno", objExcel.Cells(i, 4).Value
entityObj.SetFieldValue "steps", objExcel.Cells(i, 5).Value
' validate and submit
status = entityObj.Validate
If status = "" Then
entityObj.Commit
Else
entityObj.Revert
End If
Next
objExcel.Workbooks.Close
objExcel.quit
Set objExcel = Nothing
Set objWorkbook = Nothing
Set fso = Nothing
Set sessionObj = Nothing[
本帖最后由 yunshan 于 2007-12-21 18:49 编辑 ]