@Priyesh_Shetty1 number of columns does not matter we can convert all columns
Please tell the exception
or use this
Dt.AsEnumerable.ToList.ForEach(sub(r) r("Total") = r.ItemArray.Sum(function(x) If(x.ToString.IsNumeric,0,Cint(x.ToString))).ToString)
cheers
@Anil_G exception for this code…Iam using invoke code before write range activity…RemoteException wrapping System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. —> RemoteException wrapping System.ArgumentException: Column ‘Total’ does not belong to table .
at System.Data.DataRow.GetDataColumn(String columnName)
at UiPathCodeRunner_a993b066d5e14fee938a9b50fb39f8ac._Closure$__._Lambda$__0-0(DataRow r)
at System.Collections.Generic.List1.ForEach(Action
1 action)
at UiPathCodeRunner_a993b066d5e14fee938a9b50fb39f8ac.Run(DataTable& dt)
— End of inner exception stack trace —
at System.RuntimeMethodHandle.InvokeMethod(Object target,
Object arguments,
Signature sig,
Boolean constructor)
at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj,
Object parameters,
Object arguments)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj,
BindingFlags invokeAttr,
Binder binder,
Object parameters,
CultureInfo culture)
at System.RuntimeType.InvokeMember(String name,
BindingFlags bindingFlags,
Binder binder,
Object target,
Object providedArgs,
ParameterModifier modifiers,
CultureInfo culture,
String namedParams)
at UiPath.Activities.System.Utilities.InvokeCode.CompilerRunner.Run(Object args)
at UiPath.Activities.System.Utilities.InvokeCode.NetCodeInvoker.Run(String userCode,
List1 inArgs, IEnumerable
1 imps,
Object args)
at UiPath.Core.Activities.InvokeCode.Execute(CodeActivityContext context)
at System.Activities.CodeActivity.InternalExecute(ActivityInstance instance,
ActivityExecutor executor,
BookmarkManager bookmarkManager)
at System.Activities.ActivityInstance.Execute(ActivityExecutor executor,
BookmarkManager bookmarkManager)
at System.Activities.Runtime.ActivityExecutor.ExecuteActivityWorkItem.ExecuteBody(ActivityExecutor executor,
BookmarkManager bookmarkManager,
Location resultLocation)
As per exception it says your dt does not have total column…can you check please and change name accordingly
cheers
@Anil_G after using ctrl+space i could not get the DT variable i have created a argument also in invoke code…and there iam getting the variable DT.
dt is the datatable which contains the data from your excel…are you reading it?
cheers
I see you initialized it…my question is us the dt variable containing data from your excel or what you want to write to your excel?
if yes…does it contain total columns also? if not add the column
cheers
But as per error it is clear that total column is not found…can you check if there are any spaces?
Also just to be sure verify in locals panel if you have data as expected
Cheers
@Anil_G your this code worked Dt.AsEnumerable.ToList.ForEach(sub(r) r(“Total”) = r.ItemArray.Sum(function(x) If(String.IsNullOrEmpty(x.ToString),0,Cint(x.ToString))).ToString)…But no changes in excel total count.
@Anil_G no it did not write the total count
because to write the total count i have to convert the each and every column to number then only total count column get increamented
The given formula is to get the total count in code and then write it directly to excel
cheers