Open, Edit and Save Excel file with MATLAB

Hi,
I want following thing to be done with the help of MATLAB:-
1) Open an Excel file 2) Fill some data in Excel file cells 3) Save that file.
Again I need it through MATLAB.
Kindly help me out.

 採用された回答

Julia
Julia 2015 年 2 月 18 日

1 投票

Hi,
I did it like this:
1. Write data into the excel file (OutputTest) with xlswrite (it starts in cell F1 in Excel):
xlswrite('OutputTest',data,'Output','F1');
2. Edit the data. Therefore open the excel application (I think you can also use this technique to write your data if you do not want to use xlswrite):
e=actxserver('excel.application');
eW=e.Workbooks;
filename=[pwd '\OutputTest.xls'];
eF=eW.Open(filename); % open OutputTest.xls
eS=eF.ActiveSheet;
% edit sheet
eS.Range('A1:Q1').EntireColumn.AutoFit;
eS.Range('A1').EntireRow.Font.Bold=1;
eF.Save;
eF.Close; % close the file
e.Quit; % close Excel entirely

4 件のコメント

Suraj Srivastava
Suraj Srivastava 2015 年 2 月 18 日
Hi, Thank you so much for your reply. It was wonderful.
But I want to manually enter the data in the excel file. How is it possible.? Please I need your precious suggestions.
Julia
Julia 2015 年 2 月 18 日
When I had to write data from Matlab to Excel, I first wrote the data into a cell array and then I transfered it with the xlswrite() command to Excel.
I think in this thread you find a good example how to do it in another way :) (ExcelDemo.m)
Suraj Srivastava
Suraj Srivastava 2015 年 2 月 20 日
Thank you Julia,
I have achieved this task, by implementing macro in excel file.
Again thank you so much.
Shashank Rayaprolu
Shashank Rayaprolu 2017 年 10 月 20 日
Hi, May I know how you did that??
1. I want my MATLAB code to open an excel.
2. then I want to manuall fill the excel sheet.
3. I want MATLAB to read that excel and then do other operations.

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeData Import from MATLAB についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by