PowerDesigner方向工程并添加注释,导出表到word

pd导出word表跟一般软件的导出功能类似,通过模版定义格式和样式,然后导出自定义格式的word。

一、导出word之前先根据数据库反向生成物理模型

需要先通过powerdesigner的反向工程,根据数据库生成physical model,在反向工程之前先建好数据源

1.1、创建数据源

1、database》configureConnections


2、选择,connection Profiles


3、点击“add data source”


如下:



配置完成,点击“Test Connection”按钮,测试成功即可。

二、反向工程生成表结构

1、file》reverse engineer 》database,如下图所示:


2、选择使用的数据库,如下


3、点击确定


选择已经配置好的数据源

4、点击确定

输入用户名、密码,连接即可


5、连接成功后,就会显示所有的表,你可以针对性的选择你需要的表进行生成

如下,点击ok即可。

就生成了physical model。

三、生成的物理模型table面板上没有显示注释,如何让注释显示在table面板上:

1、Tools》DisplayPreferences,点击进去

2、选择table,点击“Advance”

3、columns》listcolumns点击预览


将code移到第一行,然后点击“ok”。

弹出

选择“ALL symbols”,点击“ok”即可。

4、执行脚本


comment2name.vbs 将显示name的部分由comment来代替掉。将以下脚本代码复制粘贴到以上对话框的空白处。

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 

 

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  

                 ifcol.comment="" then 

                  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 

接着点击保存再运行脚本。切记,不要先运行再保存!!!

接着点击运行按钮RUN。

这样看下注释就加上了。

二、生成word

一:基本使用介绍
1. 在工具栏中选择【Report -->Reports】,如下图
2. 点击第二个图标创建一个Report,如下图
该wizard中有三个信息
Report name Report : Report名字,也是导出word的文件名
Language :语言,有中文汉化包选择Simplified Chinese
Report template : Report模版,如果所示软件本身自带了几个模版,在安装目录Resource Files\Report Templates下
 
3. 选一个默认模版Standard Physical Report,确认后会发现多了两个区Available items和Report items
Available items :软件提供的可用模块,是导出word模版的一个小组件,双击就会添加到Report items区域
Report items : 我选中的模版小组件
4. 根据模版导出word,在工作空间区域,右键Reports下我们建的Report,如下图点击生产RTF格式
以为系统模版要导出的数据比较多会很慢,导出的word格式如下图所示
二 : 定制导出模版
当然这不是我们想要的word,下面看如何做一个自定义模版
1. 在工具栏中选择【Report -->Reports】,如下图
点击第二个图标创建一个Template,如下图
2. 选中Physical Data Model,OK确认
在Available items区域找到List of Tables和List of Table Columns,双击添加到Template items区域
一般导出word也就只需要这两个
List of Tables :所有表的清单,默认显示表名和中文描述,一般不需要改动
List of Table Columns :表的列信息
3. 右键List of Table Columns,如下图所示
Format:字体设置,一般用默认的
Layout:需要显示的属性和显示的宽度
Selection:排序和属性过滤,一般用默认的
4. 设置导出word文档的页眉和页脚,右键模版如下图,不爽的是第一和第二页的页眉页脚这个设置不了
5. 设置title page,右键report如下图
 
选了no title page竟然没效果,郁闷
 
6. 做了一个通用的模版,显示表清单和表列清单, 需要下载点击这里,下面是导出后的效果图
 
文档结构图:
首页:
表清单:
表列清单:

猜你喜欢

转载自blog.csdn.net/menghuannvxia/article/details/79526562