PowerDesigner脚本使用记录
生活随笔
收集整理的這篇文章主要介紹了
PowerDesigner脚本使用记录
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
文章目錄
- 1.表名、字段由小寫轉大寫
- 2.PDM導出Excel
1.表名、字段由小寫轉大寫
LCase2UCase.vbs
Option Explicit ValidationMode = True InteractiveMode = im_Batch Dim mdl ' 當前模型 ' 獲取當前模型 Set mdl = ActiveModel If (mdl Is Nothing) Then MsgBox "沒有打開一個模型" ElseIf Not mdl.IsKindOf(PdPDM.cls_Model) Then MsgBox "當前模型不是一個PDM" Else '調用處理程序 ProcessFolder mdl End If '調用的處理程序 Private sub ProcessFolder(folder) Dim Tab '要處理的表 for each Tab in folder.Tables ' if not Tab.isShortcut then ' Tab.code = tab.name '表名處理,前邊添加前綴,字母小寫 Tab.name= UCase(Tab.name) Tab.code= UCase(Tab.code) Dim col ' 要處理的列 for each col in Tab.columns '列名稱和code全部小寫,大寫詩UCase col.code= UCase(col.code) col.name= UCase(col.name) next 'end ifnext ' 處理視圖 ' Dim view 'running view ' for each view in folder.Views ' if not view.isShortcut then ' view.code = view.name ' end if' next ' 遞歸進入 sub-packages Dim f ' sub folder For Each f In folder.Packages if not f.IsShortcut then ProcessFolder f end ifNext end sub2.PDM導出Excel
PDB2Excel.vbs
Option ExplicitDim rowsNumrowsNum = 0'-----------------------------------------------------------------------------' Main function'-----------------------------------------------------------------------------' Get the current active modelDim ModelSet Model = ActiveModelIf (Model Is Nothing) Or (Not Model.IsKindOf(PdPDM.cls_Model)) ThenMsgBox "The current model is not an PDM model."Else' Get the tables collection'創建EXCEL APPdim beginrowDIM EXCEL, SHEETset EXCEL = CREATEOBJECT("Excel.Application")EXCEL.workbooks.add(-4167)'添加工作表EXCEL.workbooks(1).sheets(1).name ="test"set sheet = EXCEL.workbooks(1).sheets("test")ShowProperties Model, SHEETEXCEL.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 =truesheet.Columns(2).WrapText =truesheet.Columns(4).WrapText =trueEnd If'-----------------------------------------------------------------------------' Show properties of tables'-----------------------------------------------------------------------------Sub ShowProperties(mdl, sheet)' Show tables of the current model/packagerowsNum=0beginrow = rowsNum+1' For each tableoutput "begin"Dim tabFor Each tab In mdl.tablesShowTable tab,sheetNextif mdl.tables.count > 0 thensheet.Range("A" & beginrow + 1 & ":A" & rowsNum).Rows.Groupend ifoutput "end"End Sub'-----------------------------------------------------------------------------' Show table properties'-----------------------------------------------------------------------------Sub ShowTable(tab, sheet)If IsObject(tab) ThenDim rangFlagrowsNum = rowsNum + 1' Show propertiesOutput "================================"sheet.cells(rowsNum, 1) = "實體名"sheet.cells(rowsNum, 2) =tab.namesheet.cells(rowsNum, 3) = ""sheet.cells(rowsNum, 4) = "表名"sheet.cells(rowsNum, 5) = tab.codesheet.Range(sheet.cells(rowsNum, 5),sheet.cells(rowsNum, 6)).MergerowsNum = rowsNum + 1sheet.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 columnDim colsNumcolsNum = 0for each col in tab.columnsrowsNum = rowsNum + 1colsNum = colsNum + 1sheet.cells(rowsNum, 1) = col.namesheet.cells(rowsNum, 2) = col.commentsheet.cells(rowsNum, 3) = ""sheet.cells(rowsNum, 4) = col.namesheet.cells(rowsNum, 5) = col.codesheet.cells(rowsNum, 6) = col.datatypenextsheet.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.NameEnd IfEnd Sub總結
以上是生活随笔為你收集整理的PowerDesigner脚本使用记录的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: varchar与varchar2的区别
- 下一篇: 跨域问题解决方案--Nginx代理转发