You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
nmWATI/Bin/Doc/iWTAI_DataStructure.vbs

111 lines
3.3 KiB
Plaintext

'******************************************************************************
'* File: excel2pdm.vbs
'* Purpose: <20><><EFBFBD><EFBFBD>excel<65><6C><EFBFBD><EFBFBD><EFBFBD>Ƶı<C6B5><C4B1><EFBFBD><EFBFBD>뵽pdm<64>ļ<EFBFBD>
'* Category:
'* Version: 1.0
'* time : 2014-6-11
'* <20><>Ϊϲ<CEAA><CFB2><EFBFBD><EFBFBD>excel<65><6C><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݿ<EFBFBD><DDBF><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƣ<EFBFBD><C6A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>øó<C3B8><C3B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>뵽pdm<64><6D>
'* <20>ó<EFBFBD><C3B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ψһû<D2BB><C3BB><EFBFBD><EFBFBD><EFBFBD>ܺõĴ<C3B5><C4B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֹ<EFBFBD><D6B9>޸ġ<DEB8>
'*<2A>ó<EFBFBD><C3B3><EFBFBD><EFBFBD>ο<EFBFBD><CEBF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵Ĵ<CBB5><C4B4><EFBFBD><EBA3AC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǿ<EFBFBD><C7BF>Խ<EFBFBD>sheet<65><74><EFBFBD><EFBFBD><EFBFBD>еı<D0B5>һ<EFBFBD>ε<EFBFBD><CEB5>
'*
'* <20><><EFBFBD>еı<D0B5><C4B1><EFBFBD><EFBFBD>ƶ<EFBFBD><C6B6><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>excel<65><6C>һ<EFBFBD><D2BB>sheet<65>У<EFBFBD>ÿ<EFBFBD><C3BF><EFBFBD><EFBFBD><EFBFBD>м<EFBFBD><D0BC><EFBFBD>һ<EFBFBD>У<EFBFBD><D0A3><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD>ͷ˵<CDB7><CBB5><EFBFBD><EFBFBD><EFBFBD>£<EFBFBD>
'* <20><>ǰ<EFBFBD><C7B0>һ<EFBFBD><D2BB><EFBFBD>DZ<EFBFBD><C7B1><EFBFBD><EFBFBD>ͱ<EFBFBD><CDB1><EFBFBD>˵<EFBFBD><CBB5><EFBFBD><EFBFBD><EFBFBD>ֱ<EFBFBD><D6B1><EFBFBD>A<EFBFBD><41>C<EFBFBD>С<EFBFBD><D0A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽֱ<CABD>ӿ<EFBFBD><D3BF><EFBFBD><EFBFBD><EFBFBD>excel<65>оͿ<D0BE><CDBF>Կ<EFBFBD><D4BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ո<EFBFBD><D5B8><EFBFBD><EFBFBD>Ʊ<EFBFBD><C6B1><EFBFBD><EFBFBD><EFBFBD>
'******************************************************************************
' Excel <20><>ʽ<EFBFBD><CABD><EFBFBD><EFBFBD>
'icontract_master_t <09>ļ<EFBFBD>ͷ<EFBFBD><CDB7>
'<27><><EFBFBD><EFBFBD> <09><><EFBFBD><EFBFBD> <09><> <09>ǿ<EFBFBD> ע<><D7A2>
'contract_m_id NUMBER <09><><EFBFBD><EFBFBD> N <09><><EFBFBD><EFBFBD>
'******************************************************************************
Option Explicit
Dim mdl ' the current model
Set mdl = ActiveModel
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:\Run\mWTAI\Bin\Doc\iWTAI_DataStructure.xlsx"
x1.Workbooks(1).Worksheets("Table").Activate 'ָ<><D6B8>Ҫ<EFBFBD>򿪵<EFBFBD>sheet<65><74><EFBFBD><EFBFBD>
Else
HaveExcel = False
End If
a x1, mdl
sub a(x1, mdl)
dim rwIndex
dim tableName
dim colname
dim table
dim col
dim count
dim abc
on error Resume Next
'--------------------------------
'<27><><EFBFBD><EFBFBD><EFBFBD>Ƕ<EFBFBD>ȡexcel<65><6C><EFBFBD><EFBFBD><EFBFBD>ӱ<EFBFBD>ʵ<EFBFBD><CAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
'--------------------------------
For rwIndex = 2 To 457 'ָ<><D6B8>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Excel<65>б<EFBFBD> <20><><EFBFBD>ڵ<EFBFBD>2<EFBFBD><32><EFBFBD>DZ<EFBFBD>ͷ<EFBFBD><CDB7><EFBFBD>ӵ<EFBFBD>1<EFBFBD>п<EFBFBD>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƶ<EFBFBD><C6B6><EFBFBD><EFBFBD><EFBFBD>
With x1.Workbooks(1).Worksheets("Table")'<27><>Ҫѭ<D2AA><D1AD><EFBFBD><EFBFBD>sheet<65><74><EFBFBD><EFBFBD>
If .Cells(rwIndex,1).Value <> "" And .Cells(rwIndex,3).Value <> "" And .Cells(rwIndex,4).Value = "Table" Then
set table = mdl.Tables.CreateNew '<27><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD>ʵ<EFBFBD><CAB5>
table.Code = .Cells(rwIndex,3).Value'<27><>excel<65><6C>ȡ<EFBFBD>ñ<EFBFBD><C3B1><EFBFBD><EFBFBD>ƺͱ<C6BA><CDB1><EFBFBD>
table.Name = .Cells(rwIndex,1).Value'
table.Comment = .Cells(rwIndex,1).Value 'ָ<><D6B8><EFBFBD><EFBFBD>˵<EFBFBD><CBB5>
count = count + 1
'MsgBox .Cells(rwIndex,1).Value + .Cells(rwIndex,3).Value + .Cells(rwIndex,4).Value, vbOK + vbInformation, "<22><>"
Continue
End If
If .Cells(rwIndex,2).Value = "" Or .Cells(rwIndex,3).Value = "" Or (.Cells(rwIndex,1).Value = "<22><><EFBFBD><EFBFBD>" And .Cells(rwIndex,2).Value = "<22><><EFBFBD><EFBFBD>")Then
continue
Else
set col =table.Columns.CreateNew '<27><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>/<2F>ֶ<EFBFBD>
col.Name = .Cells(rwIndex, 2).Value 'ָ<><D6B8><EFBFBD><EFBFBD>name
col.Code = .Cells(rwIndex, 3).Value 'ָ<><D6B8><EFBFBD><EFBFBD>code
col.DataType = .Cells(rwIndex, 4).Value 'ָ<><D6B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
If.Cells(rwIndex, 5).Value <> "" Then'ָ<><D6B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
col.Primary =true
End If
If.Cells(rwIndex, 8).Value = "Y" Then'ָ<><D6B8><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7>ɿ<EFBFBD> true Ϊ<><CEAA><EFBFBD>ɿ<EFBFBD>
col.Mandatory =true
End If
col.Comment = .Cells(rwIndex, 2).Value 'ָ<><D6B8><EFBFBD><EFBFBD>˵<EFBFBD><CBB5>
'col.Length =.Cells(rwIndex, 4).Value 'ָ<><D6B8><EFBFBD>ֶγ<D6B6><CEB3><EFBFBD>
'col.Precision =.Cells(rwIndex, 5).Value 'ָ<><D6B8><EFBFBD>ֶγ<D6B6><CEB3><EFBFBD>
End If
End With
Next
MsgBox "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݱ<EFBFBD><DDB1><EFBFBD><E1B9B9><EFBFBD><EFBFBD> " + CStr(count), vbOK + vbInformation, "<22><>"
Exit Sub
End sub