首页 > 其他分享 >powerdesigner导出excel

powerdesigner导出excel

时间:2024-11-07 14:42:16浏览次数:3  
标签:SheetList sheet rowsNum excel cells 导出 powerdesigner tab rowsNo

 

'******************************************************************************
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

 

标签:SheetList,sheet,rowsNum,excel,cells,导出,powerdesigner,tab,rowsNo
From: https://www.cnblogs.com/QW-lzm/p/18532230

相关文章

  • 淘宝商家电话采集工具 批量导出淘宝天猫商家联系方式软件 Python使用教程
    淘宝商家电话采集工具批量导出淘宝天猫商家联系方式软件Python使用教程作者V553813195以Python为例,下面是一个简单的教程,来介绍如何使用python语音进行淘宝天猫商家爬虫。首先,我们需要安装以下库:requests,beautifulsoup4。可以使用以下命令进行安装:pipinstallrequestspip......
  • 抖音商家电话采集工具 批量导出抖音小店联系方式软件
    抖音商家电话采集工具批量导出抖音小店联系方式软件作者V553813195抖音电商平台已成为当前电商行业中的热点,众多商家通过抖音平台推广,吸引大量用户注意。在这样的背景下,提取商家电话成为了一项重要的任务。本教程将介绍一个抖音精选联盟商家电话提取工具,通过这个工具可以快速、......
  • VBA(Visual Basic for Applications)宏是用于在Microsoft Office应用程序(如Excel、Word
    在MicrosoftWord中,VBA(VisualBasicforApplications)宏是一种非常强大的自动化工具,它能够帮助你在文档中执行一系列自动化操作,比如格式化、批量修改、数据处理等。下面是如何在MicrosoftWord中设置和使用VBA宏的详细步骤:1.启用开发者选项卡在MicrosoftWord中,默认情......
  • Unity 一键导出exe
    publicstaticvoidSettingPlayer(){RefreshAllScene(true);string[]scenesNamseList=scenesName.Split('\\');string[]sceneNamesList_Right=scenesNamseList[scenesNamseList.Length-1].Split('/');......
  • 在 Windows Server 2025 中,您可以通过 Certutil、PowerShell 和证书管理器工具来进行
    certmgr.msc是Windows操作系统中的一个管理工具,它用于管理和查看证书存储。通过certmgr.msc,用户可以方便地浏览和管理个人证书、受信任的根证书颁发机构(CA)、中间证书颁发机构等不同证书存储区。 1. certmgr.msc 是什么?certmgr.msc是证书管理器(CertificateM......
  • SVN集成ExcelMerge
    在SVN中对比表格差异时,如果只是一个sheet的CSV表格,SVN自带的diff效果也很好,如果是多个Sheet的xlsx表格,,SVN自带的diff效果就很差ExcelMerge是一个在Windows平台下比对Excel的工具,当Excel存在多个Sheet时也能很好的支持差异的比对,配合上svn可以很好的查看策划的数值表变化。具体细......
  • .Net Core NPOI 导出多级表头
     想要导出这样的表格 数据准备格式   附上源码1usingNPOI.HSSF.UserModel;2usingNPOI.SS.UserModel;3usingNPOI.SS.Util;4usingSystem.Data;5usingSystem.Text.RegularExpressions;67namespaceTestConsoleApp8{9//......
  • 7.10 已知一组观测数据,如表中7.17.excel(表中第一列为x的值,第二列为y的值)。试用插值方
    importnumpyasnpimportpandasaspdimportmatplotlib.pyplotaspltfromscipy.interpolateimportinterp1d,PchipInterpolator,CubicSplinefromscipy.optimizeimportcurve_fitfromscipy.statsimportnormfile_path='7.17.xlsx'data=pd.rea......
  • 操作Excel
    EasyExcel导入导出是阿里巴巴开源的一个Excel处理工具,专门用于简化Excel文件的读写操作。1、添加Maven依赖<dependency><groupId>com.alibaba</groupId><artifactId>easyexcel</artifactId><version>3.2.0</version><!--使用最新版本......
  • 中药材快速计算器 可以从Excel导入药品单价信息 佳易网中药复制文本划价管理系统操作
    一、概述【软件试用版文件资源可以点文章最后官网卡片按钮了解】中药材快速计算器可以从Excel导入药品单价信息 ‌核心功能‌:可快速划价计算出总金额,支持多副药方计算,并保存记录。‌操作简便‌:用户只需复制药方文本,点击划价按钮,即可自动计算出金额。可以从Excel表格导入......