ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How can I get only visible cells using range.get_Value? (https://www.excelbanter.com/excel-programming/439593-how-can-i-get-only-visible-cells-using-range-get_value.html)

shatol

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

Ive a code on C# that reads the data from Excels 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, Im confused about what SpecialCells(xlCellTypeVisible) returns.
Could anyone provide me a hint how to get only visible range from the
spreadsheet?



All times are GMT +1. The time now is 01:43 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com