1.打开pd(我这里用的是pd15),新建一个物理模型(PhysicalDataModel),打开下面的菜单
输入脚本,更改脚本中所要求的部分,删除提示更改的语句
Set mdl = ActiveModel
Dim HaveExcel Dim RQ
If RQ = vbYes Then HaveExcel = True ' Open & Create Excel Document
Dim x1 ' Set x1 = CreateObject("Excel.Application")
x1.Workbooks.Open "D:/test.xlsx" --更改要导入的excel名称 End If
dim rwIndex
dim tableName dim table dim col dim count 'on error Resume Next
With x1.Workbooks(1).Worksheets("Sheet1") 'MsgBox "生成数据表结构共计1 ="+CStr(.Cells(2,2).Value ), vbOK + vbInformation, "表" Exit For
End If If .Cells(rwIndex, 3).Value = "" Then set table = mdl.Tables.CreateNew
table.Code = .Cells(rwIndex , 2).Value count = count + 1 Else set col = table.Columns.CreateNew
'MsgBox .Cells(rwIndex, 1).Value, vbOK + vbInformation, "列" col.Name = .Cells(rwIndex, 1).Value 'MsgBox col.Name, vbOK + vbInformation, "列" col.Comment = .Cells(rwIndex,4).Value
col.DataType = .Cells(rwIndex, 3).Value End If End With Next MsgBox "生成数据表结构共计 " + CStr(count), vbOK + vbInformation, "表" Exit Sub
准备就绪,run就行了