export from matlab to excel

sir help me about the commad how can i export my result in to the excel file.

回答 (3 件)

stozaki
stozaki 2020 年 2 月 1 日
編集済み: stozaki 2020 年 2 月 1 日

0 投票

You can use writematrix or xlswrite.
Please see following URL.
R2019a or later : writematrix
example code
M = magic(5)
writematrix(M,'M.xlsx','Sheet',2,'Range','A3:E8')
R2018b or earlier : xlswrite
exanple code
filename = 'testdata.xlsx';
A = [12.7 5.02 -98 63.9 0 -.2 56];
xlswrite(filename,A)

1 件のコメント

Chaudhary P Patel
Chaudhary P Patel 2020 年 2 月 1 日
sir i did not get your point please clearify it with one example and i am using R2018a.

サインインしてコメントする。

Chaudhary P Patel
Chaudhary P Patel 2020 年 2 月 1 日

0 投票

sir, it is not working,
>> filename = 'testdata.xlsx';
A = [12.7 5.02 -98 63.9 0 -.2 56];
xlswrite(filename,A)
Warning: Could not start Excel server for export.
XLSWRITE will attempt to write file in CSV format.
> In xlswrite (line 181)
>>

7 件のコメント

stozaki
stozaki 2020 年 2 月 1 日
What OS platform do you use? Win10, Mac OS or Linux?
Chaudhary P Patel
Chaudhary P Patel 2020 年 2 月 1 日
windows 10
Chaudhary P Patel
Chaudhary P Patel 2020 年 2 月 1 日
sir, resolve the problem. please
stozaki
stozaki 2020 年 2 月 1 日
I tested following script in the R2018a.
I was able to write the data to the excel file without any problems.
filename = 'testdata.xlsx';
A = [12.7 5.02 -98 63.9 0 -.2 56];
xlswrite(filename,A)
I attach it as a .gif.
xlswriteR2018a_loop.gif
Chaudhary P Patel
Chaudhary P Patel 2020 年 2 月 1 日
sir, now i am also getting by name of testeddata.csv file but it is showing some warning. what is its mean
Warning: Could not start Excel server for export.
XLSWRITE will attempt to write file in CSV format.
> In xlswrite (line 181)
In Untitled4 (line 3)
stozaki
stozaki 2020 年 2 月 1 日
編集済み: stozaki 2020 年 2 月 1 日
I ran the same script on the following versions, but no problem occurred. And I can't reproduce the warninig.
  • R2015a
  • R2018a
  • R2019b
Workaround: Open the .csv in Microsoft Excel. And SaveAs .xlsx.
If possible, can you reinstall R2018a and try it out?
Image Analyst
Image Analyst 2020 年 2 月 1 日
Are you 100% sure you have Excel installed? Perhaps that might cause a problem.
If you don't have Excel on that computer, use csvwrite() to write a CSV file, which can be opened by WordPad.
Why are you not upgrading to R2019b, where you can get writecell()? It's much, much faster in my experience than xlswrite().

サインインしてコメントする。

Chaudhary P Patel
Chaudhary P Patel 2020 年 2 月 2 日

0 投票

sir, i have excel and file is also opening in excel only thing is that i am not getting why this warning is showing there.

15 件のコメント

stozaki
stozaki 2020 年 2 月 2 日
編集済み: stozaki 2020 年 2 月 2 日
Do you run the following test script and open actxserver?
If you get error message, please tell me the error message.
try
Excel = actxserver('excel.application');
fprintf('>> excel server open. \n');
catch ME
fprintf('>> %s. \n',ME.message);
end
Excel.Quit;
Excel.delete;
fprintf('>> excel server close. \n');
Chaudhary P Patel
Chaudhary P Patel 2020 年 2 月 2 日
can i use it alongwith previous command.
stozaki
stozaki 2020 年 2 月 2 日
Pleae run this command independently. Just the script to test your environment.
Chaudhary P Patel
Chaudhary P Patel 2020 年 2 月 2 日
編集済み: Chaudhary P Patel 2020 年 2 月 2 日
sir, it is showing like that.
file and the result what am i trying to print in excel is not memtioned!
Undefined function 'actxserer' for input arguments of type 'char'..
Undefined variable "Excel" or class "Excel.Quit".
Error in Untitled2 (line 149)
Excel.Quit;
stozaki
stozaki 2020 年 2 月 2 日
I am very sorry. My script had a miss spelling. I have modified it. Please re-try it. If you have caught an error, matlab didn’t have connect excel. Could you login your PC as administrator and try it?
Chaudhary P Patel
Chaudhary P Patel 2020 年 2 月 2 日
sir, it is showing like that,
Server creation failed. Invalid ProgID 'excel.application'..
Undefined variable "Excel" or class "Excel.Quit".
Error in Untitled2 (line 149)
Excel.Quit;
stozaki
stozaki 2020 年 2 月 2 日
Could you login your PC as administrator and try it? I have experienced the problem of access when Excel is installed but not registered.
Walter Roberson
Walter Roberson 2020 年 2 月 2 日
Excel is not installed on your system, or is not properly installed, or else you have a quite old version of Excel that is 32 bit only but you are using a 64 bit MATLAB
Chaudhary P Patel
Chaudhary P Patel 2020 年 2 月 3 日
sir every thing is ok related to excel.
Walter Roberson
Walter Roberson 2020 年 2 月 3 日
If everything was okay related to excel then the activex test would have succeeded.
Chaudhary P Patel
Chaudhary P Patel 2020 年 2 月 3 日
sir tell me other way to perform it.
Walter Roberson
Walter Roberson 2020 年 2 月 3 日
filename = 'testdata.xlsx';
A = [12.7 5.02 -98 63.9 0 -.2 56];
T = array2table(A);
writetable(T, filename, 'WriteVariableNames', false);
You might possibly get a warning message about having trouble connecting to Excel, but it should then use the built-in routines that do not use Excel .
Starting in the release after yours, R2018b, it is possible to add an option 'UseExcel', false to cause it to deliberately skip even attempting to use Excel.
Chaudhary P Patel
Chaudhary P Patel 2020 年 2 月 3 日
thanku so much sir,
finally we are able to export the data but one error is there it is not opening in matlb but outside matlab it is opening and file name also soming .xlsx.
Walter Roberson
Walter Roberson 2020 年 2 月 3 日
To open it in MATLAB use readtable() not xlsread()
stozaki
stozaki 2020 年 2 月 3 日
編集済み: stozaki 2020 年 2 月 3 日
@pramod kumar
Do you solve this problem? I got a similar warning on Linux without Excel installed. You may not have installed Excel correctly. (I know you are using windows10.)
@Walter Roberson @Image Analyst
Thank you for your help.

サインインしてコメントする。

製品

リリース

R2018a

質問済み:

2020 年 2 月 1 日

編集済み:

2020 年 2 月 3 日

Community Treasure Hunt

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

Start Hunting!

Translated by