用于处理 Excel 数据的接受集合

发布于 2024-12-27 06:59:22 字数 288 浏览 2 评论 0原文

我有一堆数据正在提取到我的应用程序中,坦率地说,最好将其表示为 Excel 电子表格。我的意思是:

  • 有很多列需​​要“总结”
  • 有合理数量的数据(基本上是一张数字)

目前这只是数据库中的原始数据,但我还有一个电子表格显示此数据(以及我需要在应用程序中复制的公式)。

目前,我刚刚获得了每行的 List,但是我相信可能有更好的集合来存储这种类型的数据。我基本上需要能够轻松地操纵这些数字。

有什么建议吗?

I have a bunch of data that I'm pulling into my application which frankly is best represented as an Excel spreadsheet. By this I mean:

  • There are a lot of columns which need 'summing up'
  • There is a reasonable amount of data (basically a sheet of numbers)

At the moment this is just raw data in a database, but I also have a spreadsheet which shows this data (along with formulas that I need to replicate in my app).

At the moment I've just got a List<of T> of each row, however I believe there might be a better collection for storing data of this type. I basically need to be able to manipulate these numbers easily.

Any suggestions?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

怎会甘心 2025-01-03 06:59:22

一种选择是使用 DataTable 它也有内置聚合方法

例如(来自 MSDN):

// Presumes a DataTable named "Orders" that has a column named "Total."
DataTable table;
table = dataSet.Tables["Orders"];

// Declare an object variable.
object sumObject;
sumObject = table.Compute("Sum(Total)", "EmpID = 5");

另一个优点是它支持使用 LINQ-To 进行 LINQ 查询-数据集

One option would be to use a DataTable which also has a builtin aggregation method.

For example(from MSDN):

// Presumes a DataTable named "Orders" that has a column named "Total."
DataTable table;
table = dataSet.Tables["Orders"];

// Declare an object variable.
object sumObject;
sumObject = table.Compute("Sum(Total)", "EmpID = 5");

Another advantage is that it supports LINQ queries with LINQ-To-DataSet.

┈┾☆殇 2025-01-03 06:59:22

如果您的“excel 数据”可以用模型表示,我只会使用模型。例如,如下所示:

public class ExcelModel()
{
     public string Id { get; set; }
     public double value1 { get; set; }
     public int value1 { get; set; }
}

然后您可以轻松创建一个 List,并获取总数,如下所示:

List<ExcelModel> model = repository.GetAll(); //just an example
var total = model.sum(x => x.value1);

If your "excel data" can be represented in models, I'd just use models. For example like so:

public class ExcelModel()
{
     public string Id { get; set; }
     public double value1 { get; set; }
     public int value1 { get; set; }
}

Then you can easily create a List<ExcelModel>, and get the total like so:

List<ExcelModel> model = repository.GetAll(); //just an example
var total = model.sum(x => x.value1);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文