Is it possible to copy a figure into excel using a WebApp server?

2 次查看(过去 30 天)
I can successfully copy a figure into an exel sheet using below function:
function xlswritefig(hFig,filename,sheetname,range)
copygraphics(hFig)
% Connect to Ecel
Excel = actxserver('Excel.Application');
% Open file and active worksheet
op = invoke(Excel.Workbooks, 'open', filename);
Sheets = Excel.ActiveWorkBook.Sheets;
n_sheets = Sheets.Count;
Sheets.Add([], Sheets.Item(n_sheets));
Sheets.Item(n_sheets+1).Name = sheetname;
target_sheet = get(Sheets, 'Item', sheetname);
invoke(target_sheet, 'Activate');
Activesheet = Excel.Activesheet;
% Paste to specified cell
Paste(Activesheet,get(Activesheet,'Range',range))
% Save and quit
invoke(op, 'Save');
invoke(Excel, 'Quit');
delete(Excel)
close(filename)
However, is it also possible to run this function (or actxserver) from a Web App if I install Excel on my virtuel machine (MS Azure)?

回答(1 个)

Vijay
Vijay 2022-12-28
Yes, you can create a create a COM server on your AZURE machine by supplying IP address of the remote machine from your MATLAB program.
Example
c = actxserver(progid,'machine',machineName)
%‘machinename' can be IP address of a remote computer or a name that can be resolved on your network.
For more information, please go through links below.
  1. Create COM server - MATLAB actxserver - MathWorks India
  2. How to run excel macro via MATLAB on another pc - MATLAB Answers - MATLAB Central (mathworks.com)
Hope that helps!

类别

Help CenterFile Exchange 中查找有关 Use COM Objects in MATLAB 的更多信息

产品


版本

R2022b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by