excel cells wider in matlab export
Ältere Kommentare anzeigen
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???
Antworten (2)
Walter Roberson
am 26 Apr. 2018
0 Stimmen
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
am 26 Apr. 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 Kommentare
Raymond Morano
am 10 Feb. 2020
This solution does not work because writematrix does change the format for the columns in a preformated file.
Walter Roberson
am 11 Feb. 2020
Do not use writematrix() for this purpose: use xlswrite() on an MS Windows system that has Excel installed.
Kategorien
Mehr zu Spreadsheets finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!