How can I pass a variable from MATLAB to Excel using DDE by passing only the first cell of the Excel sheet?
3 ビュー (過去 30 日間)
古いコメントを表示
MathWorks Support Team
2009 年 6 月 27 日
編集済み: MathWorks Support Team
2021 年 10 月 14 日
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
採用された回答
MathWorks Support Team
2021 年 10 月 11 日
編集済み: MathWorks Support Team
2021 年 10 月 14 日
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 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で ActiveX についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!