1
votes
javaaddpath('jxl.jar');
javaaddpath('MXL.jar');

import mymxl.*;
import jxl.*;   

filename = 'Test.xls';
data = {A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R}
xlwrite('./Test.xls',data);

http://www.mathworks.com/matlabcentral/fileexchange/37560-xlwrite---export-data-to-excel-from-matlab-on-mac-win

When I use this code in MATLAB R2014b the test.xls is created in the folder where the .m is. There is more code in the .m file, but I have not included as this is just defining variables.

When I compile this using the Application Compiler, the .xls file is not created. I have included all files that I got in the xlwrite download, when I compiled. I also included the ./ to indicate that the .xls should be written in the folder the app is. But still no file is written.

Can anyone advise me where I am going wrong when I open the app after compiling please?

2

2 Answers

0
votes

Maybe you should try changing the compiler you use (Matlab has problems with some compilers) with the mex -setup function, or try using the Matlab Coder, then convert the code to a C equivalent and compile it through a C compiler.

If nothing of that works, it just might be that the code cannot be interpreted outside of Matlab (maybe because of the libraries you use or something).

P.S. If the "A, B, C..." part of your code in
data = {A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R}
are not variables but chars, divided by commas and spaces, then you should replace that line with
data = {'A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R'};
If not, then just add a semicolon on the end of the line (just in case).

0
votes

First, make sure you have necessary poi library .jar files in your Matlab java path.

If it anyway does not work, running setupxlwrite() just before xlwrite command might solve the issue.