PowerDesigner(PDM转Excel、Comment同步Name)

博客介绍了使用PowerDesigner 16.5将PDM转Excel的操作步骤,包括工具、快捷键和执行方式,还提到表名长度限制。同时给出相关脚本,介绍了VBScript中对Excel的常见操作,以及VBA中颜色设置的相关内容。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1. 操作步骤

工具:powerdesigner 16.5

快捷键:ctrl+shift+x

执行:点击“run”

说明1:可复制以下脚本,执行pdm转excel;

说明2:表名长度不可超过31个字符,否则执行会中断;

说明3:以下格式仅用于支持当前需求,如果需要调整样式及导出顺序,可参考目录3、目录4中vbs对excel的操作,修改函数 ExportTable 或 函数 AddSheet

2. Comment向Name同步脚本

转自:PowerDesigner Comment 同步至 Name

Option Explicit
ValidationMode = True
InteractiveMode = im_Batch
 
Dim mdl 'the current model
 
'get the current active model
Set mdl = ActiveModel
If (mdl Is Nothing) Then
MsgBox "There is no current Model"
ElseIf Not mdl.IsKindOf(PdPDM.cls_Model) Then
MsgBox "The current model is not an Physical Data model."
Else
ProcessFolder mdl
End If
 
'This routine copy name into code for each table, each column and each view
'of the current folder
Private sub ProcessFolder(folder)
Dim Tab 'running table
for each Tab in folder.tables
if not tab.isShortcut then
if len(tab.comment) <> 0 then
tab.name = tab.comment
end if
Dim col 'running column
for each col in tab.columns
if len(col.comment) <> 0 then
col.name= col.comment
end if
next
end if
next
 
Dim view 'running view
for each view in folder.Views
if not view.isShortcut then
if len(view.comment) <> 0 then
view.name = view.comment
end if
end if
next
 
'go into the sub-packages
Dim f 'running folder
For Each f In folder.Packages
if not f.IsShortcut then
ProcessFolder f
end if
Next
end sub

3. Excel导出脚本

'******************************************************************************
'* File:     Exported_Excel_page.vbs
'* Purpose:  分目录递归,查找当前PDM下所有表,并导出Excel
'******************************************************************************

Option Explicit
ValidationMode = True
InteractiveMode = im_Batch

'-----------------------------------------------------------------------------
' 主函数
'-----------------------------------------------------------------------------
' 获取当前活动模型
Dim mdl ' 当前的模型
Set mdl = ActiveModel
Dim EXCEL,catalog,sheet,catalogNum,rowsNum,linkNum
rowsNum = 1
catalogNum = 1
linkNum = 1

If (mdl Is Nothing) Then
    MsgBox "There is no Active Model"
Else
    SetCatalog
    ListObjects(mdl)
End If

'----------------------------------------------------------------------------------------------
' 子过程,用于扫描当前包并从当前包中打印对象的信息,然后对当前包的所有子包再次调用相同的子过程
'----------------------------------------------------------------------------------------------
Private Sub ListObjects(fldr)
    output "Scanning " & fldr.code
    Dim obj ' 运行对象
    For Each obj In fldr.children
        ' 调用子过程来打印对象上的信息
        DescribeObject obj
    Next
    ' 进入子包
    Dim f ' 运行文件夹
    For Each f In fldr.Packages
        '调用子程序扫描子程序包
        ListObjects f
    Next
End Sub

'-----------------------------------------------------------------------------
' 子过程,用于在输出中打印当前对象的信息
'-----------------------------------------------------------------------------
Private Sub DescribeObject(CurrentObject)
    if not CurrentObject.Iskindof(cls_NamedObjec
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值