varlmes
(Mesut Varlioglu)
November 20, 2020, 3:19pm
1
Hi there,
I am hoping to get some guidance. I am trying to sum a column called “Value” in Excel, only the numeric values. I read the file as DT but when I wrote the following code in Write Cell function:
“DT.AsEnumerable.Sum(Function(x) If(IsNumeric(x(“Value”).ToString.Trim),CDbl(x(“Value”).ToString.Trim),0)).ToString”
It gives the following error. I appreciate if someone offer assistance. thanks.
Cannot refer to an instance member of a class from within a shared method or shared member initializer without an explicit instance of the class.
3 Likes
ptrobot
November 20, 2020, 5:46pm
2
It’s complaining about the IsNumeric() function. To get it to work use either Information.IsNumeric() or myString.IsNumeric().
DT.AsEnumerable.Sum(Function(x) If(Information.IsNumeric(x("Value").ToString.Trim),CDbl(x("Value").ToString.Trim),0)).ToString
Or
DT.AsEnumerable.Sum(Function(x) If(x("Value").ToString.Trim.IsNumeric,CDbl(x("Value").ToString.Trim),0)).ToString
1 Like
varlmes
(Mesut Varlioglu)
November 20, 2020, 6:13pm
3
@ptrobot
Many thanks. Your suggestion works perfect. You saved me at least a day. Cheers.
1 Like
system
(system)
Closed
November 23, 2020, 6:24pm
4
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.