08-14-2012 10:25 AM
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
Solved! Go to Solution.
08-15-2012 09:56 AM
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
08-16-2012 12:56 AM
I tied to register exel file, and used your code, but it doesn't help, I'm still geting same error mesage.
08-16-2012 01:08 AM
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.
08-16-2012 01:27 AM
Hi,
Have you tried the "Register" import action parameter in the DataFileLoad command?
set MyGroup = DataFileLoad(sPathData & "A_172132.xlsx", "A_172132_Example","Register")
08-16-2012 01:37 AM
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.
08-16-2012 01:50 AM
I find out, that this problem I get, when I run the script in debug mode.
In run mode it works correctly.