xlswrite problems - example from the documentation produces an error
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Suddenly xlswrite does not work anymore.
Even trying the example results in error:
filename = 'testdata.xlsx';
A = [12.7 5.02 -98 63.9 0 -.2 56];
xlswrite(filename,A)
Error using xlswrite (line 219)
I realize that this is probably not an outright matlab error, but maybe someone has seen it before. Tracing the execution the actual error is on this line:
[~, ExcelWorkbook] = openExcelWorkbook(Excel, file, readOnly);
and looking in the folder, I can see that the file was not created in the previous step.
I have MatLab 2015b and Excel is installed and working properly. I have tried to write to different folders but no luck. Could it be some kind of setting for what Excel is allowed to do? (Saving a file from Excel is of course no problem.)
I tried a previous version of MatLab, where I know that xlswrite has worked, but got the same error.
Help is appreciated.
2 Kommentare
Alen Alempijevic
am 29 Okt. 2016
Same here, Matlab 2015b, Excel 2016, fails on exact same line (just like yourself, have run example provided by Matlab).
MException with properties:
identifier: 'MATLAB:COM:E0'
message: ''
cause: {0x1 cell}
stack: [3x1 struct]
K>> exception.stack.file
C:\Program Files\MATLAB\R2015b\toolbox\matlab\iofun\private\openExcelWorkbook.m
C:\Program Files\MATLAB\R2015b\toolbox\matlab\iofun\xlswrite.m
C:\Program Files\MATLAB\R2015b\toolbox\matlab\iofun\xlswrite.m
K>> exception.stack.name
openExcelWorkbook
xlswrite/ExecuteWrite
xlswrite
K>> exception.stack.line
16
249
213
Antworten (1)
BAN
am 24 Sep. 2015
It doesn't throughout any error for me.
Try creating the file in WRITE mode. I think the file you created is in READ mode, that's why it's popping out that error.
Or try running the MATLAB in administrator mode.
3 Kommentare
Matthew Maltese
am 23 Jan. 2016
I am having this EXACT same problem. I executed the following code, copied directly from MATLAB documentation:
clear;
filename = 'testdata.xlsx';
A = {'Time', 'Temperature'; 12,98; 13,99; 14,97};
sheet = 2;
xlRange = 'E1';
xlswrite(filename,A,sheet,xlRange);
and here is the error text:
Warning: Could not start Excel server for export.
XLSWRITE will attempt to write file in CSV format.
> In xlswrite (line 174)
In test (line 6)
Error using xlswrite (line 187)
An error occurred on data export in CSV format.
Error in test (line 6)
xlswrite(filename,A,sheet,xlRange);
Caused by:
Error using dlmwrite (line 112)
The input cell array cannot be converted to a
matrix.
I am running MATLAB R2015b and Excel 2011 on MAC El Capitan.
Walter Roberson
am 23 Jan. 2016
Limitations:
If your computer does not have Excel for Windows®, or if the COM server (part of the typical installation of Excel) is unavailable, then the xlswrite function:
- Writes array A to a text file in comma-separated value (CSV) format. A must be a numeric matrix.
- Ignores the sheet and xlRange arguments.
----
Or written at greater length see http://uk.mathworks.com/matlabcentral/answers/264887-print-matlab-output-string-to-xlsx-spreadsheet#answer_207165
Siehe auch
Kategorien
Mehr zu Spreadsheets finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!