powerdesign扫描excel表生成概念模型

打开powerdesign


新建 conceptual data model (CDM) 


此脚本只试用于 CDM图


打开菜单栏 Tool -> execute command ->Edit/Run Script


脚本如下:

On Error Resume Next 

dim excelPath
excelPath="c:/a.xls"
dim sheetCount
Dim model ' the current model
Set model = ActiveModel
If (model Is Nothing) Then  
 MsgBox "There is no Active Model"
End If


Dim RQ 
RQ=MsgBox ("是否安装excel?",vbYesNo + vbInformation,"Confirmation")
if RQ = vbyes then


Set x=createobject("Excel.Application")
x.workbooks.open excelPath
x.workbooks(1).worksheets(1).activate
sheetCount=x.workbooks(1).worksheets.count
'开始处理多个sheet
for each tmpSheet in x.workbooks(1).worksheets




   if tmpSheet.cells(1,1)<>"" then
     '获取到总行数
     dim rowCount
     rowCount=tmpSheet.usedrange.rows.count
     '获取到总列树
     dim colCount
     colCount=tmpSheet.usedrange.columns.count
  
     '首先获取表名称 第一列是表名称
     tableName=tmpSheet.cells(1,1).value
  
     set newEntity=Activemodel.entities.createnew
     newEntity.name=tableName
     newEntity.code=tableName
     
     for rowIndex=2 to rowCount
       set newColumn=newEntity.attributes.createnew
       'msgbox rowIndex
       'msgbox tmpSheet.cells(rowIndex,1)
       if tmpSheet.cells(rowIndex,1) <>"" then
       newColumn.name=tmpSheet.cells(rowIndex,1)  
       newColumn.code=tmpSheet.cells(rowIndex,1)
       newColumn.datatype="Variable characters (60)"
       end if


     next
  
   end if 
  
  
  
next 
msgbox "生成完成"
x.workbooks.close()
x.quit
end if


If Err.Number <> 0 Then 
   x.workbooks.close()
   x.quit
end if 




excel 格式:



转载于:https://www.cnblogs.com/liaomin416100569/archive/2012/02/10/9331416.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值