Today received a demand, to the database design to an Excel version, Baidu came out a script file, very useful to find, leave a memorial
In PD, SHIFT+CTRL+X, open the script to run, the script is as follows, the attachment also left a copy:
‘******************************************************************************‘*TITLE:PDM Export to Excel‘* purpose:to Export the tables and columns to Excel‘*model:physical Data Model‘* objects:table, Column, View‘*Author:gunag‘* created:2016-06-03' * version:1.0 '******************************************************************************option Explicit Dim rowsNum Rowsnum = 0‘-----------------------------------------------------------------------------‘Main function‘-----------------------------------------------------------------------------‘Get The current active Modeldim modelset model = Activemodelif (Model was nothing) Or (not Model.iskindof (pdpdm.cls_mo del) then MsgBox "The current model was not a PDM model." Else‘Get the Tables collection‘Create Excel APP Dim beginrow Dim Excel, SHEET Set Excel = CreateObject ("Excel.Application") EXCEL.workbooks.add ( -4167) ‘Add sheet excel.workbooks (1). Sheets (1). Name = "Test"Set Sheet= Excel.Workbooks (1). Sheets ("test")) showproperties Model, SHEET excel.visible=true‘set the column width and wrap sheet. Columns (1). ColumnWidth = sheet. Columns (2). ColumnWidth = sheet. Columns (4). ColumnWidth = sheet. Columns (5). ColumnWidth = sheet. Columns (6). ColumnWidth = 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 NextifMdl.tables.count > 0Then sheet. Range ("A" & Beginrow + 1 & ": A" &rowsnum). Rows.group EndifOutput"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) = "Entity name"sheet.cells (Rowsnum,2) =tab.name sheet.cells (Rowsnum,3) = ""sheet.cells (Rowsnum,4) = "Table name"sheet.cells (Rowsnum,5) =tab.code Sheet. Range (Sheet.cells (Rowsnum,5), Sheet.cells (Rowsnum, 6)). Merge Rowsnum= Rowsnum + 1sheet.cells (Rowsnum,1) = "Property name"sheet.cells (Rowsnum,2) = "description"sheet.cells (Rowsnum,3) = ""sheet.cells (Rowsnum,4) = "Field Chinese name"sheet.cells (Rowsnum,5) = "Field name"sheet.cells (Rowsnum,6) = "Field type" 'sets the border 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 Columndim colsnumcolsnum= 0 forEach colinchtab.columns Rowsnum= Rowsnum + 1Colsnum= Colsnum + 1sheet.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 + 1Output"Fulldescription:" +tab. Name End IfEnd Sub
PowerDesigner Build the Excel version of the database file