power designer 自带VBA脚本语言,在某些情况下编程可实现自动化操作;
1 创建表和列
代码大体如下;
Set mdl = ActiveModel
set table = mdl.Tables.CreateNew
table.Name = "tablename"
table.Code = "table"
for each Tab in folder.tables
dim col
set col =tab.columns.createnew
col.name="columnname"
col.code="columnname"
col.comment="columncomment"
col.datatype="nvarchar2(255)"
next
2 导出到excel
代码大体如下;
Dim ExcelApp, ExcelBook, ExcelSheet
Set ExcelApp = CreateObject("Excel.Application")
ExcelApp.visible=FALSE
Set ExcelBook = ExcelApp.Workbooks.Add
Set ExcelSheet = ExcelBook.Sheets.Add
ExcelSheet.Name = "目录"
'目录标题栏
With ExcelSheet
'内容
.Cells(1,"A").Value = "序号"
.Cells(1,"B").Value = "模式名"
.Cells(1,"C").Value = "表英文名"
.Cells(1,"D").Value = "中文表名"
.Cells(1,"E").Value = "处理标志(Y/N)"
.Cells(1,"F").Value = "备注"
'样式-居中
.Rows(1).HorizontalAlignment = 3 '左右居中 5-填充,左对齐,不会覆盖右边的单元格
.Rows(1).VerticalAlignment = 2 '上下居中
'样式-宽高
.Rows(1).RowHeight = 1/0.035 '高1厘米
.Columns(1).ColumnWidth = 5 '宽,单位:字符
.Columns(2).ColumnWidth = 6
.Columns(3).ColumnWidth = 31
.Columns(4).ColumnWidth = 41
.Columns(5).ColumnWidth = 9
.Columns(6).ColumnWidth = 21
'样式-四周边框
.Range("A1","F1").Borders(1).LineStyle = 1
.Range("A1","F1").Borders(2).LineStyle = 1
.Range("A1","F1").Borders(3).LineStyle = 1
.Range("A1","F1").Borders(4).LineStyle = 1
'样式-其他
.Rows(1).WrapText = True '自动换行
.Range("A1","F1").Interior.Color = D_COLOR_BLUE '背景色-天蓝色
.Range("A1","F1").Font.Size = 10 '字体
.Rows(1).Font.Bold = True '粗体
End With
可查看power designer自带的各种VBA示例;