Excel导出到C# [英] Exporting Excel to C#

查看:109
本文介绍了Excel导出到C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要练成港口业务人员所使用的计算最终价格为C#,所以我以后可以用这个算法在Asp.Net应用程序文件。这件事我会做的不会是第一次,但今天它打我。也许Excel可以导出为C#。我不在乎,如果它看起来会比较难看,但是这仍然是东西开始。

I have to port excel file which business guys are using to calculate final price to C# so I can later use this algorithm in Asp.Net application. This is something I will be doing not for the first time, but today it hit me. Maybe Excel can export to C#. I don't care if it will look ugly, but this is still something to start with.

有一些Excel的插件,我可能标志着一些输入和输出细胞,这种附加将其导出到C#?

Is there some Excel plugin where I could mark some input and output cells and this add-it would export it to C#?

修改

我们的客户都Excel文件,其中聘用过的员工可以修改一些领域和看到最终的价格在另一个领域。 Excel文件没有任何的VB,但使用标准的数学函数的函数来计算价格。

Our client have Excel file where employes can modify some fields and see final price in another field. Excel file doesn't have any VB, but uses standard mathematical functions functions to calculate the price.

想象Excel中使用计算现场保价文件。

Imagine excel file used to calculate live insurance price.


  • Excel文件中有空白单元格公司的雇主填写:客户年龄,不良的生活习惯,保价,保险期限,折扣等

  • Excel文件中有许多细胞常数。常量是最有可能的系数(像几年保险合同号的价格系数签署了该年以上的少的价格)

  • Excel文件中有许多细胞中间值

  • Excel文件与最终保险公司的价格一个输出单元为整个周期

  • Excel file has empty cells company employer has to fill: client age, bad habits, insurance price, insurance period, discount and so on
  • Excel file has many cells with constants. Constants are most likely coeficient (like price coefficient for number of years insurance contract is signed for for. The more years the less is the price)
  • Excel file has many cells with intermediate values
  • Excel file have one output cell with final insurance price for the whole period

我有什么做的是用Excel制作文件到C#端口计算。

What I have to do is to port calculations made with excel file to C#.

推荐答案

严格地说,它并没有做出很大的意义导出Excel为C#。这是因为你通常希望从Excel导出的数据的和C#是的编程语言的。也许你正在寻找的问题是,?我怎样才能使Excel数据提供给C#编写的程序

Strictly speaking, it doesn't make a lot of sense to "export Excel to C#." This is because what you generally wish to export from Excel is data and C# is a programming language. Perhaps the question you're looking for is, "How can I make Excel data available to a program written in C#?"

我用的在C#中的Excel互操作使用此写了的为出发点从C#编写的应用程序读取Excel数据。这可能是一个良好的开端弄清楚如何在C#中的Excel数据可见。

I used this write-up on C# Excel Interop Use as a starting point for reading Excel data from an application written in C#. That might be a good place to start to figure out how to make Excel data visible in C#.

另一种方式来诠释你的问题是,要在视觉转换基本的Excel工作簿到C#中的应用程序(VBA)代码。如果是这种情况,你有几种选择:

The other way to interpret your question is that you want to convert the Visual Basic for Applications (VBA) code within an Excel workbook to C#. If this is this case, you have a few options:


  • 如果它不是一个很大的代码,它很可能是最容易简单地转换算法和程序之一从VBA到C#的时候。

  • 这是一个非常丑陋的方式,但你可以导入VBA代码到Visual Studio和它上变频到VB.NET。然后,你可以使用反射反映代码为C#。当然,这假定VBA代码不紧密耦合到个别Excel对象(表,列,单元格范围等);如果它像Excel的业务应用我已经看到了(和书面)什么,这是不太可能出现这种情况。

  • 对于绝对的巨大的与应用分离代码,你可能会考虑VB6到.NET迁移解决方案,如 VB迁移合作伙伴。我不知道这些解决方案将如何工作,如果你有紧密耦合的代码,但如果工作簿是巨大的,它可能是看一下。

  • If it's not a lot of code, it probably would be easiest to simply convert the algorithms and procedures one at a time from VBA to C#.
  • This is a pretty ugly way, but you could import the VBA code into Visual Studio and upconvert it to VB.NET. Then you could use reflector to reflect the code to C#. Granted, this assumes that the VBA code is not tightly coupled to individual Excel objects (worksheets, rows, cells, ranges, etc.); if it's anything like the Excel "business applications" I've seen (and written), that's not likely to be the case.
  • For absolutely huge applications with decoupled code, you might consider VB6 to .NET migration solutions, like VB Migration Partner. I'm not sure how well these solutions will work if you have tightly coupled code, but if the workbook is huge, it might be something to look at.

这篇关于Excel导出到C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆