I am trying to build .NET Windows form application to manipulate data is
specified Excel spreadsheets, but I am running short on information and my
searches of MSDN aren't finding the data I need.
I really don't know if it is better to ask here in the C# group or some
Office group. I am trying to write the code in C#, but this requires
knowledge of the Office Excel Object model.
So far I have:
* Figured out how to create an Excel Application from my Windows Form
* Used the MSOffice FileOpen dialog to open a selected workbook.
* Assigned both the workbook and worksheets to my application variables.
* Created a new worksheet, positiioned and named it.
The code below shows one way to set range variables, but I want more
interaction between the Excel application and my program. I want to be able
to select a range in the Excel application and to capture that range in the
windows form. I want to tell the application by pointing to it that this is
the data I want the application to process. If I cant find out how to do
that I should be able to get much farther.
// C#
rng = ws.get_Range("A1",Type.Missing);
rng = ws.get_Range("A1:B12",Type.Missing);
For all the talk of event driven programming I don't seem to be able to find
enough information on Excel events. there must be events related to cell or
range selection, cell activation, etc. So far all I have found are some
events at either the application level or the worksheet level, but not the
ones I would think are there.
Does anyone know how you can capture the cell addresses or range definitions
in .NET?
What I'd like to do is to move some of the worksheet data into an array or
arraylist object or two and to process it there. Then I'd move it back to
another worksheet.