How does one set the number format of an excel cell using activex?
9 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I have an excel spreadsheet that contains the current date in cell A1. How can I ensure that the date format is set to ISO 8601 ( that is, 'yyyy-mm-dd') so that I can be sure that the date is unambiguous across different user settings?
I have successfully written the date using xlswrite, but to set the format of the cell to a specific format, I assume I have to use activex commands.
This is what I have tried: (xlfn is the file name of the spreadsheet).
Excel = actxserver('Excel.Application');
set(Excel,'Visible',1)
Workbook = Excel.Workbooks.Open(xlfn);
Sheets = Workbook.Sheets;
Sheet = invoke(Sheets, 'Item', 1);
Sheet.Name='Test';
Sheet.Range('A1').NumberFormat = 'yyyy-mm-dd';
Any suggestions?
0 commentaires
Réponses (1)
Image Analyst
le 11 Déc 2014
This page might help: http://stackoverflow.com/questions/20648149/what-are-numberformat-options-in-excel-vba
Or, you can record a macro in Excel, then you can format some cell the way you want in Excel, then stop recording and look at (edit) the macro to see what commands and format strings it used. Then replicate those in your MATLAB code. This is a very handy method for figuring out what ActiveX commands you need to use.
0 commentaires
Voir également
Catégories
En savoir plus sur ActiveX dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!