Skip to content

Commit

Permalink
ExcelGetRangeCommand second cell is optional
Browse files Browse the repository at this point in the history
openbots-ff committed Mar 23, 2020
1 parent 3744451 commit dfed68b
Showing 2 changed files with 19 additions and 5 deletions.
10 changes: 8 additions & 2 deletions taskt/Core/Automation/Commands/ExcelGetRangeCommand .cs
Original file line number Diff line number Diff line change
@@ -60,7 +60,14 @@ public override void RunCommand(object sender)

Microsoft.Office.Interop.Excel.Application excelInstance = (Microsoft.Office.Interop.Excel.Application)excelObject;
Microsoft.Office.Interop.Excel.Worksheet excelSheet = excelInstance.ActiveSheet;
var cellValue = excelSheet.Range[targetAddress1, targetAddress2];
Microsoft.Office.Interop.Excel.Range cellValue;
if (targetAddress2 != "")
cellValue = excelSheet.Range[targetAddress1, targetAddress2];
else
{
Microsoft.Office.Interop.Excel.Range last = excelSheet.Cells.SpecialCells(Microsoft.Office.Interop.Excel.XlCellType.xlCellTypeLastCell, Type.Missing);
cellValue = excelSheet.Range[targetAddress1, last];
}

List<object> lst = new List<object>();
int rw = cellValue.Rows.Count;
@@ -85,7 +92,6 @@ public override void RunCommand(object sender)

}
string output = String.Join(",", lst);
v_ExcelCellAddress1 = output;

//Store Strings of comma seperated values into user variable
output.StoreInUserVariable(sender, v_userVariableName);
14 changes: 11 additions & 3 deletions taskt/Core/Automation/Commands/ExcelGetRangeCommandASDT.cs
Original file line number Diff line number Diff line change
@@ -40,7 +40,7 @@ public class ExcelGetRangeCommandAsDT : ScriptCommand
[Attributes.PropertyAttributes.Remarks("")]
public string v_Output { get; set; }
[XmlAttribute]
[Attributes.PropertyAttributes.PropertyDescription("Please Enter the Second Cell Location (ex. A1 or B2)")]
[Attributes.PropertyAttributes.PropertyDescription("Please Enter the Second Cell Location (ex. A1 or B2, Optional)")]
[Attributes.PropertyAttributes.PropertyUIHelper(Attributes.PropertyAttributes.PropertyUIHelper.UIAdditionalHelperType.ShowVariableHelper)]
[Attributes.PropertyAttributes.InputSpecification("Enter the actual location of the cell.")]
[Attributes.PropertyAttributes.SampleUsage("A1, B10, [vAddress]")]
@@ -73,7 +73,16 @@ public override void RunCommand(object sender)

Microsoft.Office.Interop.Excel.Application excelInstance = (Microsoft.Office.Interop.Excel.Application)excelObject;
Microsoft.Office.Interop.Excel.Worksheet excelSheet = excelInstance.ActiveSheet;
var cellValue = excelSheet.Range[targetAddress1, targetAddress2];
Microsoft.Office.Interop.Excel.Range cellValue;
if (targetAddress2 != "")
cellValue = excelSheet.Range[targetAddress1, targetAddress2];
else
{
Microsoft.Office.Interop.Excel.Range last = excelSheet.Cells.SpecialCells(Microsoft.Office.Interop.Excel.XlCellType.xlCellTypeLastCell, Type.Missing);
cellValue = excelSheet.Range[targetAddress1, last];
}


if (v_Output == "Datatable")
{

@@ -142,7 +151,6 @@ public override void RunCommand(object sender)

}
string output = String.Join(",", lst);
v_ExcelCellAddress1 = output;

//Store Strings of comma seperated values into user variable
output.StoreInUserVariable(sender, v_userVariableName);

0 comments on commit dfed68b

Please sign in to comment.