How to have an excel addin read rows from a worksheet until no more data?
Posted
by user169867
on Stack Overflow
See other posts from Stack Overflow
or by user169867
Published on 2010-05-08T17:34:00Z
Indexed on
2010/05/08
17:38 UTC
Read the original article
Hit count: 201
I've started writing a Com addin for Excel 2003 using C#. I'm looking for a code example showing how to read in cell data from the active worksheet. I've seen that you can write code like this:
Excel.Range firstCell = ws.get_Range("A1", Type.Missing);
Excel.Range lastCell = ws.get_Range("A10", Type.Missing);
Excel.Range worksheetCells = ws.get_Range(firstCell, lastCell);
to grab a range of cells. What I could use help with is how to read the cell data when you don't know how many rows of data there are. I may be able to determine the starting row that the data will be begin at, but there will be an unkown number of rows of data to read.
Could someone provide me w/ an example of how to read rows from the worksheet until you come across a row of empty cells?
Also does anyone know how to grab the range of cells the user has selected?
Any help would be greatly appreciated. This seems like a powerful dev tool, but I'm having trouble finding detailed documentation to help me learn it :)
© Stack Overflow or respective owner