PowerDesigner Generating Excel script code
Option Explicit DimRowsnum Rowsnum =0'-----------------------------------------------------------------------------' Main function'-----------------------------------------------------------------------------' Get The current active modelDimModelSetModel = ActivemodelIf(Model is Nothing)Or( notModel.iskindof (Pdpdm.cls_model)) ThenMsgBox"The current model isn't an PDM model."Else ' Get the Tables collection ' Create Excel APP DimBeginrowDIMEXCEL, SHEETSetEXCEL = CreateObject ("Excel.Application") EXCEL.workbooks.add (-4167)' Add worksheetExcel.Workbooks (1). Sheets (1). Name ="Test" SetSheet = excel.workbooks (1). Sheets ("Test") showproperties Model, SHEET excel.visible =true ' Set column widths and wrap linesSheet. Columns (1). ColumnWidth = -Sheet. Columns (2). ColumnWidth = +Sheet. Columns (3). ColumnWidth = -Sheet. Columns (1). WrapText =trueSheet. Columns (2). WrapText =trueSheet. Columns (4). WrapText =true End If'-----------------------------------------------------------------------------' Show properties of tables'-----------------------------------------------------------------------------SubShowProperties (MDL, sheet)' Show tables of the current model/packagerowsnum=0Beginrow = rowsnum+1 ' for each tableOutput"Begin" Dimtab for eachtabinchMdl.tables showtable Tab,sheetNext ifMdl.tables.count >0 ThenSheet. Range ("A"& Beginrow +1&": A"& Rowsnum). Rows.Group End ifOutput"End"End Sub'-----------------------------------------------------------------------------' Show Table Properties'-----------------------------------------------------------------------------SubShowtable (tab, sheet)IfIsObject (tab) Then DimRangflag Rowsnum = Rowsnum +1 ' Show PropertiesOutput"================================"Sheet.cells (Rowsnum,1) ="Table name"Sheet.cells (Rowsnum,2) =tab.name sheet. Range (Sheet.cells (Rowsnum,2), Sheet.cells (Rowsnum,3)). Merge Rowsnum = Rowsnum +1Sheet.cells (Rowsnum,1) ="Property name"Sheet.cells (Rowsnum,2) ="description"Sheet.cells (Rowsnum,3) ="field type" ' Set BorderSheet. Range (Sheet.cells (rowsnum-1,1), Sheet.cells (Rowsnum,3)). Borders.LineStyle ="1"DimCol' running columnDimColsnumcolsnum =0 for eachColinchTab.columns Rowsnum = Rowsnum +1Colsnum = Colsnum +1Sheet.cells (Rowsnum,1) = Col.name Sheet.cells (rowsnum,2) = Col.comment Sheet.cells (rowsnum,3) = Col.datatypeNextSheet. Range (Sheet.cells (rowsnum-colsnum+1,1), Sheet.cells (Rowsnum,3)). Borders.LineStyle ="1"Rowsnum = Rowsnum +1Output"Fulldescription:"+ TAB. NameEnd IfEnd Sub
PowerDesigner Generating Excel