文章目录
PowerDesigner16.5快速生成数据库详细设计文档
通过Power Designer的Report功能生成word表格结构的数据库设计文档
1. 定义Report模板
- 定义模板,如模板yuanGenerateWordTemplate.rtp
- 将定义好的模板放在PowerDesigner安装目录Resource Files\Report Templates目录下,如安装目录为:
D:\SAP\PowerDesigner 16\Resource Files\Report Templates
2. 设置code,name,comment同时显示
- 未改之前显示如下:
- 打开菜单 Tools>Display Perferences… 如下图:
上图点击 ok 后如下图:
选择 All symbols -> ok,如下图
3. 执行将comment值替换为name值的VB脚本
- VBScript脚本如下
Option Explicit
ValidationMode = True
InteractiveMode = im_Batch
Dim blankStr
blankStr = Space(1)
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
Private sub ProcessFolder(folder)
On Error Resume Next
Dim Tab 'running table
for each Tab in folder.tables
if not tab.isShortcut then
tab.name = tab.comment
Dim col ' running column
for each col in tab.columns
if col.comment = "" or replace(col.comment," ", "")="" Then
col.name = blankStr
blankStr = blankStr & Space(1)
else
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
view.name = view.comment
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
- 打开菜单 Tools>Execute Commands>Edit/Run Script,然后将上面脚本粘贴到里面,如下图:
脚本粘贴后,点击 Run按钮 执行后再点击 Close按钮关闭窗口即可
4. 导出表结构到Word中
- 打开菜单 Report>Reports…如下图
点击上面文件夹后,出现下面节目
- 打开菜单 Report>Generator Report…如下图
点击OK按钮后,生成《系统管理数据库详细设计.rtf》文档,内容如下:
5. 将rtf转为word
系统管理数据库详细设计.rtf直接可以用word打开,打开后另存为xxxx.doc/xxxx.docx即可