I need to invoke a a couple of UiPath activities within an Invoke Code activity.
Following the solution @vvaidya provided in this post,
I was able to write cell to a spreadsheet with this code. Works like a charm.
Dim writeCell1 As UiPath.Excel.Activities.WriteCell = New uipath.Excel.Activities.WriteCell writeCell1.WorkbookPath = xlsxFile writeCell1.SheetName = sheetName writeCell1.Cell = cellReference writeCell1.Text = cellValue Dim activity1 As WorkflowInvoker = New WorkflowInvoker(writeCell1) activity1.Invoke
But when I tried the same with write range, I started running into errors. Following the same logic as above,
Dim writeRange1 As UiPath.Excel.Activities.WriteRange = New uipath.Excel.Activities.WriteRange writeRange1.WorkbookPath = xlsxFile writeRange1.SheetName = sheetName writeRange1.AddHeaders = useHeaders 'boolean' writeRange1.StartingCell = anchorCell writeRange1.DataTable = myDatatable 'datatable' Dim activity1 As WorkflowInvoker = New WorkflowInvoker(writeRange1) activity1.Invoke
I get the following error:
’Literal’: Literal only supports value types and the immutable type System.String. The type System.Data.DataTable cannot be used as a literal.
I understand that for write range differs from write cell as write cell has only string data types and write range includes datatable and boolean types. I know it has to do with passing the datatable and boolean as literals but a day of googling has got me nowhere.
Would someone please give me a hand?