DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

How can I register channels imported using DataFileLoad function in DIAdem 2012?

Solved!
Go to solution

Hallo,

 

I would like to import data from Excel into the DIAdem 2012.

I newly use DataFileLoad and ufi file to define import plugin.

But when I want to copy a the imported channels to another group, I get err: The Channel argument of the AddChannel method must be IChannel.

 

How can I register/convert/refersh channels, so I can work with them?

 

I'm showing code sample I took from standard example collection, from: "Loading Excel Files with a DataPlugin", script file A_172132_ExcelDataPlugin.vbs

Note: to get to worky my example you have to set proprely used paths

 

If Not ItemInfoGet("sPathDocuments") Then
  Call GlobalDim("sPathDocuments")
  Call GlobalDim("sPathData")
End If
sPathDocuments = CurrentScriptPath
sPathData      = CurrentScriptPath & "..\Data\"
call PrepareAndLoadDataset

sub PrepareAndLoadDataset()
  Call Data.Root.Clear()
  If  Not FileFilterExist("A_172132_Example") Then
    Call Navigator.RegisterDataPlugin(sPathDocuments&"A_172132_Example.uri",True)
  End If
  
  set MyGroup = DataFileLoad(sPathData & "A_172132.xlsx", "A_172132_Example","") 
  set MyTemp = Data.Root.ChannelGroups.Add("temp")
  Call MyTemp.Channels.AddChannel(MyGroup.Item(1).ChannelGroups(1).Channels(1))
end sub

 

Thank you for advance.

 

Radek

0 Kudos
Message 1 of 7
(4,902 Views)

Hello Codr,

 

Your script works fine on with my DIAdem 2012. I just defined "Dim MyGroup, MyTemp"

The result is a new channel group with one channel. The channel is the first channel of the first group of the loaded dataset.

 

In case you would like to register the Excel file (and not load it) you need toexpand the copied channel. This looks like this:

 

sub PrepareAndLoadDataset()
  Call Data.Root.Clear()
  If  Not FileFilterExist("A_172132_Example") Then
    Call Navigator.RegisterDataPlugin(sPathDocuments&"A_172132_Example.uri",True)
  End If
  
  dim MyGroup, MyTemp, oChn
  set MyGroup = DataFileLoad(sPathData & "A_172132.xlsx", "A_172132_Example","Register") 
  set MyTemp = Data.Root.ChannelGroups.Add("temp")
  set oChn = MyTemp.Channels.AddChannel(MyGroup.Item(1).ChannelGroups(1).Channels(1))
  call ChnValExpand(oChn)
end sub

 

Greetings

Walter

0 Kudos
Message 2 of 7
(4,884 Views)

I tied to register exel file, and used your code, but it doesn't help, I'm still geting same error mesage.

0 Kudos
Message 3 of 7
(4,876 Views)

 

To working around this problem I'm defining a new group:

  dim MyGroup, MyTemp, NewGroup, oChn
  set MyGroup = DataFileLoad(sPathData & "A_172132.xlsx", "A_172132_Example") 
  set NewGroup = Data.Root.ChannelGroups(MyGroup.Item(1).ChannelGroups(1).Name)
  set MyTemp = Data.Root.ChannelGroups.Add("temp")
  set oChn = MyTemp.Channels.AddChannel(NewGroup.Channels(1))

 
This method but does not come to be very elegant to me.

0 Kudos
Message 4 of 7
(4,872 Views)

Hi,

 

Have you tried the "Register" import action parameter in the DataFileLoad command?

 set MyGroup = DataFileLoad(sPathData & "A_172132.xlsx", "A_172132_Example","Register")
0 Kudos
Message 5 of 7
(4,866 Views)

I actually want to convert imported exel file to IChannel rather, than to register exel file to DIAdem.

But yes I tried both possibilities, with same result.

0 Kudos
Message 6 of 7
(4,862 Views)
Solution
Accepted by topic author Radek_Codr

I find out, that this problem I get, when I run the script in debug mode.

 

In run mode it works correctly.

 

0 Kudos
Message 7 of 7
(4,857 Views)