Skip to content

Commit c801667

Browse files
committed
Updated Excel Create Dataset and added sample for looping dataset #158
1 parent 4913df5 commit c801667

File tree

3 files changed

+74
-3
lines changed

3 files changed

+74
-3
lines changed

taskt/Core/Automation/Commands/BeginExcelDatasetLoopCommand.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ public BeginExcelDatasetLoopCommand()
2727
{
2828
this.CommandName = "BeginExcelDataSetLoopCommand";
2929
this.SelectionName = "Loop Excel Dataset";
30-
this.CommandEnabled = true;
30+
//this command is no longer required as list loop can successfully loop.
31+
this.CommandEnabled = false;
3132
this.CustomRendering = true;
3233
}
3334

taskt/Core/Automation/Commands/ExcelCreateDataSetCommand.cs

+12-2
Original file line numberDiff line numberDiff line change
@@ -37,19 +37,29 @@ public class ExcelCreateDataSetCommand : ScriptCommand
3737
[Attributes.PropertyAttributes.Remarks("")]
3838
public string v_SheetName { get; set; }
3939

40+
[XmlAttribute]
41+
[Attributes.PropertyAttributes.PropertyDescription("Indicate if Header Row Exists")]
42+
[Attributes.PropertyAttributes.PropertyUISelectionOption("Yes")]
43+
[Attributes.PropertyAttributes.PropertyUISelectionOption("No")]
44+
[Attributes.PropertyAttributes.InputSpecification("Select the necessary indicator")]
45+
[Attributes.PropertyAttributes.SampleUsage("Select **Yes**, **NO**. Data will be loaded as column headers if **YES** is selected.")]
46+
[Attributes.PropertyAttributes.Remarks("")]
47+
public string v_ContainsHeaderRow { get; set; }
48+
4049
public ExcelCreateDataSetCommand()
4150
{
4251
this.CommandName = "ExcelCreateDatasetCommand";
4352
this.SelectionName = "Create Dataset";
4453
this.CommandEnabled = true;
4554
this.CustomRendering = true;
55+
v_ContainsHeaderRow = "Yes";
4656
}
4757

4858
public override void RunCommand(object sender)
4959
{
5060

5161
DatasetCommands dataSetCommand = new DatasetCommands();
52-
DataTable requiredData = dataSetCommand.CreateDataTable(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + v_FilePath + @";Extended Properties=""Excel 12.0;HDR=No;IMEX=1""", "Select * From [" + v_SheetName + "$]");
62+
DataTable requiredData = dataSetCommand.CreateDataTable(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + v_FilePath.ConvertToUserVariable(sender) + $@";Extended Properties=""Excel 12.0;HDR={v_ContainsHeaderRow.ConvertToUserVariable(sender)};IMEX=1""", "Select * From [" + v_SheetName.ConvertToUserVariable(sender) + "$]");
5363

5464
var engine = (Core.Automation.Engine.AutomationEngineInstance)sender;
5565

@@ -70,7 +80,7 @@ public override List<Control> Render(frmCommandEditor editor)
7080
RenderedControls.AddRange(CommandControls.CreateDefaultInputGroupFor("v_DataSetName", this, editor));
7181
RenderedControls.AddRange(CommandControls.CreateDefaultInputGroupFor("v_FilePath", this, editor));
7282
RenderedControls.AddRange(CommandControls.CreateDefaultInputGroupFor("v_SheetName", this, editor));
73-
83+
RenderedControls.AddRange(CommandControls.CreateDefaultDropdownGroupFor("v_ContainsHeaderRow", this, editor));
7484
return RenderedControls;
7585

7686
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Script xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
3+
<Commands>
4+
<ScriptAction>
5+
<ScriptCommand xsi:type="CommentCommand" CommandID="f3a14099-21a7-43d4-8362-a2c063e63799" CommandName="CommentCommand" IsCommented="false" SelectionName="Add Code Comment" DefaultPause="0" LineNumber="1" PauseBeforeExeucution="false" v_Comment="Open Worksheet and Pull Dataset. Sample DataSet used Below." CommandEnabled="true" />
6+
</ScriptAction>
7+
<ScriptAction>
8+
<ScriptCommand xsi:type="CommentCommand" CommandID="1d340af1-0819-492d-b94f-03fa695e8119" CommandName="CommentCommand" IsCommented="false" SelectionName="Add Code Comment" DefaultPause="0" LineNumber="2" PauseBeforeExeucution="false" v_Comment="A B&#xD;&#xA;name&#x9;color&#xD;&#xA;Jason&#x9;Red&#xD;&#xA;John&#x9;Blue&#xD;&#xA;Tom&#x9;Green&#xD;&#xA;" CommandEnabled="true" />
9+
</ScriptAction>
10+
<ScriptAction>
11+
<ScriptCommand xsi:type="ExcelCreateDataSetCommand" CommandID="85ff8a9d-3364-4db9-9594-dc1f883a53cd" CommandName="ExcelCreateDatasetCommand" IsCommented="false" SelectionName="Create Dataset" DefaultPause="0" LineNumber="3" PauseBeforeExeucution="false" CommandEnabled="true" v_DataSetName="vExcelDS" v_FilePath="D:\Dropbox\Environment Folders\Desktop\test2.xlsx" v_SheetName="Sheet1" v_ContainsHeaderRow="Yes" />
12+
</ScriptAction>
13+
<ScriptAction>
14+
<ScriptCommand xsi:type="CommentCommand" CommandID="edb775f6-57f1-420d-a655-951b1b11ac0b" CommandName="CommentCommand" IsCommented="false" SelectionName="Add Code Comment" DefaultPause="0" LineNumber="4" PauseBeforeExeucution="false" v_Comment="Loop each row" CommandEnabled="true" />
15+
</ScriptAction>
16+
<ScriptAction>
17+
<ScriptCommand xsi:type="BeginListLoopCommand" CommandID="0d36938d-6529-4e3c-b3ef-9dd938b4e5bb" CommandName="BeginListLoopCommand" IsCommented="false" SelectionName="Loop List" DefaultPause="0" LineNumber="5" PauseBeforeExeucution="false" CommandEnabled="true" v_LoopParameter="vExcelDS" />
18+
<AdditionalScriptCommands>
19+
<ScriptCommand xsi:type="CommentCommand" CommandID="820b8929-4c66-4e33-8656-c90604ce5476" CommandName="CommentCommand" IsCommented="false" SelectionName="Add Code Comment" DefaultPause="0" LineNumber="6" PauseBeforeExeucution="false" v_Comment="Calling by {datasetName} will return array. This can additionally be parsed by &quot;Parse Json Array&quot; command." CommandEnabled="true" />
20+
</AdditionalScriptCommands>
21+
<AdditionalScriptCommands>
22+
<ScriptCommand xsi:type="MessageBoxCommand" CommandID="f3019daa-775b-4d00-85c8-f7c801b75596" CommandName="MessageBoxCommand" IsCommented="false" SelectionName="Show Message" DefaultPause="0" LineNumber="7" PauseBeforeExeucution="false" CommandEnabled="true" v_Message="{vExcelDS}" v_AutoCloseAfter="0" />
23+
</AdditionalScriptCommands>
24+
<AdditionalScriptCommands>
25+
<ScriptCommand xsi:type="CommentCommand" CommandID="0e74779c-34a7-4677-a5ce-d6038e75dde2" CommandName="CommentCommand" IsCommented="false" SelectionName="Add Code Comment" DefaultPause="0" LineNumber="8" PauseBeforeExeucution="false" v_Comment="Items can be pulled by column index" CommandEnabled="true" />
26+
</AdditionalScriptCommands>
27+
<AdditionalScriptCommands>
28+
<ScriptCommand xsi:type="MessageBoxCommand" CommandID="c5445d7e-772f-4906-8335-c1b6678889fc" CommandName="MessageBoxCommand" IsCommented="false" SelectionName="Show Message" DefaultPause="0" LineNumber="9" PauseBeforeExeucution="false" CommandEnabled="true" v_Message="{vExcelDS.0}" v_AutoCloseAfter="0" />
29+
</AdditionalScriptCommands>
30+
<AdditionalScriptCommands>
31+
<ScriptCommand xsi:type="CommentCommand" CommandID="9d10da57-5f39-41dc-9499-bafc58e93534" CommandName="CommentCommand" IsCommented="false" SelectionName="Add Code Comment" DefaultPause="0" LineNumber="10" PauseBeforeExeucution="false" v_Comment="Items can be pulled by column name (If Header = Yes)" CommandEnabled="true" />
32+
</AdditionalScriptCommands>
33+
<AdditionalScriptCommands>
34+
<ScriptCommand xsi:type="MessageBoxCommand" CommandID="5c7cab75-cfd0-496f-88d3-6e6fadd1a916" CommandName="MessageBoxCommand" IsCommented="false" SelectionName="Show Message" DefaultPause="0" LineNumber="11" PauseBeforeExeucution="false" CommandEnabled="true" v_Message="{vExcelDS.Name}" v_AutoCloseAfter="0" />
35+
</AdditionalScriptCommands>
36+
<AdditionalScriptCommands>
37+
<ScriptCommand xsi:type="CommentCommand" CommandID="dc649501-79b8-4b9f-b552-f21871c7838a" CommandName="CommentCommand" IsCommented="false" SelectionName="Add Code Comment" DefaultPause="0" LineNumber="12" PauseBeforeExeucution="false" v_Comment="Items can be pulled by column index (second column index)" CommandEnabled="true" />
38+
</AdditionalScriptCommands>
39+
<AdditionalScriptCommands>
40+
<ScriptCommand xsi:type="MessageBoxCommand" CommandID="0f54aef0-59ad-4690-b8db-1034640b3308" CommandName="MessageBoxCommand" IsCommented="false" SelectionName="Show Message" DefaultPause="0" LineNumber="13" PauseBeforeExeucution="false" CommandEnabled="true" v_Message="{vExcelDS.1}" v_AutoCloseAfter="0" />
41+
</AdditionalScriptCommands>
42+
<AdditionalScriptCommands>
43+
<ScriptCommand xsi:type="CommentCommand" CommandID="8ec67541-7fb1-4a63-8fb7-07c6d4f3510a" CommandName="CommentCommand" IsCommented="false" SelectionName="Add Code Comment" DefaultPause="0" LineNumber="14" PauseBeforeExeucution="false" v_Comment="Items can be pulled by column name (If Header = Yes)" CommandEnabled="true" />
44+
</AdditionalScriptCommands>
45+
<AdditionalScriptCommands>
46+
<ScriptCommand xsi:type="MessageBoxCommand" CommandID="4f888d9b-9fad-4399-857e-039c65010281" CommandName="MessageBoxCommand" IsCommented="false" SelectionName="Show Message" DefaultPause="0" LineNumber="15" PauseBeforeExeucution="false" CommandEnabled="true" v_Message="{vExcelDS.Color}" v_AutoCloseAfter="0" />
47+
</AdditionalScriptCommands>
48+
<AdditionalScriptCommands>
49+
<ScriptCommand xsi:type="MessageBoxCommand" CommandID="c84ccce3-ccec-4d2c-b6f3-f357bdacb5be" CommandName="MessageBoxCommand" IsCommented="false" SelectionName="Show Message" DefaultPause="0" LineNumber="16" PauseBeforeExeucution="false" CommandEnabled="true" v_Message="{vExcelDS =&gt;$.[0]}" v_AutoCloseAfter="0" />
50+
</AdditionalScriptCommands>
51+
<AdditionalScriptCommands>
52+
<ScriptCommand xsi:type="CommentCommand" CommandID="e63dfa71-a242-4361-a139-a959e4476e76" CommandName="CommentCommand" IsCommented="false" SelectionName="Add Code Comment" DefaultPause="0" LineNumber="17" PauseBeforeExeucution="false" v_Comment="Items in this section will run within the loop" CommandEnabled="true" />
53+
</AdditionalScriptCommands>
54+
<AdditionalScriptCommands>
55+
<ScriptCommand xsi:type="EndLoopCommand" CommandID="3b8469d3-894d-4cb4-af78-bb30111dbc00" CommandName="EndLoopCommand" IsCommented="false" SelectionName="End Loop" DefaultPause="0" LineNumber="18" PauseBeforeExeucution="false" CommandEnabled="true" />
56+
</AdditionalScriptCommands>
57+
</ScriptAction>
58+
</Commands>
59+
<Variables />
60+
</Script>

0 commit comments

Comments
 (0)