PowerDesigner 모든 테이블을 Excel로 내보내기(동일한 테이블)

pdm를 열고 단축키를 누르십시오:ctrl +shift +x
다음 스크립트를 입력하고 Run을 누르십시오
Excel은 다음과 같이 생성됩니다.
시계 이름
중국어
표비고
필드 ID
필드 이름
필드 중국어 이름
필드 유형
필드 노트
'******************************************************************************
'* File:     pdm2excel.vbs
'* Purpose:   , PDM , Excel
'* Title:    
'* Category: 
'* Version:  1.0
'* Author:  [email protected]
'******************************************************************************
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.Iskindof(cls_Table) 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 ="pdm"
    set sheet = EXCEL.workbooks(1).sheets("pdm")

    ' Place some text in the first Row of the sheet.
    sheet.Cells(rowsNum, 1).Value = " "
    sheet.Cells(rowsNum, 2).Value = " "
    sheet.Cells(rowsNum, 3).Value = " "
    sheet.Cells(rowsNum, 4).Value = " ID"
    sheet.Cells(rowsNum, 5).Value = " "
    sheet.Cells(rowsNum, 6).Value = " "
    sheet.Cells(rowsNum, 7).Value = " "
    sheet.Cells(rowsNum, 8).Value = " "
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.code
        sheet.Cells(rowsNum, 2).Value = tab.name
        sheet.Cells(rowsNum, 3).Value = tab.comment
        sheet.Cells(rowsNum, 4).Value = colsNum
        sheet.Cells(rowsNum, 5).Value = col.code
        sheet.Cells(rowsNum, 6).Value = col.name
        sheet.Cells(rowsNum, 7).Value = col.datatype
        sheet.Cells(rowsNum, 8).Value = col.comment
    next
    output "Exported table: "+ +tab.Code+"("+tab.Name+")"
End Sub 

좋은 웹페이지 즐겨찾기