excel cells wider in matlab export
显示 更早的评论
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???
回答(2 个)
Walter Roberson
2018-4-26
0 个投票
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
2018-4-26
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 个评论
Raymond Morano
2020-2-10
This solution does not work because writematrix does change the format for the columns in a preformated file.
Walter Roberson
2020-2-11
Do not use writematrix() for this purpose: use xlswrite() on an MS Windows system that has Excel installed.
类别
在 帮助中心 和 File Exchange 中查找有关 Spreadsheets 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!