wpf 如何在Excel中计算总和

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/26337471/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-13 12:36:16  来源:igfitidea点击:

how to calculate total Sum in Excel

c#wpfexcel-formula

提问by Raj De Inno

I am producing last report for my venture. I need to ascertain the Sum of aggregate cells in my excel sheet. I have done the accompanying code. Be that as it may, its not computing the qualities.. Here is my code:

我正在为我的企业制作最后一份报告。我需要确定我的 excel 表中的聚合单元格总和。我已经完成了随附的代码。尽管如此,它不计算质量..这是我的代码:

        Worksheet.Cells[20, 16].Formula =
                  "Sum(" + Worksheet.Cells[6, 16].Value + 
                 ":" + Worksheet.Cells[rowIndex, 16].Value + ")";

I need to figure the Cell No 16's Sum esteem and I will show it into Cells[20,16]. Its not working. Anybody help me to settle this?

我需要计算第 16 号单元格的总和值,然后将其显示到单元格 [20,16] 中。它不工作。有人帮我解决这个问题吗?

回答by Fratyx

Change the two occurrences of .Valuein your code to .Address.

.Value将代码中出现的两次更改为.Address

Update... and add a =before the Sum:

更新... 并在=之前添加一个Sum

Worksheet.Cells[20, 16].Formula =
        "=Sum(" + Worksheet.Cells[6, 16].Address + 
        ":" + Worksheet.Cells[rowIndex, 16].Address + ")";