Use message box to display Sum data in Excel file

Hello! i need to sum up one column in excel and display them in a message box as “total price is ____” how do i do that?

Hi @meli

Use Read Range Workbook to read your excel

create a variable called totalPrice as string

in assign activity, use

totalPrice = your_dt_variable.AsEnumerable.Sum(Function (x) CDbl(x(“Price”).toString.Trim).ToString

Then use it in your Message Box the totalPrice variable


what do i enter here

it says activity us only valid inside excel application scope

Use this one

Read Range Workbook from Workbook Activities

image

Then pass the full path of Excel File and the Sheet Name

Ah, i think i do not have that activity

Coud you share screenshot of project dependencies ?

Update your Excel Package activity and System Activity from Manage Packages:

do i copy the ‘x’ and CDbl?
i have no idea whats that, could you explain please?

Please use the workflow attached as reference

SumExcelColumn.zip (49.0 KB)

the code line is about LINQ

x acts like like a local variable representing the looped Datarow like
For each row in DataTable Acitvity

Also have a look here

1 Like

It says document invalid .(

Could you share some screenshot ?

By any chance do you have another workflow i can refer to?

Could you share what Studio version are you work with ?

@meli

  1. First drag excel application scope and give the excel path there …inside that activity drag read range and use it…that should solve the issue

To get sum use this in message box dt.AsEnumerable.Sum(function(x) cdbl(x("Price").ToString)).ToString

Where dt is the output of read range activity

Cheers

Hi @meli ,


Is this your expect output?
SumBox.zip (9.0 KB)
This is source
Regards

Yes!! this is what i need to get!! how do u do that

what do i write for ‘x’ or do i js keep it as ‘x’

I am sorrh :frowning: i am not sure