Hi everyone, I just installed excel(2016) in my Mac so I tried the below code just then it shows the following error.
ans =
1.6629028619989176615049162203409
xlswrite('a.xls','ans')
Warning: Could not start Excel server for export. XLSWRITE will attempt to write file in CSV format.

7 Comments

Paolo
Paolo on 21 Aug 2018
Edited: Paolo on 21 Aug 2018
You may use writetable, bearing in mind that:
On Linux® and Mac platforms, the xlsread function or the Import Tool cannot open spreadsheet files written by the writetable function.
MATLAB can only talk to Excel directly on MS Windows that has Office installed. For all other systems (Mac, Linux, Windows without Office) then xlswrite() is restricted to writing csv files.
Paolo's suggestion of writetable() is a good one: writetable() can create .xls and .xlsx files on all systems.
But I would like to use xlswrite.
madhan ravi
madhan ravi on 21 Aug 2018
Edited: madhan ravi on 21 Aug 2018
So @sir Walter you say xlswrite command won't work even if excel is installed?
Thank you paolo.
"xlswrite command won't work even if excel is installed?"
xlswrite() cannot communicate directly with Excel, except on MS Windows that has MS Office installed. COM object support is not compiled into the Mac version of Excel, so even if you were to install one of the COM libraries for Mac, it would not be possible to communicate with Excel that way.
This is a Microsoft restriction.
Thank you for the clear clarification Sir Walter

Sign in to comment.

 Accepted Answer

That's normal for a Mac. Also, you'll probably see a in one cell, n in the next cell to the right, and s in the next cell to the right. If you want the string 'ans' to go in as a string into one cell, put it in braces:
xlswrite('a.xlsx', {'ans'})
If you want the number 1.662 to go in, use ans without quotes
xlswrite('a.xlsx', ans)

4 Comments

>> a=ans
a =
1.6629028619989176615049162203409
>> xlswrite('a.xls',a)
Error using xlswrite (line 172)
Input data must be a numeric, cell, or logical
array.
>> xlswrite('a.xls',{'a'})
Warning: Could not start Excel server for export.
XLSWRITE will attempt to write file in CSV format.
We can tell from the number of digits in your variable a that your variable is class sym. You will need to use
xlswrite('a.xls', double(a))
If you were on Windows with Office installed then another option would be
xlswrite('a.xls', char(a))
Note that this will not have any effect on the fact that xlswrite on Mac or Linux can only write in csv format. There is no way to get around that fact. It is quite unlikely that Microsoft will ever create a version of Office for Mac that supports the COM interface that xlswrite() needs to be able to write in xls or xlsx format.
Thank you sirs @Image Analyst & @Walter.

Sign in to comment.

More Answers (0)

Products

Release

R2017a

Tags

Community Treasure Hunt

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

Start Hunting!