Get an array of values from xlfGetCell

123 views
Skip to first unread message

Andrey Eremenko

unread,
Jun 15, 2021, 12:32:28 AM6/15/21
to Excel-DNA
Hi all,

I am trying to get all values from a range using the following code:

ExcelReference excelReference = new ExcelReference(0, 99, 0, 99);               
var value = XlCall.Excel(XlCall.xlfGetCell, 53, excelReference);

But I only get a single value from the top left of the range. Is there a way to get all values?

Thanks!

Govert van Drimmelen

unread,
Jun 15, 2021, 5:29:47 AM6/15/21
to exce...@googlegroups.com
--------------------------------------------------
Excel-DNA is now registered on GitHub Sponsors.
You can access direct Excel-DNA support with easy billing through a corporate GitHub account.
--------------------------------------------------

Hi Andrey,

The macro help documentation says:

GET.CELL

Macro Sheets Only

Returns information about the formatting, location, or contents of a cell. Use GET.CELL in a macro whose behavior is determined by the status of a particular cell.


So I guess it really does only work for a single cell.

If you're looking for the underlying values and not the displayed text, you can just do "ExcelReference.GetValue()" and that will give you an array.


This also matches (somewhat) the result of the COM object model property "Range.Text", for which we have this:


The Text property is most often used for a range of one cell. If the range includes more than one cell, the Text property returns Null, except when all the cells in the range have identical contents and formats.


-Govert



--
You received this message because you are subscribed to the Google Groups "Excel-DNA" group.
To unsubscribe from this group and stop receiving emails from it, send an email to exceldna+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/exceldna/a9436b63-4118-48da-8144-886534687b7cn%40googlegroups.com.

Andrey Eremenko

unread,
Jun 15, 2021, 8:02:08 PM6/15/21
to Excel-DNA
Financial Applications Using Excel Add-in Development in C/C++ book says that it should be possible to get information about ranges as well.

Screenshot from page 291:

Screenshot 2021-06-16 095947.png

peter....@gmail.com

unread,
Jun 16, 2021, 8:00:22 AM6/16/21
to exce...@googlegroups.com

Hi Andrey

The book does say that just the “ ..top left cell.. “ value is returned for a range.

 

Peter

 

From: exce...@googlegroups.com <exce...@googlegroups.com> On Behalf Of Andrey Eremenko
Sent: 16 June 2021 01:02
To: Excel-DNA <exce...@googlegroups.com>
Subject: Re: [ExcelDna] Get an array of values from xlfGetCell

 

Financial Applications Using Excel Add-in Development in C/C++ book says that it should be possible to get information about ranges as well.

 

Screenshot from page 291:

 

image001.png
image002.png
Reply all
Reply to author
Forward
0 new messages