在PowerDesigner中,批量导出视图的所有字段到Excel

'******************************************************************************
'* File:     pdm2excel.vbs
'* Purpose:  导出字段信息
'******************************************************************************
Option Explicit
ValidationMode = True
InteractiveMode = im_Batch
' get the current active model
Dim mdl ' the current model
Set mdl = ActiveModel
Dim EXCEL,sheet,rowsNum
rowsNum = 1
 
If (mdl Is Nothing) Then
    MsgBox "There is no Active Model"
Else
    SetExcel
    ListObjects(mdl)
End If
'-----------------------------------------------------------------------------
' Sub procedure to scan current package and print information on objects from current package
' and call again the same sub procedure on all children pacakge 
' of the current package
'-----------------------------------------------------------------------------
Private Sub ListObjects(fldr)
    output "Scanning " & fldr.code
    Dim obj ' running object
    For Each obj In fldr.children
        ' Calling sub procedure to print out information on the object
        DescribeObject obj
    Next
    ' go into the sub-packages
    Dim f ' running folder
    For Each f In fldr.Packages
        'calling sub procedure to scan children package
        ListObjects f
    Next
End Sub
'-----------------------------------------------------------------------------
' Sub procedure to print information on current object in output
'-----------------------------------------------------------------------------
Private Sub DescribeObject(CurrentObject)
      
    'if not CurrentObject.Iskindof(cls_NamedObject) then exit sub
    if CurrentObject.ClassName="View" then 
        ExportTable CurrentObject, sheet
    else
        output "Found "+CurrentObject.ClassName+" """+CurrentObject.Name+""", Created by "+CurrentObject.Creator+" On "+Cstr(CurrentObject.CreationDate)   
    End if
End Sub
 
 
Sub SetExcel()
    Set EXCEL= CreateObject("Excel.Application")
 
    ' Make Excel visible through the Application object.
    EXCEL.Visible = True
    EXCEL.workbooks.add(-4167)'添加工作表
    EXCEL.workbooks(1).sheets(1).name ="视图字段清单"
    set sheet = EXCEL.workbooks(1).sheets("视图字段清单")
 
    ' Place some text in the first Row of the sheet.
    sheet.Cells(rowsNum, 1).Value = "Table Name"
    sheet.Cells(rowsNum, 2).Value = "Table Code"
    sheet.Cells(rowsNum, 3).Value = "Column Name"
     sheet.Cells(rowsNum, 4).Value = "Column Code"
    sheet.Cells(rowsNum, 5).Value = "Comment"
    sheet.Cells(rowsNum, 6).Value = "Data Type"

End Sub
 
Sub ExportTable(tab, sheet)
    Dim col ' running column
    Dim colsNum
    colsNum = 0
    for each col in tab.columns
        colsNum = colsNum + 1
        rowsNum = rowsNum + 1
        sheet.Cells(rowsNum, 1).Value = tab.name
        sheet.Cells(rowsNum, 2).Value = tab.code
        sheet.Cells(rowsNum, 3).Value = col.name
        sheet.Cells(rowsNum, 4).Value = col.code
        sheet.Cells(rowsNum, 5).Value = col.comment
        sheet.Cells(rowsNum, 6).Value = col.datatype

    next
    output "Exported table: "+ +tab.Code+"("+tab.Name+")"
end sub

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值