actxGetRunningServer and Excel Dynamic range
Show older comments
Hi guys,
I'm usign an ExcelSheet on which historic data from broker is coming :

I use the following matlab code:
format bank;
prvClose = 13380;
% start observation date od stocastic process
prvDate = "2022-05-09";
% last date
expDate = "2022-06-17";
dayToExp = datenum(expDate) - datenum(prvDate);
dayToExp_1 = 1;
% Attach a Running xcel object.
e= actxGetRunningServer('Excel.Application');
eWkbk = e.ActiveWorkbook;
eSheet = eWkbk.Sheets.Item(1);
dat_range = 'C7#'; %<<<<---- DYNAMIC RANGE NOTATION
dataTable = eSheet.Range(dat_range);
dataTable.Value
When I check the loaded data I see that the dynamic range C7# is not loaded and only the first cell C7 is loaded with value 0
ans =
0
K>>
I was expecting to see a table (or an array) with values in C7:C4316
Now as a problem solver I though .."never mind I know the number of rows so i use the full range notation, and the code was simply modified in this way :
format bank;
prvClose = 13380;
% start observation date od stocastic process
prvDate = "2022-05-09";
% last date
expDate = "2022-06-17";
dayToExp = datenum(expDate) - datenum(prvDate);
dayToExp_1 = 1;
% Attach a Running xcel object.
e= actxGetRunningServer('Excel.Application');
eWkbk = e.ActiveWorkbook;
eSheet = eWkbk.Sheets.Item(1);
dat_range = 'C7:C4316'; %<<<<<-----FUL RANGE NOTATION
dataTable = eSheet.Range(dat_range);
dataTable.Value
And look the answer !!:
ans =
4310×1 cell array
{[ 0]}
{[NaN]}
{[NaN]}
{[NaN]}
{[NaN]}
{[NaN]}
{[NaN]}
{[NaN]}
{[NaN]}
{[NaN]}
{[NaN]}
There is no way to read values inside a dynamic range .
May be I'm missing something, any hint ?
Massimo
Answers (1)
Massimo Salese
on 9 Jun 2022
Categories
Find more on Matrix Indexing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!