PowerDesigner数据库设计导出到Excel
Option Explicit
Dim rowsNum
rowsNum =
'-----------------------------------------------------------------------------
' Main function
'-----------------------------------------------------------------------------
' Get the current active model
Dim Model
Set Model = ActiveModel
If (Model Is Nothing) Or (Not Model.IsKindOf(PdPDM.cls_Model)) Then
MsgBox "The current model is not an PDM model."
Else
' Get the tables collection
'创建EXCEL APP Dim beginrow
Dim EXCEL, BOOK, SHEET
Set EXCEL = CreateObject("Excel.Application")
EXCEL.Visible = True
Set BOOK = EXCEL.Workbooks.Add(-) '新建工作簿 BOOK.Sheets().Name = "数据库表结构"
Set SHEET = EXCEL.workbooks().sheets("数据库表结构") ShowProperties Model, SHEET
EXCEL.visible = true
'设置列宽和自动换行
SHEET.Columns().ColumnWidth =
SHEET.Columns().ColumnWidth =
SHEET.Columns().ColumnWidth = SHEET.Columns().WrapText =true
SHEET.Columns().WrapText =true
SHEET.Columns().WrapText =true End If '-----------------------------------------------------------------------------
' Show properties of tables
'-----------------------------------------------------------------------------
Sub ShowProperties(mdl, sheet)
' Show tables of the current model/package
rowsNum=
beginrow = rowsNum+
' For each table
output "begin"
Dim tab
For Each tab In mdl.tables
ShowTable tab,sheet
Next
if mdl.tables.count > then
sheet.Range("A" & beginrow + & ":A" & rowsNum).Rows.Group
end if
output "end"
End Sub '-----------------------------------------------------------------------------
' 数据表查询
'-----------------------------------------------------------------------------
Sub ShowTable(tab, sheet)
If IsObject(tab) Then
Dim rangFlag
sheet.cells(, ) = "序号"
sheet.cells(, ) = "表名"
sheet.cells(, ) = "实体名"
'设置边框
sheet.Range(sheet.cells(, ),sheet.cells(, )).Borders.LineStyle = ""
'设置背景颜色
sheet.Range(sheet.cells(, ),sheet.cells(, )).Interior.ColorIndex = "" rowsNum = rowsNum +
sheet.cells(rowsNum+, ) = rowsNum
sheet.cells(rowsNum+, ) = tab.code
sheet.cells(rowsNum+, ) = tab.name
'设置边框
sheet.Range(sheet.cells(rowsNum+,),sheet.cells(rowsNum+,)).Borders.LineStyle = "" '增加Sheet
BOOK.Sheets.Add , BOOK.Sheets(BOOK.Sheets.count)
BOOK.Sheets(rowsNum+).Name = tab.code Dim shtn
Set shtn = EXCEL.workbooks().sheets(tab.code)
'设置列宽和换行
shtn.Columns().ColumnWidth =
shtn.Columns().ColumnWidth =
shtn.Columns().ColumnWidth =
shtn.Columns().ColumnWidth =
shtn.Columns().ColumnWidth = shtn.Columns().WrapText =true
shtn.Columns().WrapText =true
shtn.Columns().WrapText =true
shtn.Columns().WrapText =true
shtn.Columns().WrapText =true '设置列标题
shtn.cells(, ) = "字段中文名"
shtn.cells(, ) = "字段名"
shtn.cells(, ) = "字段类型"
shtn.cells(, ) = tab.code
shtn.cells(, ) = tab.Name
'设置边框
shtn.Range(shtn.cells(, ),shtn.cells(, )).Borders.LineStyle = ""
shtn.Range(shtn.cells(, ),shtn.cells(, )).Borders.LineStyle = ""
'设置背景颜色
shtn.Range(shtn.cells(, ),shtn.cells(, )).Interior.ColorIndex = ""
shtn.Range(shtn.cells(, ),shtn.cells(, )).Interior.ColorIndex = "" Dim col ' running column
Dim colsNum
Dim rNum
colsNum =
rNum =
for each col in tab.columns
rNum = rNum +
colsNum = colsNum + shtn.cells(rNum+, ) = col.name
shtn.cells(rNum+, ) = col.code
shtn.cells(rNum+, ) = col.datatype
next
shtn.Range(shtn.cells(rNum-colsNum+,),shtn.cells(rNum+,)).Borders.LineStyle = ""
rNum = rNum + Output "FullDescription: " + tab.Name End If
End Sub
'******************************************************************************
'* File: pdm2excel.txt
'* Title: pdm export to excel
'* Purpose: To export the tables and columns to Excel
'* Model: Physical Data Model
'* Objects: Table, Column, View
'* Author: ziyan
'* Created: 2012-05-03
'* Version: 1.0
'******************************************************************************
Option Explicit
Dim rowsNum
rowsNum =
'-----------------------------------------------------------------------------
' Main function
'-----------------------------------------------------------------------------
' Get the current active model
Dim Model
Set Model = ActiveModel
If (Model Is Nothing) Or (Not Model.IsKindOf(PdPDM.cls_Model)) Then
MsgBox "The current model is not an PDM model."
Else
' Get the tables collection
'创建EXCEL APP
dim beginrow
DIM EXCEL, SHEET
set EXCEL = CREATEOBJECT("Excel.Application")
EXCEL.workbooks.add(-)'添加工作表
EXCEL.workbooks().sheets().name ="test"
set sheet = EXCEL.workbooks().sheets("test") ShowProperties Model, SHEET
EXCEL.visible = true
'设置列宽和自动换行
sheet.Columns().ColumnWidth =
sheet.Columns().ColumnWidth =
sheet.Columns().ColumnWidth =
sheet.Columns().ColumnWidth =
sheet.Columns().ColumnWidth =
sheet.Columns().WrapText =true
sheet.Columns().WrapText =true
sheet.Columns().WrapText =true
End If
'-----------------------------------------------------------------------------
' Show properties of tables
'-----------------------------------------------------------------------------
Sub ShowProperties(mdl, sheet)
' Show tables of the current model/package
rowsNum=
beginrow = rowsNum+
' For each table
output "begin"
Dim tab
For Each tab In mdl.tables
ShowTable tab,sheet
Next
if mdl.tables.count > then
sheet.Range("A" & beginrow + & ":A" & rowsNum).Rows.Group
end if
output "end"
End Sub
'-----------------------------------------------------------------------------
' Show table properties
'-----------------------------------------------------------------------------
Sub ShowTable(tab, sheet)
If IsObject(tab) Then
Dim rangFlag
rowsNum = rowsNum +
' Show properties
Output "================================"
sheet.cells(rowsNum, ) = "实体名"
sheet.cells(rowsNum, ) =tab.name
sheet.cells(rowsNum, ) = ""
sheet.cells(rowsNum, ) = "表名"
sheet.cells(rowsNum, ) = tab.code
sheet.Range(sheet.cells(rowsNum, ),sheet.cells(rowsNum, )).Merge
rowsNum = rowsNum +
sheet.cells(rowsNum, ) = "属性名"
sheet.cells(rowsNum, ) = "说明"
sheet.cells(rowsNum, ) = ""
sheet.cells(rowsNum, ) = "字段中文名"
sheet.cells(rowsNum, ) = "字段名"
sheet.cells(rowsNum, ) = "字段类型"
'设置边框
sheet.Range(sheet.cells(rowsNum-, ),sheet.cells(rowsNum, )).Borders.LineStyle = ""
sheet.Range(sheet.cells(rowsNum-, ),sheet.cells(rowsNum, )).Borders.LineStyle = ""
Dim col ' running column
Dim colsNum
colsNum =
for each col in tab.columns
rowsNum = rowsNum +
colsNum = colsNum +
sheet.cells(rowsNum, ) = col.name
sheet.cells(rowsNum, ) = col.comment
sheet.cells(rowsNum, ) = ""
sheet.cells(rowsNum, ) = col.name
sheet.cells(rowsNum, ) = col.code
sheet.cells(rowsNum, ) = col.datatype
next
sheet.Range(sheet.cells(rowsNum-colsNum+,),sheet.cells(rowsNum,)).Borders.LineStyle = ""
sheet.Range(sheet.cells(rowsNum-colsNum+,),sheet.cells(rowsNum,)).Borders.LineStyle = ""
rowsNum = rowsNum + Output "FullDescription: " + tab.Name
End If
End Sub
代码二:每个表都会新建一个 Sheet 页,第一个 Sheet 页上是所有表的列表
'******************************************************************************
'* File: pdm2excel.txt
'* Title: pdm export to excel
'* Purpose: To export the tables and columns to Excel
'* Model: Physical Data Model
'* Objects: Table, Column, View
'* Author: Chirs
'* Created: 2015-01-28
'* Version: 1.0
'******************************************************************************
Option Explicit
Dim rowsNum
rowsNum =
'-----------------------------------------------------------------------------
' Main function
'-----------------------------------------------------------------------------
' Get the current active model
Dim Model
Set Model = ActiveModel
If (Model Is Nothing) Or (Not Model.IsKindOf(PdPDM.cls_Model)) Then
MsgBox "The current model is not an PDM model."
Else
' Get the tables collection
'创建EXCEL APP Dim beginrow
Dim EXCEL, BOOK, SHEET
Set EXCEL = CreateObject("Excel.Application")
EXCEL.Visible = True
Set BOOK = EXCEL.Workbooks.Add(-) '新建工作簿 BOOK.Sheets().Name = "数据库表结构"
Set SHEET = EXCEL.workbooks().sheets("数据库表结构") ShowProperties Model, SHEET
EXCEL.visible = true
'设置列宽和自动换行
SHEET.Columns().ColumnWidth =
SHEET.Columns().ColumnWidth =
SHEET.Columns().ColumnWidth = SHEET.Columns().WrapText =true
SHEET.Columns().WrapText =true
SHEET.Columns().WrapText =true End If '-----------------------------------------------------------------------------
' Show properties of tables
'-----------------------------------------------------------------------------
Sub ShowProperties(mdl, sheet)
' Show tables of the current model/package
rowsNum=
beginrow = rowsNum+
' For each table
output "begin"
Dim tab
For Each tab In mdl.tables
ShowTable tab,sheet
Next
if mdl.tables.count > then
sheet.Range("A" & beginrow + & ":A" & rowsNum).Rows.Group
end if
output "end"
End Sub '-----------------------------------------------------------------------------
' 数据表查询
'-----------------------------------------------------------------------------
Sub ShowTable(tab, sheet)
If IsObject(tab) Then
Dim rangFlag
sheet.cells(, ) = "序号"
sheet.cells(, ) = "表名"
sheet.cells(, ) = "实体名"
'设置边框
sheet.Range(sheet.cells(, ),sheet.cells(, )).Borders.LineStyle = ""
'设置背景颜色
sheet.Range(sheet.cells(, ),sheet.cells(, )).Interior.ColorIndex = "" rowsNum = rowsNum +
sheet.cells(rowsNum+, ) = rowsNum
sheet.cells(rowsNum+, ) = tab.code
sheet.cells(rowsNum+, ) = tab.name
'设置边框
sheet.Range(sheet.cells(rowsNum+,),sheet.cells(rowsNum+,)).Borders.LineStyle = "" '增加Sheet
BOOK.Sheets.Add , BOOK.Sheets(BOOK.Sheets.count)
BOOK.Sheets(rowsNum+).Name = tab.code Dim shtn
Set shtn = EXCEL.workbooks().sheets(tab.code)
'设置列宽和换行
shtn.Columns().ColumnWidth =
shtn.Columns().ColumnWidth =
shtn.Columns().ColumnWidth =
shtn.Columns().ColumnWidth =
shtn.Columns().ColumnWidth = shtn.Columns().WrapText =true
shtn.Columns().WrapText =true
shtn.Columns().WrapText =true
shtn.Columns().WrapText =true
shtn.Columns().WrapText =true '设置列标题
shtn.cells(, ) = "字段中文名"
shtn.cells(, ) = "字段名"
shtn.cells(, ) = "字段类型"
shtn.cells(, ) = tab.code
shtn.cells(, ) = tab.Name
'设置边框
shtn.Range(shtn.cells(, ),shtn.cells(, )).Borders.LineStyle = ""
shtn.Range(shtn.cells(, ),shtn.cells(, )).Borders.LineStyle = ""
'设置背景颜色
shtn.Range(shtn.cells(, ),shtn.cells(, )).Interior.ColorIndex = ""
shtn.Range(shtn.cells(, ),shtn.cells(, )).Interior.ColorIndex = "" Dim col ' running column
Dim colsNum
Dim rNum
colsNum =
rNum =
for each col in tab.columns
rNum = rNum +
colsNum = colsNum + shtn.cells(rNum+, ) = col.name
shtn.cells(rNum+, ) = col.code
shtn.cells(rNum+, ) = col.datatype
next
shtn.Range(shtn.cells(rNum-colsNum+,),shtn.cells(rNum+,)).Borders.LineStyle = ""
rNum = rNum + Output "FullDescription: " + tab.Name End If
End Sub
代码三:都在一页样式好看
'******************************************************************************
Option Explicit
Dim rowsNum
rowsNum =
'-----------------------------------------------------------------------------
' Main function
'-----------------------------------------------------------------------------
' Get the current active model
Dim Model
Set Model = ActiveModel
If (Model Is Nothing) Or (Not Model.IsKindOf(PdPDM.cls_Model)) Then
MsgBox "The current model is not an PDM model."
Else
' Get the tables collection
'创建EXCEL APP
dim beginrow
DIM EXCEL, SHEET, SHEETLIST
set EXCEL = CREATEOBJECT("Excel.Application")
EXCEL.workbooks.add(-)'添加工作表
EXCEL.workbooks().sheets().name ="表结构"
set SHEET = EXCEL.workbooks().sheets("表结构") EXCEL.workbooks().sheets.add
EXCEL.workbooks().sheets().name ="目录"
set SHEETLIST = EXCEL.workbooks().sheets("目录")
ShowTableList Model,SHEETLIST ShowProperties Model, SHEET,SHEETLIST EXCEL.workbooks().Sheets().Select
EXCEL.visible = true
'设置列宽和自动换行
sheet.Columns().ColumnWidth =
sheet.Columns().ColumnWidth =
sheet.Columns().ColumnWidth =
sheet.Columns().ColumnWidth =
sheet.Columns().ColumnWidth =
sheet.Columns().ColumnWidth =
sheet.Columns().WrapText =true
sheet.Columns().WrapText =true
sheet.Columns().WrapText =true
'不显示网格线
EXCEL.ActiveWindow.DisplayGridlines = False End If
'-----------------------------------------------------------------------------
' Show properties of tables
'-----------------------------------------------------------------------------
Sub ShowProperties(mdl, sheet,SheetList)
' Show tables of the current model/package
rowsNum=
beginrow = rowsNum+
Dim rowIndex
rowIndex=
' For each table
output "begin"
Dim tab
For Each tab In mdl.tables
ShowTable tab,sheet,rowIndex,sheetList
rowIndex = rowIndex +
Next
if mdl.tables.count > then
sheet.Range("A" & beginrow + & ":A" & rowsNum).Rows.Group
end if
output "end"
End Sub
'-----------------------------------------------------------------------------
' Show table properties
'-----------------------------------------------------------------------------
Sub ShowTable(tab, sheet,rowIndex,sheetList)
If IsObject(tab) Then
Dim rangFlag
rowsNum = rowsNum +
' Show properties
Output "================================"
sheet.cells(rowsNum, ) =tab.name
sheet.cells(rowsNum, ).HorizontalAlignment=
sheet.cells(rowsNum, ) = tab.code
'sheet.cells(rowsNum, 5).HorizontalAlignment=3
'sheet.cells(rowsNum, 6) = ""
'sheet.cells(rowsNum, 7) = "表说明"
sheet.cells(rowsNum, ) = tab.comment
'sheet.cells(rowsNum, 8).HorizontalAlignment=3
sheet.Range(sheet.cells(rowsNum, ),sheet.cells(rowsNum, )).Merge
'设置超链接,从目录点击表名去查看表结构
'字段中文名 字段英文名 字段类型 注释 是否主键 是否非空 默认值
sheetList.Hyperlinks.Add sheetList.cells(rowIndex,), "","表结构"&"!B"&rowsNum
rowsNum = rowsNum +
sheet.cells(rowsNum, ) = "字段中文名"
sheet.cells(rowsNum, ) = "字段英文名"
sheet.cells(rowsNum, ) = "字段类型"
sheet.cells(rowsNum, ) = "注释"
sheet.cells(rowsNum, ) = "是否主键"
sheet.cells(rowsNum, ) = "是否非空"
sheet.cells(rowsNum, ) = "默认值"
'设置边框
sheet.Range(sheet.cells(rowsNum-, ),sheet.cells(rowsNum, )).Borders.LineStyle = ""
'sheet.Range(sheet.cells(rowsNum-1, 4),sheet.cells(rowsNum, 9)).Borders.LineStyle = "1"
'字体为10号
sheet.Range(sheet.cells(rowsNum-, ),sheet.cells(rowsNum, )).Font.Size=
Dim col ' running column
Dim colsNum
colsNum =
for each col in tab.columns
rowsNum = rowsNum +
colsNum = colsNum +
sheet.cells(rowsNum, ) = col.name
'sheet.cells(rowsNum, 3) = ""
'sheet.cells(rowsNum, 4) = col.name
sheet.cells(rowsNum, ) = col.code
sheet.cells(rowsNum, ) = col.datatype
sheet.cells(rowsNum, ) = col.comment
If col.Primary = true Then
sheet.cells(rowsNum, ) = "Y"
Else
sheet.cells(rowsNum, ) = " "
End If
If col.Mandatory = true Then
sheet.cells(rowsNum, ) = "Y"
Else
sheet.cells(rowsNum, ) = " "
End If
sheet.cells(rowsNum, ) = col.defaultvalue
next
sheet.Range(sheet.cells(rowsNum-colsNum+,),sheet.cells(rowsNum,)).Borders.LineStyle = ""
'sheet.Range(sheet.cells(rowsNum-colsNum+1,4),sheet.cells(rowsNum,9)).Borders.LineStyle = "3"
sheet.Range(sheet.cells(rowsNum-colsNum+,),sheet.cells(rowsNum,)).Font.Size =
rowsNum = rowsNum + Output "FullDescription: " + tab.Name
End If End Sub
'-----------------------------------------------------------------------------
' Show List Of Table
'-----------------------------------------------------------------------------
Sub ShowTableList(mdl, SheetList)
' Show tables of the current model/package
Dim rowsNo
rowsNo=
' For each table
output "begin"
SheetList.cells(rowsNo, ) = "主题"
SheetList.cells(rowsNo, ) = "表中文名"
SheetList.cells(rowsNo, ) = "表英文名"
SheetList.cells(rowsNo, ) = "表说明"
rowsNo = rowsNo +
SheetList.cells(rowsNo, ) = mdl.name
Dim tab
For Each tab In mdl.tables
If IsObject(tab) Then
rowsNo = rowsNo +
SheetList.cells(rowsNo, ) = ""
SheetList.cells(rowsNo, ) = tab.name
SheetList.cells(rowsNo, ) = tab.code
SheetList.cells(rowsNo, ) = tab.comment
End If
Next
SheetList.Columns().ColumnWidth =
SheetList.Columns().ColumnWidth =
SheetList.Columns().ColumnWidth =
SheetList.Columns().ColumnWidth =
output "end"
End Sub
目录页可以跳转
'******************************************************************************
'* File: Exported_Excel_page.vbs
'* Purpose: 分目录递归,查找当前PDM下所有表,并导出Excel
'* Title:
'* Category:
'* Version: 1.0
'* Author: 787681084@qq.com
'****************************************************************************** Option Explicit
ValidationMode = True
InteractiveMode = im_Batch '-----------------------------------------------------------------------------
' 主函数
'-----------------------------------------------------------------------------
' 获取当前活动模型
Dim mdl ' 当前的模型
Set mdl = ActiveModel
Dim EXCEL,catalog,sheet,catalogNum,rowsNum,linkNum
rowsNum =
catalogNum =
linkNum = If (mdl Is Nothing) Then
MsgBox "There is no Active Model"
Else
SetCatalog
ListObjects(mdl)
End If '----------------------------------------------------------------------------------------------
' 子过程,用于扫描当前包并从当前包中打印对象的信息,然后对当前包的所有子包再次调用相同的子过程
'----------------------------------------------------------------------------------------------
Private Sub ListObjects(fldr)
output "Scanning " & fldr.code
Dim obj ' 运行对象
For Each obj In fldr.children
' 调用子过程来打印对象上的信息
DescribeObject obj
Next
' 进入子包
Dim f ' 运行文件夹
For Each f In fldr.Packages
'调用子程序扫描子程序包
ListObjects f
Next
End Sub '-----------------------------------------------------------------------------
' 子过程,用于在输出中打印当前对象的信息
'-----------------------------------------------------------------------------
Private Sub DescribeObject(CurrentObject)
if not CurrentObject.Iskindof(cls_NamedObject) then exit sub
if CurrentObject.Iskindof(cls_Table) then
AddSheet CurrentObject.code
ExportTable CurrentObject, sheet
ExportCatalog CurrentObject
else
output "Found "+CurrentObject.ClassName+" """+CurrentObject.Name+""", Created by "+CurrentObject.Creator+" On "+Cstr(CurrentObject.CreationDate)
End if
End Sub '----------------------------------------------------------------------------------------------
' 设置Excel的sheet页
'----------------------------------------------------------------------------------------------
Sub SetExcel()
Set EXCEL= CreateObject("Excel.Application") ' 使Excel通过应用程序对象可见。
EXCEL.Visible = True
EXCEL.workbooks.add(-)'添加工作表
EXCEL.workbooks().sheets().name ="pdm"
set sheet = EXCEL.workbooks().sheets("pdm") ' 将一些文本放在工作表的第一行
sheet.Cells(rowsNum, ).Value = "表名"
sheet.Cells(rowsNum, ).Value = "表中文名"
sheet.Cells(rowsNum, ).Value = "表备注"
sheet.Cells(rowsNum, ).Value = "字段ID"
sheet.Cells(rowsNum, ).Value = "字段名"
sheet.Cells(rowsNum, ).Value = "字段中文名"
sheet.Cells(rowsNum, ).Value = "字段类型"
sheet.Cells(rowsNum, ).Value = "字段备注"
sheet.cells(rowsNum, ).Value = "主键"
sheet.cells(rowsNum, ).Value = "非空"
sheet.cells(rowsNum, ).Value = "默认值"
End Sub '----------------------------------------------------------------------------------------------
' 导出目录结构
'----------------------------------------------------------------------------------------------
Sub ExportCatalog(tab)
catalogNum = catalogNum +
catalog.cells(catalogNum, ).Value = tab.parent.name
catalog.cells(catalogNum, ).Value = tab.code
catalog.cells(catalogNum, ).Value = tab.comment
'设置超链接
catalog.Hyperlinks.Add catalog.cells(catalogNum,), "",tab.code&"!A2"
End Sub '----------------------------------------------------------------------------------------------
' 导出sheet页
'----------------------------------------------------------------------------------------------
Sub ExportTable(tab, sheet)
Dim col ' 运行列
Dim colsNum
colsNum =
for each col in tab.columns
colsNum = colsNum +
rowsNum = rowsNum +
sheet.Cells(rowsNum, ).Value = tab.code
'sheet.Cells(rowsNum, 2).Value = tab.name
sheet.Cells(rowsNum, ).Value = tab.comment
'sheet.Cells(rowsNum, 4).Value = colsNum
sheet.Cells(rowsNum, ).Value = col.code
'sheet.Cells(rowsNum, 4).Value = col.name
sheet.Cells(rowsNum, ).Value = col.datatype
sheet.Cells(rowsNum, ).Value = col.comment If col.Primary = true Then
sheet.cells(rowsNum, ) = "Y"
Else
sheet.cells(rowsNum, ) = ""
End If
If col.Mandatory = true Then
sheet.cells(rowsNum, ) = "Y"
Else
sheet.cells(rowsNum, ) = ""
End If sheet.cells(rowsNum, ).Value = col.defaultvalue
'设置居中显示
sheet.cells(rowsNum,).HorizontalAlignment =
sheet.cells(rowsNum,).HorizontalAlignment =
next
output "Exported table: "+ +tab.Code+"("+tab.Name+")"
End Sub '----------------------------------------------------------------------------------------------
' 设置Excel目录页
'----------------------------------------------------------------------------------------------
Sub SetCatalog()
Set EXCEL= CreateObject("Excel.Application") ' 使Excel通过应用程序对象可见。
EXCEL.Visible = True
EXCEL.workbooks.add(-)'添加工作表
EXCEL.workbooks().sheets().name ="表结构"
EXCEL.workbooks().sheets.add
EXCEL.workbooks().sheets().name ="目录"
set catalog = EXCEL.workbooks().sheets("目录") catalog.cells(catalogNum, ) = "模块"
catalog.cells(catalogNum, ) = "表名"
catalog.cells(catalogNum, ) = "表注释" ' 设置列宽和自动换行
catalog.Columns().ColumnWidth =
catalog.Columns().ColumnWidth =
catalog.Columns().ColumnWidth = '设置首行居中显示 catalog.Range(catalog.cells(,),catalog.cells(,)).HorizontalAlignment =
'设置首行字体加粗
catalog.Range(catalog.cells(,),catalog.cells(,)).Font.Bold = True
End Sub '----------------------------------------------------------------------------------------------
' 新增sheet页
'----------------------------------------------------------------------------------------------
Sub AddSheet(sheetName)
EXCEL.workbooks().Sheets().Select
EXCEL.workbooks().sheets.add
EXCEL.workbooks().sheets().name = sheetName
set sheet = EXCEL.workbooks().sheets(sheetName)
rowsNum =
'将一些文本放在工作表的第一行
sheet.Cells(rowsNum, ).Value = "表名"
'sheet.Cells(rowsNum, 2).Value = "表中文名"
sheet.Cells(rowsNum, ).Value = "表备注"
'sheet.Cells(rowsNum, 4).Value = "字段ID"
sheet.Cells(rowsNum, ).Value = "字段名"
'sheet.Cells(rowsNum, 4).Value = "字段中文名"
sheet.Cells(rowsNum, ).Value = "字段类型"
sheet.Cells(rowsNum, ).Value = "字段备注"
sheet.cells(rowsNum, ).Value = "主键"
sheet.cells(rowsNum, ).Value = "非空"
sheet.cells(rowsNum, ).Value = "默认值" '设置列宽
sheet.Columns().ColumnWidth =
sheet.Columns().ColumnWidth =
sheet.Columns().ColumnWidth =
sheet.Columns().ColumnWidth =
sheet.Columns().ColumnWidth =
sheet.Columns().ColumnWidth =
sheet.Columns().ColumnWidth =
sheet.Columns().ColumnWidth = '设置首行居中显示
sheet.Range(sheet.cells(,),sheet.cells(,)).HorizontalAlignment =
'设置首行字体加粗
sheet.Range(sheet.cells(,),sheet.cells(,)).Font.Bold = True linkNum = linkNum +
'设置超链接
sheet.Hyperlinks.Add sheet.cells(,), "","目录"&"!B"&linkNum
End Sub
PowerDesigner数据库设计导出到Excel的更多相关文章
- PowerDesigner数据库设计PDM基于Excel的导入导出总结
经常用到pdm来管理代码,一两张表,手写一下还凑合,一旦表多了,就慌了.于是,开始学习用vbs进行Excel的来快速导入导出操作PDM就变得很紧急了,搜罗了网络上的很多vbs脚本,各有各的优点,但对于 ...
- Python实现数据库一键导出为Excel表格
依赖 Python2711 xlwt MySQLdb 数据库相关 连接 获取字段信息 获取数据 Excel基础 workbook sheet 案例 封装 封装之后 测试结果 总结 数据库数据导出为ex ...
- PowerDesigner ---- 数据库设计(物理模型CDM和概念模型PDM)
前言 上一篇介绍了个PowerDesigner工具的安装和汉化,现在我就说一下怎么用这个PowerDesigner建数据库吧. 内容 第一种方法:概念模型转物理模型 1.首先新建模型--选择概念模 ...
- Java利用Apache POI将数据库数据导出为excel
将数据库中的数据导出为excel文件,供其他人查看 public class POITest { public static void main(String[] args) { POITest te ...
- Java:将数据库数据导出到Excel (一眼就看会)
所用Jar包 1. sqljdbc4.jar 连接数据库的Jar包(根据数据库的不同进行选择,我用的SqlServer2008) 2.Jxl.jar 访问Excel的Jar包 注意:支持以.xls结尾 ...
- Java实现将Excel导入数据库和从数据库中导出为Excel
实现的功能: 用Java实现从Excel导入数据库,如果存在就更新 将数据库中的数据导出为Excel 1.添加jxl.jar mysql-connector-java.1.7-bin.jar包到项目的 ...
- PCB MS SERVER 使用bcp命令将数据库数据导出到Excel
在前年工程系统与APS系统对接时,需将工程系统数据导出来给APS,采用的正是bcp命令实现,速度超快. 这里将此命令使用方法整理如下: 一.写SQL将表数据导出到Excel @echo "& ...
- PowerDesigner数据库设计实用技巧
欢迎大家补充,谢谢! 1. 原始单据与实体之间的关系 可以是一对一.一对多.多对多的关系.在一般情况下,它们是一对一的关系:即一张原始单据对应且只对应一个实体.在特殊情况下,它们可能是一对多或多对一的 ...
- mysql数据库表格导出为excel表格
在本地数据库中操作如下: 由于excel表格的编码是GBK,所以导出时要加一个设置字符编码: select * from 某个表 into outfile 'd:/文件名.xls' CHARACTER ...
随机推荐
- 一个spinner控件使用的实例
布局文件 <?xml version="1.0" encoding="utf-8"?><android.support.constraint. ...
- 解决SVN提交和更新代码冲突?
解决冲突有三种选择: 1.放弃自己的更新,使用svn revert(回滚),然后提交.在这种方式下不需要使用svn resolved(解决) 2.放弃自己的更新,使用别人的更新.使用最新获取的版本覆盖 ...
- AbstractMethodError:
AbstractMethodError: This java.lang.AbstractMethodError is usually thrown when we try to invoke the ...
- 使用Python的库qrcode生成二维码
现在有很多二维码的生成工具,在线的,或者安装的软件,都可以进行生成二维码.今天我用Python的qrcode库生成二维码.需要预先安装 Image 库 安装 用pip安装 # pip install ...
- connect设置连接超时
转自:庖丁解牛 /** * connect_timeout - 带超时的connect(方法中已执行connect) * @fd:文件描述符 * @addr:地址结构体指针 * @wait_secon ...
- Flutter 数据存储 加权限 sharedpreference, sqflite, file
要访问SD卡,首先读取权限肯定是要有的,不然写再多代码都是无用功.在AndroidManifest.xml文件中添加 <uses-permission android:name="an ...
- 常用的tcpdump操作
tcpdump -i eth0 icmp and host 192.168.0.111 -nn -tttt 用ping检测网络情况时抓包,-nn 显示ip和端口而不是机器名和进程名,-tttt 显示详 ...
- CSc 352 (Spring 2019): Assignment
CSc 352 (Spring 2019): Assignment 11Due Date: 11:59PM Wed, May 1The purpose of this assignment is to ...
- 浅谈Tarjan算法
从这里开始 预备知识 两个数组 Tarjan 算法的应用 求割点和割边 求点-双连通分量 求边-双连通分量 求强连通分量 预备知识 设无向图$G_{0} = (V_{0}, E_{0})$,其中$V_ ...
- uirecorder 启动webdriver服务报错
在安装好uirecorder后,执行起来是各种错误. 不是少这个就是缺那个,也是因为自己对自动化测试知识太匮乏. 导致刚开始走自动化测试绕了很多弯路,报个错都不知所措.后来才知道要多看ERROR后面的 ...