如何使用closedxml从excel电子表格中获取活动单元格 [英] How to get the active cell from excel spreadsheet with closedxml

查看:494
本文介绍了如何使用closedxml从excel电子表格中获取活动单元格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在使用Microsoft.Office.Interop.Excel dll在我的离线C#程序中使用Excel。当我转向ASP.Net网站应用程序时,我发现由于服务器端安全性问题,这个dll不再有效。这就是我决定开始使用ClosedXML的原因。我发现ClosedXML有多种用途,但有一个问题。



如何从电子表格中检索活动/选定的单元格?



我想添加此功能是因为我的用户需要点击电子表格并使用C#代码计算的值更新单元格。



我尝试过的内容:



我尝试过使用sheet.RangeUsed,但这给出了整张表的范围

I've been using the Microsoft.Office.Interop.Excel dll to work with Excel in my offline C# programs. When I made the move to ASP.Net website applications, I found that this dll no longer worked because of issues with server-side security. This is why I decided to start using ClosedXML. I've found multiple uses for ClosedXML but there is one issue.

How would I retrieve the active/selected cell from the spreadsheet?

I am trying to add this feature because my users need to click on the spreadsheet and update cells with values calculated by the C# code.

What I have tried:

I have tried using sheet.RangeUsed, but that gives the range of entire sheet

推荐答案

你不能。



ClosedXML不处理交互式Excel实例。它只是读取和修改文件的内容。用户无法查看您正在操作的文件或与之交互。



不,您也无法使用Office Interop执行此操作。您的代码在服务器上运行,因此如果您启动了交互式Excel实例,用户将永远不会看到它。
You can't.

ClosedXML doesn't deal with an interactive Excel instance. It simply reads and modifies the contents of the file. The user can't see or interact with the file you're manipulating.

And no, you can't use Office Interop to do that either. Your code is running on the server, so if you brought up an interactive Excel instance, the user would never see it.


当您在服务器上使用Excel工作表时,没有诸如活动单元之类的东西。



由于服务器端代码也无法与客户端上的Excel实例进行交互。
When you working with the Excel sheet on the server, there is no such thing as the "active cell".

Since server-side code also has no way of interacting with an instance of Excel on the client.


这篇关于如何使用closedxml从excel电子表格中获取活动单元格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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