当前位置:网站首页>PowerDesigner connects to entity database to generate physical model in reverse
PowerDesigner connects to entity database to generate physical model in reverse
2022-06-12 06:38:00 【Little white rabbit】
One 、 Generating physical models
Reference resources :
https://www.cnblogs.com/xmyjcs/p/8536233.html
https://blog.csdn.net/iteye_9108/article/details/82572329
Two 、 export excel:
In turn, click Tools ->Excute Commands->Edit/Run Script…
'****************************************************************************** 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
' establish EXCEL APP dim beginrow DIM EXCEL, SHEET, SHEETLIST set EXCEL = CREATEOBJECT("Excel.Application") EXCEL.workbooks.add(-4167)' Add sheet
EXCEL.workbooks(1).sheets(1).name =" Table structure "
set SHEET = EXCEL.workbooks(1).sheets(" Table structure ")
EXCEL.workbooks(1).sheets.add
EXCEL.workbooks(1).sheets(1).name =" Catalog "
set SHEETLIST = EXCEL.workbooks(1).sheets(" Catalog ")
ShowTableList Model,SHEETLIST
ShowProperties Model, SHEET,SHEETLIST
EXCEL.workbooks(1).Sheets(2).Select
EXCEL.visible = true
' Set column width and wrap sheet.Columns(1).ColumnWidth = 20 sheet.Columns(2).ColumnWidth = 20 sheet.Columns(3).ColumnWidth = 20 sheet.Columns(4).ColumnWidth = 40 sheet.Columns(5).ColumnWidth = 10 sheet.Columns(6).ColumnWidth = 10 sheet.Columns(1).WrapText =true sheet.Columns(2).WrapText =true sheet.Columns(4).WrapText =true ' Do not show gridlines
EXCEL.ActiveWindow.DisplayGridlines = False
End If
'----------------------------------------------------------------------------- ' Show properties of tables
'----------------------------------------------------------------------------- Sub ShowProperties(mdl, sheet,SheetList) ' Show tables of the current model/package
rowsNum=0
beginrow = rowsNum+1
Dim rowIndex
rowIndex=3
' For each table output "begin" Dim tab For Each tab In mdl.tables ShowTable tab,sheet,rowIndex,sheetList rowIndex = rowIndex +1 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,rowIndex,sheetList)
If IsObject(tab) Then
Dim rangFlag
rowsNum = rowsNum + 1
' Show properties Output "================================" sheet.cells(rowsNum, 1) =tab.name sheet.cells(rowsNum, 1).HorizontalAlignment=3 sheet.cells(rowsNum, 2) = tab.code 'sheet.cells(rowsNum, 5).HorizontalAlignment=3
'sheet.cells(rowsNum, 6) = "" 'sheet.cells(rowsNum, 7) = " Table description "
sheet.cells(rowsNum, 3) = tab.comment
'sheet.cells(rowsNum, 8).HorizontalAlignment=3 sheet.Range(sheet.cells(rowsNum, 3),sheet.cells(rowsNum, 7)).Merge ' Set hyperlink , Click the table name from the directory to view the table structure
' Field Chinese name Field English name Field type notes Is the primary key? Is it not empty? The default value is sheetList.Hyperlinks.Add sheetList.cells(rowIndex,2), ""," Table structure "&"!B"&rowsNum rowsNum = rowsNum + 1 sheet.cells(rowsNum, 1) = " Field Chinese name " sheet.cells(rowsNum, 2) = " Field English name " sheet.cells(rowsNum, 3) = " Field type " sheet.cells(rowsNum, 4) = " notes " sheet.cells(rowsNum, 5) = " Is the primary key? " sheet.cells(rowsNum, 6) = " Is it not empty? " sheet.cells(rowsNum, 7) = " The default value is " ' Set borders
sheet.Range(sheet.cells(rowsNum-1, 1),sheet.cells(rowsNum, 7)).Borders.LineStyle = "1"
'sheet.Range(sheet.cells(rowsNum-1, 4),sheet.cells(rowsNum, 9)).Borders.LineStyle = "1" ' Font is 10 Number
sheet.Range(sheet.cells(rowsNum-1, 1),sheet.cells(rowsNum, 7)).Font.Size=10
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, 3) = ""
'sheet.cells(rowsNum, 4) = col.name sheet.cells(rowsNum, 2) = col.code sheet.cells(rowsNum, 3) = col.datatype sheet.cells(rowsNum, 4) = col.comment If col.Primary = true Then sheet.cells(rowsNum, 5) = "Y" Else sheet.cells(rowsNum, 5) = " " End If If col.Mandatory = true Then sheet.cells(rowsNum, 6) = "Y" Else sheet.cells(rowsNum, 6) = " " End If sheet.cells(rowsNum, 7) = col.defaultvalue next sheet.Range(sheet.cells(rowsNum-colsNum+1,1),sheet.cells(rowsNum,7)).Borders.LineStyle = "3" 'sheet.Range(sheet.cells(rowsNum-colsNum+1,4),sheet.cells(rowsNum,9)).Borders.LineStyle = "3"
sheet.Range(sheet.cells(rowsNum-colsNum+1,1),sheet.cells(rowsNum,7)).Font.Size = 10
rowsNum = rowsNum + 2
Output "FullDescription: " + tab.Name
End If
End Sub
'----------------------------------------------------------------------------- ' Show List Of Table
'----------------------------------------------------------------------------- Sub ShowTableList(mdl, SheetList) ' Show tables of the current model/package
Dim rowsNo
rowsNo=1
' For each table
output "begin"
SheetList.cells(rowsNo, 1) = " The theme "
SheetList.cells(rowsNo, 2) = " Table name in Chinese "
SheetList.cells(rowsNo, 3) = " Table name in English "
SheetList.cells(rowsNo, 4) = " Table description "
rowsNo = rowsNo + 1
SheetList.cells(rowsNo, 1) = mdl.name
Dim tab
For Each tab In mdl.tables
If IsObject(tab) Then
rowsNo = rowsNo + 1
SheetList.cells(rowsNo, 1) = ""
SheetList.cells(rowsNo, 2) = tab.name
SheetList.cells(rowsNo, 3) = tab.code
SheetList.cells(rowsNo, 4) = tab.comment
End If
Next
SheetList.Columns(1).ColumnWidth = 20
SheetList.Columns(2).ColumnWidth = 20
SheetList.Columns(3).ColumnWidth = 30
SheetList.Columns(4).ColumnWidth = 60
output "end"
End Sub
边栏推荐
- android studio 利用数据库实现登录注册界面功能
- [easyexcel] easyexcel checks whether the header matches the tool class encapsulated in easyexcel, including the field verification function. You can use validate to verify
- Redis application (I) -- distributed lock
- Vscode common plug-ins
- (14)Blender源码分析之闪屏窗口显示软件版本号
- 六月集训 第七日 ——哈希表
- Apache POI import export excel file
- Leetcode January 10 daily question 306 Additive number
- Multithreading (2) -- pipeline (4) -- Park and unpark
- Opencv_ 100 questions_ Chapter V (21-25)
猜你喜欢

SQL language

About session Getattribute, getattribute error

Leetcode January 12 daily question 334 Increasing ternary subsequence

PHP 读写 COOKIE

leetcode:剑指 Offer 66. 构建乘积数组【前后缀积的应用】

AI operation ch8

(14)Blender源码分析之闪屏窗口显示软件版本号

leetcode:剑指 Offer 60. n个骰子的点数【数学 + 层次dp + 累计贡献】

Codeforces Round #793 (Div. 2) A B C

Touch screen setting for win7 system dual screen extended display
随机推荐
AI作业ch8
Codeforces Round #793 (Div. 2) A B C
Zhang Chi: is process a panacea?
Bulk Rename Utility
Android studio mobile development creates a new database and obtains picture and text data from the database to display on the listview list
六月集训 第五天——双指针
美团获得小样本学习榜单FewCLUE第一!Prompt Learning+自训练实战
Codeforces Round #793 (Div. 2) A B C
LeetCode-1716. Calculate the amount deducted from the bank
June training day 6 - sliding window
LeetCode-1154. Day of the year
MySQL multiple SQL batch operations (crud) in JDBC
Whether the modification of basic type and reference type is valid
Install MySQL tutorial
Reentrantlock underlying AQS source code analysis
SQL注入原理即sqli-labs搭建,sql注入简单实战
About session Getattribute, getattribute error
LeetCode-1490. Clone n-ary tree
Torch models trained in higher versions report errors in lower versions
How to build your own website (using the pagoda panel)