PDM 导出Excel
生活随笔
收集整理的這篇文章主要介紹了
PDM 导出Excel
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
打開 工具 - Execute Commonds - Edit/Run Scripts 。執行如下代碼
'******************************************************************************'* File: pdm2excel.txt'* Title: pdm export to excel'* Purpose: To export the tables and columns to Excel'* Model: Physical Data Model 16.5 , Microsoft Office 2007'* Objects: Table, Column, View'******************************************************************************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?
總結
以上是生活随笔為你收集整理的PDM 导出Excel的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Linux用户管理命令(第二版)
- 下一篇: 运维自动化之使用PHP+MYSQL+SH