vbs dictionary excel

读取连个e3文件 

输出格式 

blockname 1.e3s 2.e3s

aaa            Y     N

bbb          N    Y

 ccc     N         N


Dim sdict 'As Disctionary 

Dim i     'As Integer
Dim keys   'As String


Call GetInfo(sdict)
   
Set   ExcelApp  =  CreateObject("Excel.Application")        
Set   ExcelBook =  ExcelApp.Workbooks.Add  
Set   ExcelSheet   =   ExcelBook.Worksheets(1)     'sheetを追加
   
ExcelSheet.Activate   
ExcelApp.DisplayAlerts   =   False   
ExcelSheet.Name="sheet1"


ExcelSheet.range("A1").Value = "blockname"
ExcelSheet.range("B1").value="1.e3s"
ExcelSheet.range("C1").value="2.e3s"


'すべてのキーを取得
keys = sdict.Keys
'すべてのちを取得
items =sdict.Items




For i = 0 To sdict.Count - 1
ExcelSheet.cells(i+2,1).value=keys(i)
msgbox items(i)
If  items(i) = 0 Then
ExcelSheet.cells(i+2,2).value="Y"
ExcelSheet.cells(i+2,3).value="Y"
ElseIf items(i) =1 Then 
ExcelSheet.cells(i+2,2).value="Y"
ExcelSheet.cells(i+2,3).value="N"
ElseIf items(i)=2   Then
ExcelSheet.cells(i+2,2).value="N"
ExcelSheet.cells(i+2,3).value="Y"
End If
Next


ExcelBook.SaveAs "d:\1.xlsx"
ExcelBook.close


Set excelApp=nothing
Set ExcelBook=nothing
Set ExcelSheet=nothing




Public Function GetInfo(sdict)
   
Dim strarry1(5)  'As Array
Dim strarry2(8)  'As Array
Dim Count1       'As Integer
Dim Count2       'As Integer
Dim i            'As Integer


'1.e3sを読み込む
Call ReadFile("d:\3.e3s",strarry1)
'2.e3sを読み込む
Call ReadFile("d:\4.e3s",strarry2)


Count1 = ubound(strarry1)+1


Count2 = ubound(strarry2)+1

Set sdict=CreateObject("Scripting.Dictionary")


'1.e3sのみ存在する時に、1を設定します
For i = 0 To Count1 - 1

     If strarry1(i)<>null Then
sdict.add strarry1(i),1
 
    End If 
Next


For i = 0 To Count2 - 1


'1.e3sと2.e3sに存在する時に、0を設定します
If sdict.Exists(strarry2(i)) Then
  If strarry2(i)<>null Then
sdict.add strarry2(i),0
            End If  
'2.e3sのみ存在する時に、2を設定します
Else
sdict.add strarry2(i),2
End If
Next
End Function

Public Function ReadFile(filePath,strarry)


    Dim e3 'As CT.Application
Dim prj  'As CT.Job
Dim dev   'As CT.Device
Dim devides  'As string
   
    Set e3 = CreateObject( "CT.Application" )
    Set prj = e3.CreateJobObject
   
    prj.open filePath


    Set dev = Prj.CreateDeviceObject


    'devicenameを出力
    'e3.putinfo 0,"name:devides"
    devides = prj.GetAllDeviceIds(devideids)

    For i = 0 To devides
    dev.setid devideids(i)
  
        str= dev.getname 
        strarry(i)=str
  
    Next
End Function
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值