发新话题
打印

[已解决] 有什么脚本可以直接将EXCEL文件导入到CQ中( 此文章被查看:460次,被回复:1篇!! )

有什么脚本可以直接将EXCEL文件导入到CQ中

有什么脚本可以直接将EXCEL文件导入到CQ中,不用先转换为txt文件再导


问题已经解决 [打开主题]
本主题的最佳答案为 [ 2 楼].



© 本文为 lilinSCMLife 共同所有,未经同意,请勿转载 ©如该文侵犯了您的版权,请联系管理员

TOP

下面是我临时写的一个外部脚本,你可以参考这个来做:
记录是放在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 编辑 ]


最佳答案
该回答被楼主/管理员列为正解!



© 本文为 yunshanSCMLife 共同所有,未经同意,请勿转载 ©如该文侵犯了您的版权,请联系管理员

TOP

发新话题