Convert the PDM file of powerdesigner to excel and powerdesignerpdm

Source: Internet
Author: User

Convert the PDM file of powerdesigner to excel and powerdesignerpdm

Put the following script into the script runner of the pd to run it.


'*************************************** * ************************************ Option explicit Dim rowsNum = 0 'comment 'main function' then 'get the current active model Dim Model Set Model = ActiveModel If (Model Is Nothing) or (Not Model. isKindOf (Pd PDM. cls_Model) Then MsgBox "The current model is not an PDM model. "Else 'get the tables collect' to create an excel app dim beginrow dim excel, SHEET, SHEETLIST set EXCEL = CREATEOBJECT (" Excel. application ") EXCEL. workbooks. add (-4167) 'add worksheet EXCEL. workbooks (1 ). sheets (1 ). name = "table structure" set SHEET = EXCEL. workbooks (1 ). sheet ("table structure") EXCEL. workbooks (1 ). sheets. add EXCEL. workbooks (1 ). sheets (1 ). name = "directory" set SHEET LIST = EXCEL. workbooks (1 ). sheets ("directory") ShowTableList Model, SHEETLIST ShowProperties Model, SHEET, sheetlist excel. workbooks (1 ). sheets (2 ). select EXCEL. visible = true' set the column width and automatically wrap the 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 ). wrap Text = true sheet. columns (2 ). wrapText = true sheet. columns (4 ). wrapText = true' the gridline EXCEL is not displayed. activeWindow. displayGridlines = False End If 'hangzhou' Show properties of tables 'using Sub ShowProperties (mdl, sheet, SheetList) 'show tables of the current model/package RowsNum = 0 beginrow = rowsNum + 1 Dim 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 prope Rties '--------------------------------------------------------------------------- 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 ). horizontalAlign Ment = 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' sets the hyperlink, click the table name from the directory to view the table structure 'field Chinese Name field English Name field type comment whether the primary key is not empty default value sheetList. hyperlinks. add sheetList. cells (rowIndex, 2), "", "table structure "&"! B "& rowsNum = rowsNum + 1 sheet. cells (rowsNum, 1) = "Chinese name of the field" sheet. cells (rowsNum, 2) = "field English name" sheet. cells (rowsNum, 3) = "field type" sheet. cells (rowsNum, 4) = "comment" sheet. cells (rowsNum, 5) = "primary key" sheet. cells (rowsNum, 6) = "whether it is not empty" sheet. cells (rowsNum, 7) = "Default Value" 'sets the border 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" '. The font is sheet 10. range (sheet. cells (rowsNum-1, 1), sheet. cells (rowsNum, 7 )). font. size = 10 Dim col 'running column Dim 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 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 'region' Show List Of table' --------------------------------------------------------------------------- Sub ShowTableList (mdl, SheetList) 'Show tables of the current model/package Dim rowsNo = 1' For each table output "begin" SheetList. cells (rowsNo, 1) = "topic" SheetList. cells (rowsNo, 2) = "Chinese Table Name" SheetList. cells (rowsNo, 3) = "Table English name" 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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.