I’m trying to write a cell array and I’m using these line of codes:
[filename,pathname] = uiputfile('.xlsx','choose your file');
fileToWrite = fullfile(pathname,filename);
fileID = fopen(fileToWrite,'w');
**xlswrite(fileToWrite,cellul);**
fclose(fileID);
I receive this error at the bold line
??? Error using ==> xlswrite at 213
Invoke Error, Dispatch Exception:
Source: Microsoft Office Excel
Description: Excel cannot open the file ‘eee.xlsx’ because the file format or file extension is not valid.
Verify that the file has not been corrupted and that the file extension matches the format of the file.
fopenandfcloseare not needed and the former is the cause of your problem. Basicallyxlswritestarts an ActiveX server which tries to open and write to the spreadsheet. However the file is already acquired by MATLAB throughfopen, soxlswriteis unable to open the spreadsheet.