excel表格定义导入到powerdesigner脚本
打开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脚本的更多相关文章
- 用多线程优化Excel表格数据导入校验的接口
公司的需求,当前某个Excel导入功能,流程是:读取Excel数据,传入后台校验每一条数据,判断是否符合导入要求,返回给前端,导入预览展示.(前端等待响应,难点).用户再点击导入按钮,进行异步导入(前 ...
- 通过Python将Excel表格信息导入数据库
前言 公司原采用Excel表格方式记录着服务器资产信息,随着业务的增加,相应的硬件资产也增加,同时物理机虚拟化出多台虚拟机,存在表格管理杂乱.变更资产信息不能及时相互同步, 为了紧跟时代的步伐,老大搞 ...
- 将Excel表结构导入到Powerdesigner
我们经常会在excel中设计整理表结构,整理完需要导入到Powerdesigner中,可以通过以下脚本来实现快速,具体操作方法: 打开PowerDesigner,新建模型,点击Tools|Execut ...
- 将包含经纬度点位信息的Excel表格数据导入到ArcMap中并输出成shapefile
将包含经纬信息的Excel表格数据,导入到ArcMap中并输出成shapefile,再进行后面的操作.使用这种方法可以将每一个包含经纬信息的数据在ArcMap中点出来. 一.准备数据 新建Excel表 ...
- php操作excel表格的导入和导出
前言:对于excel大家肯定熟悉不过了的,那么我们在日常的业务中应该是有对这些文件的导入导出操作的 类的下载:composer require phpoffice/phpexcel,其中Classes ...
- 【Javaweb】poi实现通过上传excel表格批量导入数据到数据库
1.导入poi相关jar包 对于只操作2003及以前版本的excel,只需要导入poi-XXX.jar ,如果还需要对2007及以后版本进行操作,则需要导入 poi-ooxml-XXX.jar poi ...
- php解析Excel表格并且导入MySQL数据库
最近根据客户需求,需要增加一个导入Excel表格的功能,Excel中存放的是知识库中医知识的分类体系目录.是在thinkphp框架下编写的代码,用的是phpexcel第三方包.测试环境用的是xampp ...
- Unity 3D读取Excel表格、导入信息、导出Json
Unity 3D读取/导入Excel表格 本文提供全流程,中文翻译. Chinar 坚持将简单的生活方式,带给世人!(拥有更好的阅读体验 -- 高分辨率用户请根据需求调整网页缩放比例) Chinar ...
- Excel表格数据导入MySQL数据库
有时候项目需要将存在表格中的批量数据导入数据库,最近自己正好碰到了,总结一下: 1.将excel表格另存为.csv格式文件,excel本身的.xlsx格式导入时可能会报错,为了避免不必要的格式错误,直 ...
随机推荐
- Smpt命令顺序不正确。 服务器响应为: Error: need EHLO and AUTH first !
刚发现以前做的QQ邮箱发送邮件不能用了,查找了下原因:未加( EnableSsl SSL加密连接 )导致的,顿时觉得很坑,以前QQ邮箱也没有这个限制啊,可能是最近加的. 好吧不多说直接从头走起,照顾 ...
- 自做CA自签发SSL证书
一.把证书准备好.步骤与使用OpenSSL自签发服务器https证书所述大同小异.在这里再重复一次.1.制作CA证书:ca.key CA私钥: openssl genrsa -des3 -out ca ...
- react 使用antd导航组件实现事件传递并局部刷新DOM
我们要实现一个通过点击顶部导航来查询左侧菜单的一个功能 在这个功能中,我们要应用到onClick={this.headNavMenuList.bind(this)}方法来传递点击 不同按钮来传递不同的 ...
- P1243~P1247 线段树模板题总结
前言 这几天刚刚刷了5道线段树(水)题,现在来总结一下. 首先是犯的不少错误: 1.建树.更新函数没有return.这是最气的,每次最后程序错误查了半天也没查出来,最后发现是没有return.递归边界 ...
- Storage protocol stacks
http://brasstacksblog.typepad.com/brass-tacks/ http://brasstacksblog.typepad.com/brass-tacks/2016/02 ...
- delphi中将 4 个 Byte 合成 1 个 Integer 的五种方法
有4个字节类型的值,用移位或逻辑运算符怎么合成一个整数?比如 $FFEEDDCC.高$FF$EE$DD$CC低 //方法 1: 共用内存procedure TForm1.Button1Click(Se ...
- smartsvn学习(-)
3. Day-to-day use 3.1 Everyday commands Most of the common commands you will need are in the SmartSV ...
- ios获得文件字节总数
NSDictionary *attributes = [[NSFileManager defaultManager] attributesOfItemAtPath:self.finalPath err ...
- node在Fedora 22系统下开发环境搭建
事实上,环境搭建在linux系统还是比較简单的,下载已经编译好的包,配置一下环境变量. 或者下载源代码,自己编译. 这里记录一下,主要是node版本号变化节奏很块的情况下.怎样配置一次环境变量就不要再 ...
- 一群牛人翻译:The Swift Programming Language 中文版
无聊闲逛GIthub,看到一群牛人在github上创建了一个关于Switf的文档翻译项目 The Swift Programming Language 中文版 项目地址:中文版 Apple 官方 Sw ...