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

1 visualización (últimos 30 días)
Jens Peter Hansen
Jens Peter Hansen el 20 de Dic. de 2022
Respondida: Vijay el 28 de Dic. de 2022
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)?

Respuestas (1)

Vijay
Vijay el 28 de Dic. de 2022
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!

Categorías

Más información sobre Use COM Objects in MATLAB en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by