打开powerdesigner,shift + ctrl + X 打开脚本窗口
输入执行的脚本,点 run 即可。
简单的导入Excel脚本

'开始
Option Explicit
Dim mdl ' the current model
Set mdl = ActiveModel
MsgBox "当前活动的CDM名称是"+mdl, vbOK + vbInformation, "表"
If (mdl Is Nothing) Then
   MsgBox "There is no Active Model"
End If
Dim HaveExcel
Dim RQ
RQ = vbYes 'MsgBox("Is Excel Installed on your machine ?", vbYesNo + vbInformation, "Confirmation")
If RQ = vbYes Then
   HaveExcel = True
   ' Open & Create Excel Document
   Dim x1  '
   Set x1 = CreateObject("Excel.Application")
   x1.Workbooks.Open "E:\工作文档\新系统数据字典\系统数据字典-\1.33 Surface 面签表.xlsx"   '指定excel文档路径
   x1.Workbooks(1).Worksheets("Sheet1").Activate   '指定要打开的sheet名称
Else
   HaveExcel = False
End If
a x1, mdl
sub a(x1, mdl)
dim rwIndex   
dim tableName
dim colname
dim table
dim col
dim count
'on error Resume Next
'set table = mdl.Tables.CreateNew '创建一个表实体
'tableName= .Cells(1, 1).Value   '"customer"                      '.Cells(1,1).Value
'table.Name = .Cells(1, 1).Value   '指定表名,如果在Excel文档里有,也可以 .Cells(rwIndex, 3).Value 这样指定
'table.Code = .Cells(1, 2).Value  '指定表名

For rwIndex = 1 To 1000   '指定要遍历的Excel行标  由于第1行是表头,从第2行开始
        With x1.Workbooks(1).Worksheets("Sheet1")
            If .Cells(rwIndex, 1).Value = "" Then
               Exit For
            End If
            if rwIndex=1 Then
              set table = mdl.tables.CreateNew() '创建一个表实体
              tableName= .Cells(rwIndex, 1).Value   '"customer"                      '.Cells(1,1).Value
              table.Name = tableName   '指定表名,如果在Excel文档里有,也可以 .Cells(rwIndex, 3).Value 这样指定
              table.comment= .Cells(rwIndex, 1).Value '给的给表添加备注
              table.Code = .Cells(rwIndex, 2).Value  '指定表名   
              MsgBox "获取表格中的表名"+table.Name  + CStr(count), vbOK + vbInformation, "表"
            else if rwIndex=2 Then
                else
               'MsgBox .Cells(rwIndex, 1).Value, vbOK + vbInformation, "列"
              ' If .Cells(rwIndex, 3).Value = "" Then
                '  col.Name = .Cells(rwIndex, 1).Value   '指定列名
              ' Else 
               '   col.Name = .Cells(rwIndex, 3).Value
              ' End If
               'MsgBox col.Name, vbOK + vbInformation, "列"
               set col = table.columns.CreateNew   '创建一列/字段
               col.Code = .Cells(rwIndex, 1).Value   '指定列名
               colName = .Cells(rwIndex, 1).Value
               col.Name = .Cells(rwIndex, 1).Value 
               col.DataType = .Cells(rwIndex, 2).Value   '指定列数据类型
               col.Comment = .Cells(rwIndex, 5).Value  '指定列说明  
               If .Cells(rwIndex, 4).Value = "N" Then
                   col.Mandatory = true        '指定列是否可空  true  为不可空                  
               End If
               if .Cells(rwIndex, 5).Value <>"" then
                   'col.defaults=.Cells(rwIndex, 5).Value
               end if
               'If rwIndex = 2 Then
                  ' col.Primary = true    '指定主键
              ' End If
               count = count + 1
             End If
             End If
        End With
Next
MsgBox col.Name + "表总共列数有 " + CStr(count), vbOK + vbInformation, "表"
Exit Sub
End sub

excel表格定义导入到powerdesigner脚本的更多相关文章

  1. 用多线程优化Excel表格数据导入校验的接口

    公司的需求,当前某个Excel导入功能,流程是:读取Excel数据,传入后台校验每一条数据,判断是否符合导入要求,返回给前端,导入预览展示.(前端等待响应,难点).用户再点击导入按钮,进行异步导入(前 ...

  2. 通过Python将Excel表格信息导入数据库

    前言 公司原采用Excel表格方式记录着服务器资产信息,随着业务的增加,相应的硬件资产也增加,同时物理机虚拟化出多台虚拟机,存在表格管理杂乱.变更资产信息不能及时相互同步, 为了紧跟时代的步伐,老大搞 ...

  3. 将Excel表结构导入到Powerdesigner

    我们经常会在excel中设计整理表结构,整理完需要导入到Powerdesigner中,可以通过以下脚本来实现快速,具体操作方法: 打开PowerDesigner,新建模型,点击Tools|Execut ...

  4. 将包含经纬度点位信息的Excel表格数据导入到ArcMap中并输出成shapefile

    将包含经纬信息的Excel表格数据,导入到ArcMap中并输出成shapefile,再进行后面的操作.使用这种方法可以将每一个包含经纬信息的数据在ArcMap中点出来. 一.准备数据 新建Excel表 ...

  5. php操作excel表格的导入和导出

    前言:对于excel大家肯定熟悉不过了的,那么我们在日常的业务中应该是有对这些文件的导入导出操作的 类的下载:composer require phpoffice/phpexcel,其中Classes ...

  6. 【Javaweb】poi实现通过上传excel表格批量导入数据到数据库

    1.导入poi相关jar包 对于只操作2003及以前版本的excel,只需要导入poi-XXX.jar ,如果还需要对2007及以后版本进行操作,则需要导入 poi-ooxml-XXX.jar poi ...

  7. php解析Excel表格并且导入MySQL数据库

    最近根据客户需求,需要增加一个导入Excel表格的功能,Excel中存放的是知识库中医知识的分类体系目录.是在thinkphp框架下编写的代码,用的是phpexcel第三方包.测试环境用的是xampp ...

  8. Unity 3D读取Excel表格、导入信息、导出Json

    Unity 3D读取/导入Excel表格 本文提供全流程,中文翻译. Chinar 坚持将简单的生活方式,带给世人!(拥有更好的阅读体验 -- 高分辨率用户请根据需求调整网页缩放比例) Chinar ...

  9. Excel表格数据导入MySQL数据库

    有时候项目需要将存在表格中的批量数据导入数据库,最近自己正好碰到了,总结一下: 1.将excel表格另存为.csv格式文件,excel本身的.xlsx格式导入时可能会报错,为了避免不必要的格式错误,直 ...

随机推荐

  1. gpio 預設值

    若 gpio 預設值只寫 pull-down or pull-up or no-pull or keeper, 代表 是 input mode.

  2. linux mmap 详解【转】

    转自:http://blog.chinaunix.net/uid-20321537-id-3483405.html 一.前言mmap的具体实现以前在学习内核时学习过,但是对于其中的很多函数是一知半解的 ...

  3. android 的渐变背景设置文件

    main.xml:<button android:layout_width="wrap_content" android:layout_height="wrap_c ...

  4. PHP二维数组排序研究

    前几天在项目中碰到了一个问题,在做商城的时候,要对一个店铺里所有商品进行价格排序,而且每一种商品都拥有多个规格,要取到所有商品中所有规格的最低价和最高价,发现PHP有很友好的函数帮助我们进行筛选. 使 ...

  5. (4)JavaScript引用类型

    Object类 创建object实例的方式有两种 1.第一种是使用 new 操作符后跟 Object 构造函数 var person = new Object(); person.name = &qu ...

  6. 用pid 取主窗口 hwnd

    HWND GetHwndByPid(DWORD dwProcessID) { HWND h = GetTopWindow(); HWND retHwnd = NULL; while ( h ) { D ...

  7. 【java】Map、Set、List不同数据结构的各种不同循环迭代的效率对比,使用场景

    Map.Set.List不同数据结构的各种不同循环迭代的效率对比,使用场景 引申一个地址:Map迭代的使用keySet和entitySet的效率

  8. appium 'WebDriver' object has no attribute 'keyevent'

    这个问题是我自己犯二了,开头应该是from appium import webdriver,写成了from selenium import webdriver,也可以运行,就是不能使用appium中独 ...

  9. 解释一下Windows dos中的符号

    容许我放一段Windows的批处理: sc <server> [command] [service name] <option1> <option2>... < ...

  10. TP框架中多条件筛选

            $pid =I('pid');         $year = I('year');         $productType = I('productType');         ...