1200字范文,内容丰富有趣,写作的好帮手!
1200字范文 > 如何将word表结构转换为excel表格 最终转换为PowerDesigner格式

如何将word表结构转换为excel表格 最终转换为PowerDesigner格式

时间:2022-07-25 23:10:15

相关推荐

如何将word表结构转换为excel表格 最终转换为PowerDesigner格式

word版本结构

转换为excel

直接拷贝到excel表格中即可

需要对结构稍作处理,把表名和注释分到两个格子中,把字段头放到第一行,如果有多个表,把其他表的字段头去掉。如下:

接下来就可以做导入PowerDesigner的操作了

在PowerDesigner中新建物理模型

接着选择Tools——》ExecuteCommands——》Edit/RunScripts

脚本如下:

Option ExplicitDim mdl ' the current modelSet mdl = ActiveModelIf (mdl Is Nothing) ThenMsgBox "There is no Active Model"End IfDim HaveExcelDim RQRQ = vbYes 'MsgBox("Is Excel Installed on your machine ?", vbYesNo + vbInformation, "Confirmation")If RQ = vbYes ThenHaveExcel = True' Open & Create Excel DocumentDim x1 'Set x1 = CreateObject("Excel.Application")x1.Workbooks.Open "excel文档路径" '指定excel文档路径x1.Workbooks(1).Worksheets("Sheet1").Activate '指定要打开的sheet名称ElseHaveExcel = FalseEnd Ifa x1, mdlsub a(x1, mdl)dim rwIndex dim tableNamedim colnamedim tabledim coldim counton error Resume NextFor rwIndex = 2 To 1000 '指定要遍历的Excel行标 由于第1行是表头,从第2行开始With x1.Workbooks(1).Worksheets("Sheet1")If .Cells(rwIndex, 1).Value = "" Then '如果遍历到第一列为空,则退出Exit ForEnd IfIf .Cells(rwIndex, 3).Value = "" Then '如果遍历到第三列为空,则此行为表名set table = mdl.Tables.CreateNew'创建表table.Name = .Cells(rwIndex , 2).Value '指定表名,第一列的值table.Code = .Cells(rwIndex , 2).Value ment = .Cells(rwIndex , 1).Value '指定表注释,第二列的值count = count + 1 Elseset col = table.Columns.CreateNew '创建一列/字段'MsgBox .Cells(rwIndex, 1).Value, vbOK + vbInformation, "列" col.Name = .Cells(rwIndex, 4).Value '指定列名中文 'MsgBox col.Name, vbOK + vbInformation, "列"col.Code = .Cells(rwIndex, 1).Value '指定列名英文 col.DataType = .Cells(rwIndex, 2).Value '指定列数据类型 'MsgBox col.DataType, vbOK + vbInformation, "列类型"ment = .Cells(rwIndex, 4).Value '指定列说明End IfEnd WithNextMsgBox "生成数据表结构共计 " + CStr(count), vbOK + vbInformation, "表"Exit SubEnd sub

脚本中核心的就是要把excel中的结构跟数据库的结构进行对应

执行脚本

执行完会生成对应的table,如图:

接着按住shift,全选这些表,拖动到右侧的工作区,表就变成模型了。

参考:调整PowerDesigner各种字体大小

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。