How to change number format in excel two times via Matlab actxserver?
3 views (last 30 days)
Show older comments
Hello all,
I have an issue with actxserver(Excel Application), which I can not understand.
Originally, I have an excel file, which includes a column with dates (Format: yyyy-mm-dd). I need to change the format of dates into Number Format (0.00) or General Format, then do some stuff with the other data and finally change back the format into Dates Format (yyyy-mm-dd). So that, after Matlab script runs, my excel file looks unchanged (Date Format). My code:
e=actxserver('excel.application');
eW=e.Workbooks;
filename=[pwd '\testing.xls'];
eF=eW.Open(filename); % open testing.xls
eS=eF.ActiveSheet;
% edit sheet
eS.Range('A2:A12').NumberFormat="0.00";
eS.Range('A2:A12').NumberFormat="yyyy-mm-dd;@";
eF.Save
eF.Close; % close the file
e.Quit;
The Problem
If you run this code, you will see that code changes Range('A2:A12') to "0.00" Number Format:
eS.Range('A2:A12').NumberFormat="0.00";
But for some reason it does not want to change Range('A2:A12') back to "yyyy-mm-dd;@" Date Format:
eS.Range('A2:A12').NumberFormat="yyyy-mm-dd;@";
Thank You.
0 Comments
Answers (0)
See Also
Categories
Find more on Spreadsheets in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!