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 comentarios

Paolo
Paolo el 21 de Ag. de 2018
Editada: Paolo el 21 de Ag. de 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.
Walter Roberson
Walter Roberson el 21 de Ag. de 2018
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.
madhan ravi
madhan ravi el 21 de Ag. de 2018
But I would like to use xlswrite.
madhan ravi
madhan ravi el 21 de Ag. de 2018
Editada: madhan ravi el 21 de Ag. de 2018
So @sir Walter you say xlswrite command won't work even if excel is installed?
madhan ravi
madhan ravi el 21 de Ag. de 2018
Thank you paolo.
Walter Roberson
Walter Roberson el 21 de Ag. de 2018
"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.
madhan ravi
madhan ravi el 21 de Ag. de 2018
Thank you for the clear clarification Sir Walter

Iniciar sesión para comentar.

 Respuesta aceptada

Image Analyst
Image Analyst el 21 de Ag. de 2018

1 voto

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 comentarios

madhan ravi
madhan ravi el 21 de Ag. de 2018
>> a=ans
a =
1.6629028619989176615049162203409
>> xlswrite('a.xls',a)
Error using xlswrite (line 172)
Input data must be a numeric, cell, or logical
array.
madhan ravi
madhan ravi el 21 de Ag. de 2018
>> xlswrite('a.xls',{'a'})
Warning: Could not start Excel server for export.
XLSWRITE will attempt to write file in CSV format.
Walter Roberson
Walter Roberson el 21 de Ag. de 2018
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.
madhan ravi
madhan ravi el 21 de Ag. de 2018
Thank you sirs @Image Analyst & @Walter.

Iniciar sesión para comentar.

Más respuestas (0)

Productos

Versión

R2017a

Etiquetas

Preguntada:

el 21 de Ag. de 2018

Comentada:

el 21 de Ag. de 2018

Community Treasure Hunt

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

Start Hunting!

Translated by