How can I get only visible cells using range.get_Value?

S

shatol

Hi All!

I’ve a code on C# that reads the data from Excel’s spreadsheet.
I use Excel.Worksheet.get_Range method to get a Excel.Range object like this:

Excel.Range range = Worksheet.get_Range("A1", Missing.Value);

After I got the range I read the data into a multi-dimensional array as
following:

Object[,] saRet;
saRet = (System.Object[,])range.get_Value(Missing.Value);

Everything works fine until I want to get only visible cells from the
spreadsheet. So I use the code:

range = range.SpecialCells(xlCellTypeVisible, Missing.Value);

When I try to invoke the range.get_Value(Missing.Value) method I got an
exception that states it cannot cast a string to Object[,].

So, I’m confused about what SpecialCells(xlCellTypeVisible) returns.
Could anyone provide me a hint how to get only visible range from the
spreadsheet?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top