微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

如何对ClosedXML中的列值求和

如何解决如何对ClosedXML中的列值求和

我有9列,我想对ClosedXML中每一列的值求和。

这些是列:

foreach (Attivita attivita in listaSomthing)
{
     worksheet.Cell(index,1).Value = attivita.somthing;
     worksheet.Cell(index,2).Value = attivita.somthing;
     worksheet.Cell(index,3).Value = attivita.somthing;
     worksheet.Cell(index,4).Value = attivita.somthing;
     worksheet.Cell(index,5).Value = attivita.somthing;
     worksheet.Cell(index,6).Value = attivita.somthing;
     worksheet.Cell(index,7).Value = attivita.somthing;
     worksheet.Cell(index,8).Value = attivita.somthing;
     worksheet.Cell(index,9).Value = attivita.somthing;
 }

我需要对Cell(index,1),Cell(index,2)... Cell(index,9)求和。

这是表格:

enter image description here

在ClosedXML文档中找不到任何有用的信息。

有人可以帮助我吗?

谢谢!

解决方法

有两种方法:

  1. 在总计行中插入一个计算整个列的公式
  2. 在内存中计数,然后将值插入总单元格

对于第一种选择,您可以在文档内找到一些东西

https://github.com/ClosedXML/ClosedXML/wiki/Using-Formulas

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。