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 ...
随机推荐
- idea用到的快捷键
之前一直用的eclipse,早就听说idea更智能,更便捷,于是,下载了idea,然后再破解,现在就慢慢抛弃eclipse,平时就用idea进行编码. idea的快捷键与eclipse还是有较大不同, ...
- POJ滑雪
滑雪 Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 97172 Accepted: 36843 Description ...
- DotNetCore 部署到IIS 上
将 DotNetCore MVC 项目成功部署到 IIS 上,记录下配置要点: 1.在 ASP.NET Core 应用中使用 Kestrel Microsoft.AspNetCore.App 元包中包 ...
- python 包 笔记
绝对导入和相对导入 我们的最顶级包glance是写给别人用的,然后在glance包内部也会有彼此之间互相导入的需求,这时候就有绝对导入和相对导入两种方式: 绝对导入:以glance作为起始 相对导入: ...
- SonarQube安装文档
1.SonarQube 1.1 SonarQube介绍 SonarQube是管理代码质量一个开放平台,可以快速的定位代码中潜在的或者明显的错误. SonarQube是否可以使用自定义规则由开发人员的开 ...
- 清除本地SVN信息
C:\Documents and Settings\yangxf\Application Data\Subversion\auth 这个目录下删除svn文件夹即可
- windows修改注册表添加开启自启动
快捷键win+R regedit 计算机\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run 新建字符串值 C:\soft ...
- AutoCAD2015有时候会显示乱七八糟的线
问题描述:AutoCAD2015以上版本有时候打开一张图,会出现乱七八糟的线 解决方案: 这是由于硬件加速平滑线显示引起的,可以如下修改
- Python3 tkinter基础 Radiobutton variable 默认选中的按钮
Python : 3.7.0 OS : Ubuntu 18.04.1 LTS IDE : PyCharm 2018.2.4 Conda ...
- 0 vs null
看图说话 0 如图所示: 0 表示有纸(值), 但是纸(值)是0. 所以取纸(值)的时可以取, 但是没法用. null 如图所示: null 表示没有纸(值), 是真的啥都没有, 现在你抽纸的时候会出 ...