writetable resizing column widths
Show older comments
I am using the following:
writetable(Variable ,'Location', 'Sheet', 'Sheet Name', 'Range', Range, 'WriteVariableNames', false)
It works correctly in writing although it resizes the columns in excel. It is writing to the end of an existing table. Is there any way to avoid this?
1 Comment
Danny Smith
on 15 Nov 2022
I was able to avoid auto-resizing of Excel columns when using writetable via a 2-step process:
- In the Excel file/sheet you are writing to, go to Review>>Protect Sheet. Make sure that 'Format Columns' and 'Format Rows' are unchecked, then press OK
- When using writetable with the protected sheet, use the Name/Value pair ('UseExcel', true)
Accepted Answer
More Answers (1)
Walter Roberson
on 8 May 2019
0 votes
No, there is no way to avoid it with writetable(). writetable() does not attempt to preserve formatting or templates or graphics or formulas written into the range.
To have any of those preserved, you need to use actxserver() or a .NET interface to talk to Excel to tell it what needs to be done.
Categories
Find more on Spreadsheets in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!