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!