Embed Matlab Code into excel

7 次查看(过去 30 天)
Alberto B
Alberto B 2015-9-20
编辑: Alberto B 2015-9-20

Hello, I'm having trouble in embedding matlab code into excel. The code receives input arguments from a vba function and return the output to the same vba function. I can create the .xla file and the related files but it seems that this method is machine dependent.

For example, if I create a simple function like this:

function q = somma(w,e)
q=w+e;
end

and then I try to create an Excel AddInn through the matlab compiler it fails at the end without creating any installer. But If I use the command:

mcc -W 'excel:somma,Class1,1.0' -T link:lib -b -d D:\Al\MATLAB\somma -v class{Class1:D:\Al\MATLAB\somma.m}

it creates these files:

  • Class1_com.cpp
  • Class1_com.hpp
  • dlldata.c
  • mccExcludedFiles.log
  • mwcomtypes.h
  • mwcomtypes_i.c
  • mwcomtypes_p.c
  • readme.txt
  • requiredMCRProducts.txt
  • somma.bas
  • somma.def
  • somma.rc
  • somma.xla
  • somma_1_0.dll
  • somma_1_0.exp
  • somma_1_0.lib
  • somma_dll.cpp
  • somma_idl.h
  • somma_idl.idl
  • somma_idl.tlb
  • somma_idl_i.c
  • somma_idl_p.c

If I open the .xla or import .bas into my worbook the function works but it's machine dependent. If I try to add the .dll as a COM object into my workbook Excel says that "it is not a valid Office AddInn". If instead I use this command:

mcc -W 'com:somma,Class1,1.0' -T link:lib -d D:\Al\MATLAB\somma -v class{Class1:D:\Al\MATLAB\somma.m}

I get more or less the same files (not the .xla and .bas) but I have the same problem with the .dll.

Is there any way to achieve what I want? Do I have to install the MATLAB runtime? but I would like that the people that will use my Excel file, just needed it and nothing more. Is it possible?

Many thanks

AL

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Excel Add-Ins 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by