How can I pass a variable from MATLAB to Excel using DDE by passing only the first cell of the Excel sheet?
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
MathWorks Support Team
le 27 Juin 2009
Modifié(e) : MathWorks Support Team
le 14 Oct 2021
How can I pass a variable from MATLAB to Excel using DDE by passing only the first cell of the Excel sheet?
I would like to do something like this:
channel = ddeinit('excel', 'sheet1');
data = rand(5);
range = 'r1c1' % I do not know the end row and column of data
rc = ddepoke(channel, range, data) % This will only populate one cell not the whole data into Excel
Réponse acceptée
MathWorks Support Team
le 11 Oct 2021
Modifié(e) : MathWorks Support Team
le 14 Oct 2021
There is no direct API available to do this. You can write a small function to achieve your goal. For example:
function rc = ddepokeUnlimited(channel, startRow, startCol, data)
% This function will take in the startRow number and start Column
% number and write the data provided to the channel using DDE. This
% function will calculate the size range internally
[m n] = size(data);
endRow = startRow + m -1;
endCol = startCol + n -1;
range = ['r' num2str(startRow) 'c' num2str(starCol)...
':r' num2str(endRow) 'c' num2str(endCol) ];
rc = ddepoke(channel, range, data);
Note that MATLAB supports ActiveX protocol. You can use MATLAB as an ActiveX server or as an ActiveX client. You have more functionality available via ActiveX as compared to DDE. Please refer to Chapter 7 of the External Interfaces Users Guide for more information. You can view the HTML format of this section at the following URL:
https://www.mathworks.com/help/matlab/matlab_external/supported-client-server-configurations.html
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur ActiveX dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!