Excel column is clicked in VSTO - c#

Is there a way to know if a column has been clicked in Excel? I'm using VSTO and .NET 4. I can't find any events for this kind of situation.

It sounds like you're thinking of Worksheet.SelectionChange.
See also: How to get the selected range.

Related

Excel C# VSTO - how to know whether a user has changed a formula?

How can one tell whether a user has changed/edited/deleted/added a formula in an Excel worksheet using C# VSTO?
So far, what I have been thinking about is to attach an event handler which can tell me whether the user is changing a cell. But even this approach is problematic because existing events relating to user editing cells do not seem to be able to tell you the previous and the new value, so I do not really know if an old formula is being overwritten. What is the right approach to this question?
How about you handle SheetSelectionChange, cache the selection values and then when (and if) SheetChange is raised you compare the new value(s) with the old.

Cells format event/hook

I worked on VSTO C# Excel 2013. I tried and searched many approaches to find a way to trigger more events.
One of the important events I need is, cells formatted event (changing background color, merging cells.
Is there any way?
There is no such event. Your main events are for Workbook and Worksheet objects. Intellisense is presumably giving them all to you. If not, check out the MS reference for Worksheet events. There is a similar list for Workbook. These are also the same as the events available within the VBA editor inside Excel.
If you want to cheat and make an event, it involves watching all of the cells and detecting the change yourself using the Worksheet_SelectionChange event. See related: How to detect changes in cell format?
Note that approach will not work if you are trying to detect format changes that are effected by your code instead of the user (unless of course you are using Select in your code which would be inadvisable).

Excel <-> C# - how do I call into a C# library from Excel?

We have a couple of spreadsheets here that we populate with some data and do some formatting using Microsoft.Office.Interop.Excel.
Now that part is all good - it's something along the lines of what is done here: Write to Excel example.
What I'd like to do is:
Add a button inside the spreadsheet, bound to a macro.
When the user clicks the button, the macro fires - we grab some parameters from the cells and pass those to the C# function. That code does all the heavy lifting, populates the spreadsheet as above, etc.
What I don't understand how to do is that second step - I can't see a way to actually pass parameters and call into C# directly.
As it stands now, I can call a C# console application and pass command line parameters into it... but that seems a bit wrong, I'd have thought there would be some better way - but I can't seem to find it!
Coopernick,
It looks like you need to develop an Excel add-in and move the VBA code on the add-in rails. See Walkthrough: Creating Your First Application-Level Add-in for Excel to get started quickly. You may consider an Excel add-in as a regular .Net application where you can use any components and libraries.
You may find the Excel Solutions section in MSDN helpful.

Telerik RadGrid ExportToExcel not working

I have a radgrid and I want to use the built-in functionality to export the data in the grid to a spreadsheet. I remember a time when I ran the code and it worked, but right now when the call is made, nothing happens.
Anyone experience this problem or have any suggestions?
Thanks very much in advance!
I suggest posting this question in the Telerik Forums or checking out the code in the demo.
Please include at least some of your code unless you want people to just guess at what might be wrong. My first guess would be that you are binding manually to the radgrid with a dataset or datatable and are not binding the data before trying to export.

monitoring a range of cells inside of excel 2007 with C#/VSTO

I have a row in excel I'd like to translate into an ObserveableCollection in C# for binding/event purposes, so all accessor classes know they're getting the latest data from the source excel sheet. How would this be done?
Clarification: I'm using an excel add-in project, not a workbook project, so am not sure whether or not XMLMappedRange Controls are an option.
Using VSTO you have a few options:
From the Excel.Worksheet class, you can access the Worksheet.Change event.
From the NamedRange class, you can access the NamedRange.Change event (which uses the Microsoft.Office.Interop.Excel.DocEvents_ChangeEventHandler delegate that you mentioned in another comment).
The NamedRange class also supports simple, one-way databinding via the DataBindings property, an example of which is shown in the discussion How do I bind an array to a NamedRange.
Another possibility is the XmlMappedRange control, which also supports databinding.
A good primer on using the NamedRange and XmlMappedRange can be found here: The VSTO Programming Model. A decent walkthrough using the NamedRange can be found in the Visual Studio Tools for Office (VSTO) 2005 Guided Tour.
I hope this helps...
Mike
You can add OnChanged in your range changed event.

Categories

Resources