actxGetRunningServer and Excel Dynamic range
Mostra commenti meno recenti
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
Risposte (1)
Massimo Salese
il 9 Giu 2022
Categorie
Scopri di più su Matrix Indexing in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!