Question about deploying an Excel Add-In using MATLAB Library compiler
Ältere Kommentare anzeigen
Hello, I am trying to build an excel add-in from Matlab that can take in cells as inputs, search for specific columns, and print the data to a text file. I was able to compile the function using the library compiler and import the add-in to excel as explained in the link below: https://www.mathworks.com/videos/getting-started-excel-add-ins-using-matlab-compiler-100089.html My code looks something like this:
function [ flag ] = test(x)
data = x;
headers = data(1,:);
CH_Type = data(:,1);
c = clock;
c = fix(c);
filename = fullfile(pwd,'test_file.txt');
fid = fopen(filename,'w');
fprintf(fid,'<DATE>%i/%i/%i \t %02i:%02i:%02i</DATE>\n',c(1),c(2),c(3),c(4),c(5),c(6));
fclose(fid);
flag = {'Successfully Completed!'};
end
When I package this function as an excel add-in and call it from within excel, I get the following error: "Error in test.Class1.1_0:Invalid File Identifier. Use fopen to generate a valid file identifier." After searching on MATLAB forums, I found that the function fopen behaves differently when deployed in a standalone application. I thought that using the pwd command with fopen would force the application to get the right fid because I put the text file with the same name in the folder with the excel add in as well as the actual excel sheet. However, the error persists. I am not sure if I am doing something wrong. Is there a workaround to this error? Thanks in advance. Shyam
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Data Export to MATLAB finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!