- 浏览: 230646 次
- 性别:
- 来自: 杭州
文章分类
最新评论
-
hl174:
写的不错,赞一个
在Java中字节与十六进制的相互转换主要思想有两点 -
l540151663:
也是个好方法
String为空判断
PowerDesigner 数据库设计导出到Excel
在PowerDesigner 中 ctrl+shift+x 弹出执行脚本界面,输入如下代码就会生成 Excel
代码一:所有的表在同一个 Sheet 页中
[vb] view plain copy
'******************************************************************************
'* File: pdm2excel.txt
'* Title: pdm export to excel
'* Purpose: To export the tables and columns to Excel
'* Model: Physical Data Model
'* Objects: Table, Column, View
'* Author: ziyan
'* Created: 2012-05-03
'* Version: 1.0
'******************************************************************************
Option Explicit
Dim rowsNum
rowsNum = 0
'-----------------------------------------------------------------------------
' Main function
'-----------------------------------------------------------------------------
' Get the current active model
Dim Model
Set Model = ActiveModel
If (Model Is Nothing) Or (Not Model.IsKindOf(PdPDM.cls_Model)) Then
MsgBox "The current model is not an PDM model."
Else
' Get the tables collection
'创建EXCEL APP
dim beginrow
DIM EXCEL, SHEET
set EXCEL = CREATEOBJECT("Excel.Application")
EXCEL.workbooks.add(-4167)'添加工作表
EXCEL.workbooks(1).sheets(1).name ="test"
set sheet = EXCEL.workbooks(1).sheets("test")
ShowProperties Model, SHEET
EXCEL.visible = true
'设置列宽和自动换行
sheet.Columns(1).ColumnWidth = 20
sheet.Columns(2).ColumnWidth = 40
sheet.Columns(4).ColumnWidth = 20
sheet.Columns(5).ColumnWidth = 20
sheet.Columns(6).ColumnWidth = 15
sheet.Columns(1).WrapText =true
sheet.Columns(2).WrapText =true
sheet.Columns(4).WrapText =true
End If
'-----------------------------------------------------------------------------
' Show properties of tables
'-----------------------------------------------------------------------------
Sub ShowProperties(mdl, sheet)
' Show tables of the current model/package
rowsNum=0
beginrow = rowsNum+1
' For each table
output "begin"
Dim tab
For Each tab In mdl.tables
ShowTable tab,sheet
Next
if mdl.tables.count > 0 then
sheet.Range("A" & beginrow + 1 & ":A" & rowsNum).Rows.Group
end if
output "end"
End Sub
'-----------------------------------------------------------------------------
' Show table properties
'-----------------------------------------------------------------------------
Sub ShowTable(tab, sheet)
If IsObject(tab) Then
Dim rangFlag
rowsNum = rowsNum + 1
' Show properties
Output "================================"
sheet.cells(rowsNum, 1) = "实体名"
sheet.cells(rowsNum, 2) =tab.name
sheet.cells(rowsNum, 3) = ""
sheet.cells(rowsNum, 4) = "表名"
sheet.cells(rowsNum, 5) = tab.code
sheet.Range(sheet.cells(rowsNum, 5),sheet.cells(rowsNum, 6)).Merge
rowsNum = rowsNum + 1
sheet.cells(rowsNum, 1) = "属性名"
sheet.cells(rowsNum, 2) = "说明"
sheet.cells(rowsNum, 3) = ""
sheet.cells(rowsNum, 4) = "字段中文名"
sheet.cells(rowsNum, 5) = "字段名"
sheet.cells(rowsNum, 6) = "字段类型"
'设置边框
sheet.Range(sheet.cells(rowsNum-1, 1),sheet.cells(rowsNum, 2)).Borders.LineStyle = "1"
sheet.Range(sheet.cells(rowsNum-1, 4),sheet.cells(rowsNum, 6)).Borders.LineStyle = "1"
Dim col ' running column
Dim colsNum
colsNum = 0
for each col in tab.columns
rowsNum = rowsNum + 1
colsNum = colsNum + 1
sheet.cells(rowsNum, 1) = col.name
sheet.cells(rowsNum, 2) = col.comment
sheet.cells(rowsNum, 3) = ""
sheet.cells(rowsNum, 4) = col.name
sheet.cells(rowsNum, 5) = col.code
sheet.cells(rowsNum, 6) = col.datatype
next
sheet.Range(sheet.cells(rowsNum-colsNum+1,1),sheet.cells(rowsNum,2)).Borders.LineStyle = "2"
sheet.Range(sheet.cells(rowsNum-colsNum+1,4),sheet.cells(rowsNum,6)).Borders.LineStyle = "2"
rowsNum = rowsNum + 1
Output "FullDescription: " + tab.Name
End If
End Sub
代码二:每个表都会新建一个 Sheet 页,第一个 Sheet 页上是所有表的列表
[vb] view plain copy
'******************************************************************************
'* File: pdm2excel.txt
'* Title: pdm export to excel
'* Purpose: To export the tables and columns to Excel
'* Model: Physical Data Model
'* Objects: Table, Column, View
'* Author: Chirs
'* Created: 2015-01-28
'* Version: 1.0
'******************************************************************************
Option Explicit
Dim rowsNum
rowsNum = 0
'-----------------------------------------------------------------------------
' Main function
'-----------------------------------------------------------------------------
' Get the current active model
Dim Model
Set Model = ActiveModel
If (Model Is Nothing) Or (Not Model.IsKindOf(PdPDM.cls_Model)) Then
MsgBox "The current model is not an PDM model."
Else
' Get the tables collection
'创建EXCEL APP
Dim beginrow
Dim EXCEL, BOOK, SHEET
Set EXCEL = CreateObject("Excel.Application")
EXCEL.Visible = True
Set BOOK = EXCEL.Workbooks.Add(-4167) '新建工作簿
BOOK.Sheets(1).Name = "数据库表结构"
Set SHEET = EXCEL.workbooks(1).sheets("数据库表结构")
ShowProperties Model, SHEET
EXCEL.visible = true
'设置列宽和自动换行
SHEET.Columns(1).ColumnWidth = 10
SHEET.Columns(2).ColumnWidth = 30
SHEET.Columns(3).ColumnWidth = 20
SHEET.Columns(1).WrapText =true
SHEET.Columns(2).WrapText =true
SHEET.Columns(3).WrapText =true
End If
'-----------------------------------------------------------------------------
' Show properties of tables
'-----------------------------------------------------------------------------
Sub ShowProperties(mdl, sheet)
' Show tables of the current model/package
rowsNum=0
beginrow = rowsNum+1
' For each table
output "begin"
Dim tab
For Each tab In mdl.tables
ShowTable tab,sheet
Next
if mdl.tables.count > 0 then
sheet.Range("A" & beginrow + 1 & ":A" & rowsNum).Rows.Group
end if
output "end"
End Sub
'-----------------------------------------------------------------------------
' 数据表查询
'-----------------------------------------------------------------------------
Sub ShowTable(tab, sheet)
If IsObject(tab) Then
Dim rangFlag
sheet.cells(1, 1) = "序号"
sheet.cells(1, 2) = "表名"
sheet.cells(1, 3) = "实体名"
'设置边框
sheet.Range(sheet.cells(1, 1),sheet.cells(1, 3)).Borders.LineStyle = "1"
'设置背景颜色
sheet.Range(sheet.cells(1, 1),sheet.cells(1, 3)).Interior.ColorIndex = "19"
rowsNum = rowsNum + 1
sheet.cells(rowsNum+1, 1) = rowsNum
sheet.cells(rowsNum+1, 2) = tab.code
sheet.cells(rowsNum+1, 3) = tab.name
'设置边框
sheet.Range(sheet.cells(rowsNum+1,1),sheet.cells(rowsNum+1,3)).Borders.LineStyle = "2"
'增加Sheet
BOOK.Sheets.Add , BOOK.Sheets(BOOK.Sheets.count)
BOOK.Sheets(rowsNum+1).Name = tab.code
Dim shtn
Set shtn = EXCEL.workbooks(1).sheets(tab.code)
'设置列宽和换行
shtn.Columns(1).ColumnWidth = 30
shtn.Columns(2).ColumnWidth = 20
shtn.Columns(3).ColumnWidth = 20
shtn.Columns(5).ColumnWidth = 30
shtn.Columns(6).ColumnWidth = 20
shtn.Columns(1).WrapText =true
shtn.Columns(2).WrapText =true
shtn.Columns(3).WrapText =true
shtn.Columns(5).WrapText =true
shtn.Columns(6).WrapText =true
'设置列标题
shtn.cells(1, 1) = "字段中文名"
shtn.cells(1, 2) = "字段名"
shtn.cells(1, 3) = "字段类型"
shtn.cells(1, 5) = tab.code
shtn.cells(1, 6) = tab.Name
'设置边框
shtn.Range(shtn.cells(1, 1),shtn.cells(1, 3)).Borders.LineStyle = "1"
shtn.Range(shtn.cells(1, 5),shtn.cells(1, 6)).Borders.LineStyle = "1"
'设置背景颜色
shtn.Range(shtn.cells(1, 1),shtn.cells(1, 3)).Interior.ColorIndex = "19"
shtn.Range(shtn.cells(1, 5),shtn.cells(1, 6)).Interior.ColorIndex = "19"
Dim col ' running column
Dim colsNum
Dim rNum
colsNum = 0
rNum = 0
for each col in tab.columns
rNum = rNum + 1
colsNum = colsNum + 1
shtn.cells(rNum+1, 1) = col.name
shtn.cells(rNum+1, 2) = col.code
shtn.cells(rNum+1, 3) = col.datatype
next
shtn.Range(shtn.cells(rNum-colsNum+2,1),shtn.cells(rNum+1,3)).Borders.LineStyle = "2"
rNum = rNum + 1
Output "FullDescription: " + tab.Name
End If
End Sub
在PowerDesigner 中 ctrl+shift+x 弹出执行脚本界面,输入如下代码就会生成 Excel
代码一:所有的表在同一个 Sheet 页中
[vb] view plain copy
'******************************************************************************
'* File: pdm2excel.txt
'* Title: pdm export to excel
'* Purpose: To export the tables and columns to Excel
'* Model: Physical Data Model
'* Objects: Table, Column, View
'* Author: ziyan
'* Created: 2012-05-03
'* Version: 1.0
'******************************************************************************
Option Explicit
Dim rowsNum
rowsNum = 0
'-----------------------------------------------------------------------------
' Main function
'-----------------------------------------------------------------------------
' Get the current active model
Dim Model
Set Model = ActiveModel
If (Model Is Nothing) Or (Not Model.IsKindOf(PdPDM.cls_Model)) Then
MsgBox "The current model is not an PDM model."
Else
' Get the tables collection
'创建EXCEL APP
dim beginrow
DIM EXCEL, SHEET
set EXCEL = CREATEOBJECT("Excel.Application")
EXCEL.workbooks.add(-4167)'添加工作表
EXCEL.workbooks(1).sheets(1).name ="test"
set sheet = EXCEL.workbooks(1).sheets("test")
ShowProperties Model, SHEET
EXCEL.visible = true
'设置列宽和自动换行
sheet.Columns(1).ColumnWidth = 20
sheet.Columns(2).ColumnWidth = 40
sheet.Columns(4).ColumnWidth = 20
sheet.Columns(5).ColumnWidth = 20
sheet.Columns(6).ColumnWidth = 15
sheet.Columns(1).WrapText =true
sheet.Columns(2).WrapText =true
sheet.Columns(4).WrapText =true
End If
'-----------------------------------------------------------------------------
' Show properties of tables
'-----------------------------------------------------------------------------
Sub ShowProperties(mdl, sheet)
' Show tables of the current model/package
rowsNum=0
beginrow = rowsNum+1
' For each table
output "begin"
Dim tab
For Each tab In mdl.tables
ShowTable tab,sheet
Next
if mdl.tables.count > 0 then
sheet.Range("A" & beginrow + 1 & ":A" & rowsNum).Rows.Group
end if
output "end"
End Sub
'-----------------------------------------------------------------------------
' Show table properties
'-----------------------------------------------------------------------------
Sub ShowTable(tab, sheet)
If IsObject(tab) Then
Dim rangFlag
rowsNum = rowsNum + 1
' Show properties
Output "================================"
sheet.cells(rowsNum, 1) = "实体名"
sheet.cells(rowsNum, 2) =tab.name
sheet.cells(rowsNum, 3) = ""
sheet.cells(rowsNum, 4) = "表名"
sheet.cells(rowsNum, 5) = tab.code
sheet.Range(sheet.cells(rowsNum, 5),sheet.cells(rowsNum, 6)).Merge
rowsNum = rowsNum + 1
sheet.cells(rowsNum, 1) = "属性名"
sheet.cells(rowsNum, 2) = "说明"
sheet.cells(rowsNum, 3) = ""
sheet.cells(rowsNum, 4) = "字段中文名"
sheet.cells(rowsNum, 5) = "字段名"
sheet.cells(rowsNum, 6) = "字段类型"
'设置边框
sheet.Range(sheet.cells(rowsNum-1, 1),sheet.cells(rowsNum, 2)).Borders.LineStyle = "1"
sheet.Range(sheet.cells(rowsNum-1, 4),sheet.cells(rowsNum, 6)).Borders.LineStyle = "1"
Dim col ' running column
Dim colsNum
colsNum = 0
for each col in tab.columns
rowsNum = rowsNum + 1
colsNum = colsNum + 1
sheet.cells(rowsNum, 1) = col.name
sheet.cells(rowsNum, 2) = col.comment
sheet.cells(rowsNum, 3) = ""
sheet.cells(rowsNum, 4) = col.name
sheet.cells(rowsNum, 5) = col.code
sheet.cells(rowsNum, 6) = col.datatype
next
sheet.Range(sheet.cells(rowsNum-colsNum+1,1),sheet.cells(rowsNum,2)).Borders.LineStyle = "2"
sheet.Range(sheet.cells(rowsNum-colsNum+1,4),sheet.cells(rowsNum,6)).Borders.LineStyle = "2"
rowsNum = rowsNum + 1
Output "FullDescription: " + tab.Name
End If
End Sub
代码二:每个表都会新建一个 Sheet 页,第一个 Sheet 页上是所有表的列表
[vb] view plain copy
'******************************************************************************
'* File: pdm2excel.txt
'* Title: pdm export to excel
'* Purpose: To export the tables and columns to Excel
'* Model: Physical Data Model
'* Objects: Table, Column, View
'* Author: Chirs
'* Created: 2015-01-28
'* Version: 1.0
'******************************************************************************
Option Explicit
Dim rowsNum
rowsNum = 0
'-----------------------------------------------------------------------------
' Main function
'-----------------------------------------------------------------------------
' Get the current active model
Dim Model
Set Model = ActiveModel
If (Model Is Nothing) Or (Not Model.IsKindOf(PdPDM.cls_Model)) Then
MsgBox "The current model is not an PDM model."
Else
' Get the tables collection
'创建EXCEL APP
Dim beginrow
Dim EXCEL, BOOK, SHEET
Set EXCEL = CreateObject("Excel.Application")
EXCEL.Visible = True
Set BOOK = EXCEL.Workbooks.Add(-4167) '新建工作簿
BOOK.Sheets(1).Name = "数据库表结构"
Set SHEET = EXCEL.workbooks(1).sheets("数据库表结构")
ShowProperties Model, SHEET
EXCEL.visible = true
'设置列宽和自动换行
SHEET.Columns(1).ColumnWidth = 10
SHEET.Columns(2).ColumnWidth = 30
SHEET.Columns(3).ColumnWidth = 20
SHEET.Columns(1).WrapText =true
SHEET.Columns(2).WrapText =true
SHEET.Columns(3).WrapText =true
End If
'-----------------------------------------------------------------------------
' Show properties of tables
'-----------------------------------------------------------------------------
Sub ShowProperties(mdl, sheet)
' Show tables of the current model/package
rowsNum=0
beginrow = rowsNum+1
' For each table
output "begin"
Dim tab
For Each tab In mdl.tables
ShowTable tab,sheet
Next
if mdl.tables.count > 0 then
sheet.Range("A" & beginrow + 1 & ":A" & rowsNum).Rows.Group
end if
output "end"
End Sub
'-----------------------------------------------------------------------------
' 数据表查询
'-----------------------------------------------------------------------------
Sub ShowTable(tab, sheet)
If IsObject(tab) Then
Dim rangFlag
sheet.cells(1, 1) = "序号"
sheet.cells(1, 2) = "表名"
sheet.cells(1, 3) = "实体名"
'设置边框
sheet.Range(sheet.cells(1, 1),sheet.cells(1, 3)).Borders.LineStyle = "1"
'设置背景颜色
sheet.Range(sheet.cells(1, 1),sheet.cells(1, 3)).Interior.ColorIndex = "19"
rowsNum = rowsNum + 1
sheet.cells(rowsNum+1, 1) = rowsNum
sheet.cells(rowsNum+1, 2) = tab.code
sheet.cells(rowsNum+1, 3) = tab.name
'设置边框
sheet.Range(sheet.cells(rowsNum+1,1),sheet.cells(rowsNum+1,3)).Borders.LineStyle = "2"
'增加Sheet
BOOK.Sheets.Add , BOOK.Sheets(BOOK.Sheets.count)
BOOK.Sheets(rowsNum+1).Name = tab.code
Dim shtn
Set shtn = EXCEL.workbooks(1).sheets(tab.code)
'设置列宽和换行
shtn.Columns(1).ColumnWidth = 30
shtn.Columns(2).ColumnWidth = 20
shtn.Columns(3).ColumnWidth = 20
shtn.Columns(5).ColumnWidth = 30
shtn.Columns(6).ColumnWidth = 20
shtn.Columns(1).WrapText =true
shtn.Columns(2).WrapText =true
shtn.Columns(3).WrapText =true
shtn.Columns(5).WrapText =true
shtn.Columns(6).WrapText =true
'设置列标题
shtn.cells(1, 1) = "字段中文名"
shtn.cells(1, 2) = "字段名"
shtn.cells(1, 3) = "字段类型"
shtn.cells(1, 5) = tab.code
shtn.cells(1, 6) = tab.Name
'设置边框
shtn.Range(shtn.cells(1, 1),shtn.cells(1, 3)).Borders.LineStyle = "1"
shtn.Range(shtn.cells(1, 5),shtn.cells(1, 6)).Borders.LineStyle = "1"
'设置背景颜色
shtn.Range(shtn.cells(1, 1),shtn.cells(1, 3)).Interior.ColorIndex = "19"
shtn.Range(shtn.cells(1, 5),shtn.cells(1, 6)).Interior.ColorIndex = "19"
Dim col ' running column
Dim colsNum
Dim rNum
colsNum = 0
rNum = 0
for each col in tab.columns
rNum = rNum + 1
colsNum = colsNum + 1
shtn.cells(rNum+1, 1) = col.name
shtn.cells(rNum+1, 2) = col.code
shtn.cells(rNum+1, 3) = col.datatype
next
shtn.Range(shtn.cells(rNum-colsNum+2,1),shtn.cells(rNum+1,3)).Borders.LineStyle = "2"
rNum = rNum + 1
Output "FullDescription: " + tab.Name
End If
End Sub
发表评论
-
jrebel注册码
2017-11-28 17:26 11201、登陆https://my.jrebel.com/accou ... -
chrome设置禁用缓存
2017-08-30 14:32 586Google浏览器中,F12,控制台,选择右上的设置(sett ... -
markdown一般常用功能
2017-06-11 18:30 471一般用下面的目录就可以了 == # 功能说明 ## 功能1 * ... -
idea内存修改
2017-05-25 10:01 879我这边再用idea 我在启动我的项目的时候非常的慢 并且在T ... -
webstrom注册码
2017-03-01 19:55 841http://idea.imsxm.com/ -
Intellij IDEA
2017-01-10 17:20 730Intellij IDEA使用总结 博 ... -
intellij jrebel 6.5 license server
2016-10-29 23:52 3056http://idea.qinxi1992.cn/xxxxxx ... -
logback总结(三)
2016-10-29 16:27 604<?xml version="1.0" ... -
logback总结(二)
2016-10-29 16:28 512logback 常用配置详解( ... -
logback总结(一)
2016-10-29 16:23 445logback 配置详解(一) 标签: xmlthreadja ... -
idea快捷键
2016-08-24 15:41 509修改主窗口的tab页 file-Editor-Editor t ... -
idea svn
2016-07-21 17:01 606本地项目导入svn vcs-import into versi ... -
远程桌面工具
2016-06-22 10:52 556qq,AnyDesk.exe,TeamViewer 11 -
eclipse导出war包
2016-05-22 23:06 1188在项目上点右键->properties eclipse打 ... -
IntelliJ Idea 常用快捷键列表
2016-05-15 17:47 540IntelliJ Idea 常用快捷键 ... -
Git学习笔记与IntelliJ IDEA整合
2016-05-13 14:16 654Git学习笔记与IntelliJ IDEA整合 2014-05 ... -
eclipse格式化代码不能用
2016-05-12 16:12 490文章摘抄至 http://blog.csdn.net/abbu ... -
sublime使用技巧
2016-05-09 23:44 5621:按住滚轮,进行列选择 2:ctrl+{} 进行缩进 3:c ... -
idea svn配置
2016-05-09 19:17 1019前言:最近打算在团队开发环境中采用Idea,然后我自己用的是m ... -
MyEclipse-6.5注册码生成器源码
2014-11-26 10:54 733MyEclipse-6.5注册码生成器源码 分类 ...
相关推荐
步骤: 1、用PowerDesigner打开要导出的PDM文件 2、Tools->Execute Commands -> Edit/Run Script... 3、点击Open图标(打开文件夹)找到该脚本文件 4、点击Run按钮
该方法为powerdesigner逆向连接oracle数据库,生成.pdm文件,然后根据.pdm文件导出数据库文档的方法,文档中的方法都已经测试,可以导出word,html,和word三种格式。
这就是"PowerDesigner(PDM)文件自动转换为Excel文件格式"这个话题的核心。 这个转换过程涉及到以下几个关键知识点: 1. **PowerDesigner的PDM文件**:PDM文件是PowerDesigner保存物理数据模型的文件格式,其中...
执行脚本命令,把pdm文件导出成Excel格式的表结构定义。
脚本是参考网络资源修改的,文档格式是个通用格式不针对特定公司需求
本文将详细介绍如何利用PowerDesigner导入Excel文档,将其转化为实体表,以便进行数据库设计。 首先,我们需要理解PowerDesigner的基本功能。PowerDesigner支持概念数据模型(CDM),逻辑数据模型(LDM)和物理数据模型...
在进行数据库设计时,经常会遇到需要将Excel表格中的数据转换为PowerDesigner的数据模型,即PDM(Physical Data Model)。这个过程可以极大地提高工作效率,特别是在处理大量数据时。本文将详细介绍如何利用Excel...
在数据库开发过程中,有时我们需要将PowerDesigner中的表结构导出为Excel格式,以便于数据分析、报告编写或者与非技术人员共享。标题提到的"导出PowerDesigner表结构到EXCEL脚本"正是解决这一需求的方法。 ...
描述中提到的“从PowerDesigner中进行模型的导入导出(excel)”,意味着模型数据可以被导出为Excel表格,这种格式便于非技术人员理解,同时也方便在Excel中进行计算和数据分析。 接下来,我们关注VB脚本。VB是一种...
PDMReader也具备ADO连接数据库的基本建议功能,并提供比如SQL脚本导出,excel,word,html,xls,txt文件导出等。 如果您或者您所在公司在数据库开发中使用SyBase公司的PowerDesigner产品进行Physical Data Model数据...
在企业环境中,数据可能来自多个源头,如数据库、CSV文件、Excel表格等,格式各异,因此需要通过数据转换来统一。 压缩包中的“数据转换工具”可能包含以下几类: 1. ETL工具:ETL(Extract, Transform, Load)是...
- **详细说明**:PowerDesigner是一款强大的数据库设计工具,通过它可以方便地绘制出清晰直观的实体关系图,并据此生成相应的数据字典文件。此外,PowerDesigner还支持直接将设计好的模型转换成数据库脚本,大大...