如何使用Excel服务器端? [英] How do you use Excel server-side?

查看:157
本文介绍了如何使用Excel服务器端?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

客户端想要Web启用电子表格计算 - 用户指定某些单元格的值,然后在其他单元格中显示结果值。



(他们不想向用户显示一个电子表格式界面,这不是一个UI问题。)



他们有一个巨大的电子表格大量计算多张,多张。但是,最后,只有两件事情是重要的:(1)你将一个单元格中的数字放在一张纸上,(2)在另一张纸上的几个单元格中取出相应的数字。其余的是一个黑盒子。



我想向用户显示一个UI,输入他们想要的数字,然后我想以编程方式打开Excel文件,设置数字,告诉它重新计算,并读取结果。



这可能/可取吗?有没有一个商业组件使这更容易?他们的陷阱是我没有考虑的吗?



(我知道我可以使用Office Automation来做到这一点,但是我知道不建议在服务器端执行此操作,因为它尝试在用户的上下文中运行,等等)



编辑很多人都说我需要重新创建公式在代码中。然而,这将是非常复杂的。听起来这可能是一个解决的问题 - 有没有人知道某种类型的组件会为我做的?有人必须创建一些Excel-formula-to-code生成系统。我很乐意为此付款。



编辑/解决方案: SpreadsheetGear 是我正在寻找的。除此之外,它可以让您使用XLS作为计算器。您可以设置所选单元格的原始值,然后读出计算单元格的值。完全正在寻找。

解决方案

你绝对不想在服务器端使用互操作,这是不够的我们可以看到两个选项:



找出电子表格逻辑。这可能会使您在长期内使业务逻辑成为已知数量,并且在短期内您可能会发现电子表格中存在实际的错误(我遇到了多年使用的许多怪物电子表格,原来是简单的他们中的错误 - 每个人都假设答案必须正确)



评估 SpreadSheetGear.NET ,它基本上是替代互操作的,没有使用Excel(它复制了一大堆Excel的非可视化逻辑和IO在.NET中)。


A client wants to "Web-enable" a spreadsheet calculation -- the user to specify the values of certain cells, then show them the resulting values in other cells.

(They do NOT want to show the user a "spreadsheet-like" interface. This is not a UI question.)

They have a huge spreadsheet with lots of calculations over many, many sheets. But, in the end, only two things matter -- (1) you put numbers in a couple cells on one sheet, and (2) you get corresponding numbers off a couple cells in another sheet. The rest of it is a black box.

I want to present a UI to the user to enter the numbers they want, then I'd like to programatically open the Excel file, set the numbers, tell it to re-calc, and read the result out.

Is this possible/advisable? Is there a commercial component that makes this easier? Are their pitfalls I'm not considering?

(I know I can use Office Automation to do this, but I know it's not recommended to do that server-side, since it tries to run in the context of a user, etc.)

Edit: A lot of people are saying I need to recreate the formulas in code. However, this would be staggeringly complex. It sounds like this could be a solved problem -- does anyone know of a component of some type that would do it for me? Someone has to have created some "Excel-formula-to-code" generation system. I'd gladly pay for it.

Edit/Solution: SpreadsheetGear is what I was looking for. Among other things, it lets you use an XLS as a calculator. You can set the raw values of selected cells and then read out values of calculated cells. Exactly what I was looking for.

解决方案

You definitely don't want to be using interop on the server side, it's bad enough using it as a kludge on the client side.

I can see two options:

Figure out the spreadsheet logic. This may benefit you in the long term by making the business logic a known quantity, and in the short term you may find that there are actually bugs in the spreadsheet (I have encountered tons of monster spreadsheets used for years that turn out to have simple bugs in them - everyone just assumed the answers must be right)

Evaluate SpreadSheetGear.NET, which is basically a replacement for interop that does it all without Excel (it replicates a huge chunk of Excel's non-visual logic and IO in .NET)

这篇关于如何使用Excel服务器端?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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