excel cells wider in matlab export
Afficher commentaires plus anciens
I have exported the outputs of the program I´ve done to excel but the cells are in the basic width, can matlab make the cell width automatically wider depending on the width of the values and words in the cell???
Réponses (2)
Walter Roberson
le 26 Avr 2018
0 votes
Not by itself, but if you are using MS Windows and have Excel installed, then you can use ActiveX to talk to Excel to send formatting information for the cells.
Fangjun Jiang
le 26 Avr 2018
The direct answer is No. xlswrite() only writes the data. It can't format the Excel file.
You can use actxserver('Excel.Application') to modify the Excel file format. See help on actxserver(). You can set the column width or autofit.
FirstRow.ColumnWidth=20;
FirstRow.Columns.AutoFit;
If you don't want to do that, there is a trick. You can pre-create the Excel file that you want to write to (with the same file name, same sheet name etc), adjust the column width, leave the data sheet blank, save and close the file. Then you can write your data to the file and the format remains.
2 commentaires
Raymond Morano
le 10 Fév 2020
This solution does not work because writematrix does change the format for the columns in a preformated file.
Walter Roberson
le 11 Fév 2020
Do not use writematrix() for this purpose: use xlswrite() on an MS Windows system that has Excel installed.
Catégories
En savoir plus sur Spreadsheets dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!