PowerDesigner 表格导出为excel

选中tables
ctrl + shift +x 然后运行脚本

‘******************************************************************************
Option Explicit
   Dim rowsNum
   rowsNum = 0
‘-----------------------------------------------------------------------------
‘ 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(-4167)‘添加工作表
      EXCEL.workbooks(1).sheets(1).name ="表结构"
      set SHEET = EXCEL.workbooks(1).sheets("表结构")

      EXCEL.workbooks(1).sheets.add
      EXCEL.workbooks(1).sheets(1).name ="目录"
      set SHEETLIST = EXCEL.workbooks(1).sheets("目录")
      ShowTableList Model,SHEETLIST

      ShowProperties Model, SHEET,SHEETLIST

      EXCEL.workbooks(1).Sheets(2).Select
      EXCEL.visible = true
      ‘设置列宽和自动换行
      sheet.Columns(1).ColumnWidth = 20
      sheet.Columns(2).ColumnWidth = 20
      sheet.Columns(3).ColumnWidth = 20
      sheet.Columns(4).ColumnWidth = 40
      sheet.Columns(5).ColumnWidth = 10
      sheet.Columns(6).ColumnWidth = 10
      sheet.Columns(1).WrapText =true
      sheet.Columns(2).WrapText =true
      sheet.Columns(4).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=0
   beginrow = rowsNum+1
   Dim rowIndex
   rowIndex=3
   ‘ For each table
   output "begin"
   Dim tab
   For Each tab In mdl.tables
      ShowTable tab,sheet,rowIndex,sheetList
      rowIndex = rowIndex +1
   Next
   if mdl.tables.count > 0 then
        sheet.Range("A" & beginrow + 1 & ":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 + 1
      ‘ Show properties
      Output "================================"
      sheet.cells(rowsNum, 1) =tab.name
      sheet.cells(rowsNum, 1).HorizontalAlignment=3
      sheet.cells(rowsNum, 2) = tab.code
      ‘sheet.cells(rowsNum, 5).HorizontalAlignment=3
      ‘sheet.cells(rowsNum, 6) = ""
      ‘sheet.cells(rowsNum, 7) = "表说明"
      sheet.cells(rowsNum, 3) = tab.comment
      ‘sheet.cells(rowsNum, 8).HorizontalAlignment=3
      sheet.Range(sheet.cells(rowsNum, 3),sheet.cells(rowsNum, 7)).Merge
      ‘设置超链接,从目录点击表名去查看表结构
      ‘字段中文名    字段英文名    字段类型    注释    是否主键    是否非空    默认值
      sheetList.Hyperlinks.Add sheetList.cells(rowIndex,2), "","表结构"&"!B"&rowsNum
      rowsNum = rowsNum + 1
      sheet.cells(rowsNum, 1) = "字段中文名"
      sheet.cells(rowsNum, 2) = "字段英文名"
      sheet.cells(rowsNum, 3) = "字段类型"
      sheet.cells(rowsNum, 4) = "注释"
      sheet.cells(rowsNum, 5) = "是否主键"
      sheet.cells(rowsNum, 6) = "是否非空"
      sheet.cells(rowsNum, 7) = "默认值"
      ‘设置边框
      sheet.Range(sheet.cells(rowsNum-1, 1),sheet.cells(rowsNum, 7)).Borders.LineStyle = "1"
      ‘sheet.Range(sheet.cells(rowsNum-1, 4),sheet.cells(rowsNum, 9)).Borders.LineStyle = "1"
      ‘字体为10号
      sheet.Range(sheet.cells(rowsNum-1, 1),sheet.cells(rowsNum, 7)).Font.Size=10
            Dim col ‘ running column
            Dim colsNum
            colsNum = 0
      for each col in tab.columns
        rowsNum = rowsNum + 1
        colsNum = colsNum + 1
          sheet.cells(rowsNum, 1) = col.name
        ‘sheet.cells(rowsNum, 3) = ""
          ‘sheet.cells(rowsNum, 4) = col.name
          sheet.cells(rowsNum, 2) = col.code
          sheet.cells(rowsNum, 3) = col.datatype
        sheet.cells(rowsNum, 4) = col.comment
          If col.Primary = true Then
        sheet.cells(rowsNum, 5) = "Y"
        Else
        sheet.cells(rowsNum, 5) = " "
        End If
        If col.Mandatory = true Then
        sheet.cells(rowsNum, 6) = "Y"
        Else
        sheet.cells(rowsNum, 6) = " "
        End If
        sheet.cells(rowsNum, 7) =  col.defaultvalue
      next
      sheet.Range(sheet.cells(rowsNum-colsNum+1,1),sheet.cells(rowsNum,7)).Borders.LineStyle = "3"
      ‘sheet.Range(sheet.cells(rowsNum-colsNum+1,4),sheet.cells(rowsNum,9)).Borders.LineStyle = "3"
      sheet.Range(sheet.cells(rowsNum-colsNum+1,1),sheet.cells(rowsNum,7)).Font.Size = 10
      rowsNum = rowsNum + 2

      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=1
   ‘ For each table
   output "begin"
   SheetList.cells(rowsNo, 1) = "主题"
   SheetList.cells(rowsNo, 2) = "表中文名"
   SheetList.cells(rowsNo, 3) = "表英文名"
   SheetList.cells(rowsNo, 4) = "表说明"
   rowsNo = rowsNo + 1
   SheetList.cells(rowsNo, 1) = mdl.name
   Dim tab
   For Each tab In mdl.tables
     If IsObject(tab) Then
         rowsNo = rowsNo + 1
      SheetList.cells(rowsNo, 1) = ""
      SheetList.cells(rowsNo, 2) = tab.name
      SheetList.cells(rowsNo, 3) = tab.code
      SheetList.cells(rowsNo, 4) = tab.comment
     End If
   Next
    SheetList.Columns(1).ColumnWidth = 20
      SheetList.Columns(2).ColumnWidth = 20
      SheetList.Columns(3).ColumnWidth = 30
     SheetList.Columns(4).ColumnWidth = 60
   output "end"
End Sub
时间: 2025-02-01 01:40:12

PowerDesigner 表格导出为excel的相关文章

数据库表结构转成设计书,PowerDesigner 表格导出为excel

数据库中的表导入到PowerDesigner中并转为excel文档 1.打开PowerDesigner12,在菜单中按照如下方式进行操作 file->Reverse Engineer->DataBase 点击后,弹出 New Physical Data Model 的对话框 2.在General选项卡中 Model name:模板名字,自己命名. DMBMS    :根据需要选择,我选择的是ORACLEVersion 10g 点确定后弹出 Database Reverse Engineerin

将HTML表格导出到EXCEL,兼容Firefox,支持中文

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <head> <meta http-equiv="Content

MVC把表格导出到Excel

有关Model: namespace MvcApplication1.Models { public class Coach { public int Id { get; set; } public string Name { get; set; } } } HomeController中,借助GridView控件把内容导出到Excel: using System.Collections.Generic; using System.IO; using System.Linq; using Sys

html页面表格导出到excel

几种把html页面表格导出到excel的方法比较. 表格例子如下: <table id="tableExcel" width="100%" border="1" cellspacing="0" cellpadding="0"> <tr> <td colspan="5" align="center">html 表格导出道Exceltd

JS 将页面上的表格导出为 Excel 文件

如果在页面上展示了一个表格,想把这个表格导出为Excel文件,那么在要求不高的情况下,可以直接利用 JavaScript 的 Blob 和 Object URL 特性将表格导出.不过,这就是利用了 Excel 能打开 HTML 文档的特性,所以导出的表格实际上是一个 HTML 文档,并且其扩展名只能为 .xls,而不能是 .xlsx,否则Excel无法打开.(有使用JavaScript生成真正Excel文件的方案,以后再研究.) 实例: <!DOCTYPE html> <html>

html页面表格导出到excel总结

转载:http://www.cnblogs.com/liuguanghai/archive/2012/12/31/2840262.html <table id="tableExcel" width="100%" border="1" cellspacing="0" cellpadding="0"> <tr> <td colspan="5" align=&qu

将表格导出为excel

1 <table id="tableExcel" border="1"> 2 <tr> 3 <th>零</th> 4 <th>一</th> 5 <th>二</th> 6 <th>三</th> 7 <th>四</th> 8 </tr> 9 <tr> 10 <td>万籁寂无声</td&g

mysql数据库表格导出为excel表格

在本地数据库中操作如下: 由于excel表格的编码是GBK,所以导出时要加一个设置字符编码: select * from 某个表 into outfile 'd:/文件名.xls' CHARACTER SET gbk;

ssh+jxl将表格导出为Excel

首先准备jxl.jar. 然后让我们了解了解这个jxl,Excel本来就有工作簿.工作表.单元格等属性,所以我们从数据库导出表格也必须先有工作簿(workbook).工作表(sheet).单元格(label).实现导出表格也是从三个入手. 首先创建一个writeworkbook对象 Writableworkbook  book=Workbook.createWorkbook(new File(path)): 然后创建工作表sheet对象 WritableSheet sheet=book.crea