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 个评论

Paolo
Paolo 2018-8-21
编辑:Paolo 2018-8-21
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 2018-8-21
编辑:madhan ravi 2018-8-21
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

请先登录,再进行评论。

 采纳的回答

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 个评论

>> 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.

请先登录,再进行评论。

更多回答(0 个)

产品

版本

R2017a

标签

Community Treasure Hunt

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

Start Hunting!

Translated by