xlswrite problems - example from the documentation produces an error

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

What is the error message?
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

Melden Sie sich an, um zu kommentieren.

Antworten (1)

BAN
BAN am 24 Sep. 2015

0 Stimmen

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

No luck running in administrator mode. It works perfectly on another machine however (same windows, matlab and excel versions). Being an example from the documentation, it really should run on any system, so I think there must be some setting related to Excel, with the effect that Excel is not allowed to write files. Does that ring a bell for anyone? Or, put the other way around, what is necessary in terms of excel settings etc. for the script xlswrite to work?
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.
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.
----

Melden Sie sich an, um zu kommentieren.

Tags

Gefragt:

ULJ
am 23 Sep. 2015

Kommentiert:

am 29 Okt. 2016

Community Treasure Hunt

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

Start Hunting!

Translated by