Click here to Skip to main content
14,644,548 members
Rate this:
Please Sign up or sign in to vote.
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
Updated 16-Oct-18 6:51am
Rate this:
Please Sign up or sign in to vote.

Solution 1

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.
Rate this:
Please Sign up or sign in to vote.

Solution 2

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.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100