powerdesigner 导出excel

PD菜单栏中,依次点击 Tools ->Excute Commands->Edit/Run Script..

填入

‘******************************************************************************

‘* 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 = 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

 set EXCEL = CREATEOBJECT("Excel.Application")

 EXCEL.workbooks.add(-4167)‘添加工作表

 EXCEL.workbooks(1).sheets(1).name ="test"

 set sheet = EXCEL.workbooks(1).sheets("test")

 ShowProperties Model, SHEET

 EXCEL.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 =true

 sheet.Columns(2).WrapText =true

 sheet.Columns(4).WrapText =true

 End If

‘-----------------------------------------------------------------------------

‘ Show properties of tables

‘-----------------------------------------------------------------------------

Sub ShowProperties(mdl, sheet)

   ‘ Show tables of the current model/package

   rowsNum=0

   beginrow = rowsNum+1

   ‘ For each table

   output "begin"

   Dim tab

   For Each tab In mdl.tables

      ShowTable tab,sheet

   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)

   If IsObject(tab) Then

     Dim rangFlag

     rowsNum = rowsNum + 1

      ‘ Show properties

      Output "================================"

      sheet.cells(rowsNum, 1) = "实体名"

      sheet.cells(rowsNum, 2) =tab.name

      sheet.cells(rowsNum, 3) = ""

      sheet.cells(rowsNum, 4) = "表名"

      sheet.cells(rowsNum, 5) = tab.code

      sheet.Range(sheet.cells(rowsNum, 5),sheet.cells(rowsNum, 6)).Merge

      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.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 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, 2) = col.comment

        sheet.cells(rowsNum, 3) = ""

      sheet.cells(rowsNum, 4) = col.name

      sheet.cells(rowsNum, 5) = col.code

      sheet.cells(rowsNum, 6) = col.datatype

      next

      sheet.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 + 1

      Output "FullDescription: "       + tab.Name

   End If

End Sub

PD会自动打开EXCEL,并导出到EXCEL中

时间: 2024-10-12 23:21:55

powerdesigner 导出excel的相关文章

PowerDesigner导出Excel

1.打开PowerDesigner,创建物理模型(Physical Data Model) 2.在PowerDesigner菜单栏中,依次点击“Tools ->Excute Commands->Edit/Run Script..” 3.运行脚本 '****************************************************************************** '* File: pdm2excel.txt '* Title: pdm export to

PowerDesigner——导出成Excel

PowerDesigner导出Excel脚本: '****************************************************************************** '* File: pdm2excel.txt '* Title: pdm export to excel '* Purpose: To export the tables and columns to Excel '* Model: Physical Data Model '* Object

PowerDesigner导出数据表结构到Excel 所有表结构在同一个Sheet中

Option Explicit Dim rowsNum rowsNum = 0 '----------------------------------------------------------------------------- ' Main function '----------------------------------------------------------------------------- ' Get the current active model Dim M

通用导出excel(可控制内容)

实体类 package util; import java.sql.Timestamp; public class Book { private int bookId; private String name; private String author; private float price; private String isbn; private String pubName; private Timestamp date; public Book() { } public Book(i

使用Apache POI导出Excel小结--导出XLS格式文档

使用Apache POI导出Excel小结 关于使用Apache POI导出Excel我大概会分三篇文章去写 使用Apache POI导出Excel小结--导出XLS格式文档 使用Apache POI导出Excel小结--导出XLSX格式文档 使用Apache POI导出Excel--大数量导出 导出XLS格式文档 做企业应用项目难免会有数据导出到Excel的需求,最近在使用其,并对导出Excel封装成工具类开放出来供大家参考.关于Apache POI Excel基本的概念与操作我在这里就不啰嗦

利用poi导出Excel

import java.lang.reflect.Field;import java.lang.reflect.InvocationTargetException;import java.lang.reflect.Method;import java.sql.Date;import java.util.ArrayList;import java.util.List; import org.apache.poi.ss.usermodel.Cell;import org.apache.poi.ss.

goalng导出excel(csv格式)

最近项目中有个小需求,需要将查询结果导出到excel.之间前java比较容易,使用POI很容易就能实现,查了下golang的文档,发现golang下边并没有导出excel的包,但是却有一个encoding/csv的包,看了下发现可以导出csv文件,大家都知道csv文件其实就是文本格式的excel文件,可以直接通过excel打开或是导入excel. 看起来挺好的,问题如愿解决,但是事实证明对已一个还不成熟的语言或是库最好还是先测一下的好.兴冲冲的卸了测试例子,成功导出了一个text.csv文件,一

java 操作 Excel,java导出excel

WritableWorkbook out = null; try { response.getServletResponse().reset(); ((HttpServletResponse) response.getServletResponse()).setHeader("Content-Disposition", "attachment;filename=export.xls"); response.getServletResponse().setConten

导出excel 0kb的问题

运行导出代码,浏览器提示下载框,但是大小为0kb,跟踪代码执行情况,在这一行就结束了wb = new XSSFWorkbook( is );没有异常抛出.(可能是tomcat层面把异常处理了) 总之,找了半天问题,终于发现了,原来是jar包版本不一致造成的.看poi-ooxml-3.8的pom: <dependency> <groupId>org.apache.poi</groupId> <artifactId>poi</artifactId>