필터 지우기
필터 지우기

writetable resizing column widths

조회 수: 25 (최근 30일)
Calvin Ebert
Calvin Ebert 2019년 5월 8일
댓글: Danny Smith 2022년 11월 15일
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
Danny Smith
Danny Smith 2022년 11월 15일
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)

댓글을 달려면 로그인하십시오.

채택된 답변

Calvin Ebert
Calvin Ebert 2019년 7월 31일
Hey anyone reading this, there is a work around but it is kinda annoying. See how you want your columns sized and fill in a row with 'a's at the very very end where it doesnt touch anything (Or at the very top) and have it read (Or save as variable and keep) and write it last.
  댓글 수: 1
Alex Calder
Alex Calder 2020년 10월 29일
Can you please provide an example, or link to where one is given? Your comment doesn't make it clear exactly what info you are wrting where and in what order. Thanks.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Walter Roberson
Walter Roberson 2019년 5월 8일
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.

카테고리

Help CenterFile Exchange에서 Spreadsheets에 대해 자세히 알아보기

태그

제품


릴리스

R2019a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by