How to name an excel worksheet when using writetable
現在この質問をフォロー中です
- フォローしているコンテンツ フィードに更新が表示されます。
- コミュニケーション基本設定に応じて電子メールを受け取ることができます。
エラーが発生しました
ページに変更が加えられたため、アクションを完了できません。ページを再度読み込み、更新された状態を確認してください。
古いコメントを表示
Is there a simple way to name an the excel worksheet when using the writetable fnx? I am aware of the answer by Thomas Koelen on 8 May 2015 ( https://www.mathworks.com/matlabcentral/answers/215703-changing-the-name-of-the-sheet-in-excel ) but I am hoping there is a more direct and simple method, not involving ActiveX. Instead of an excel workbook with "Sheet1", "Sheet2", etc I want to give specific names to the worksheets.
採用された回答
Fangjun Jiang
2017 年 7 月 21 日
writetable(TableObj,'test.xlsx','FileType','spreadsheet','Sheet','MyTable')
8 件のコメント
Stephen
2017 年 7 月 21 日
編集済み: Walter Roberson
2022 年 7 月 9 日
Thanks, Fangjun Jiang! Worked great with one caveat: I modified your script slightly to (note the quotation marks):
writetable(TableObj,'test.xlsx','FileType','Sheet',"MyTable")
This indeed names the worksheet, but it ADDS this sheet to an excel workbook such that I now have sheet1, sheet2, and then "MyTable".
Is there a way to get prevent the appearance of sheets 1 and 2...it just is messy. Of course I can delete them in Excel, but I'm looking for a streamlined way of creating the excel workbook.
Fangjun Jiang
2017 年 7 月 21 日
編集済み: Fangjun Jiang
2017 年 7 月 21 日
I can't think of anything if you don't want to involve ActiveX. One last resort yet not ideal is that you create a template Excel file ahead of time. This template Excel file only contains one sheet which you can put some useful notes and comments. Write to this template Excel file by creating a new sheet every time. Or, you can even over-write this one pre-existing sheet.
Stephen
2017 年 7 月 21 日
Got it. Thanks. I'm set now. I appreciate your help!
Aleksandra Bucka
2018 年 11 月 15 日
Hi Stephen, did you solve your problem with 3 additional empty Excel sheets? Could you explain me how you did it exactly? I would really appreciate it!
Bong Jae Jun
2019 年 7 月 16 日
The code allows writing data on the specified, named tab. However, it pushed the tab to the last tab and leaving Sheet 1, Sheet 2, and Sheet 3 in front of the data tab created. This is a problem for later use of collecting data. I could not find any way to delete Sheet 1, Sheet 2, Sheet 3 either. Did anyone solve this issue?
Seum Bin Rahman
2019 年 10 月 11 日
編集済み: Walter Roberson
2022 年 7 月 9 日
Hastyar Barvar comments to @Seum Bin Rahman
irreverent and sensing for a downlink
Hastyar Barvar:
The topic of the link is how to get rid of the default three sheets that are created, 'sheet1', 'sheet2', 'sheet3' . Deleting those sheets after creation is a valid approach to the question of how to end up with an Excel worksheet that does not have sheets with those names, which is what @Stephen was asking about.
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Spreadsheets についてさらに検索
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
最適なサイトパフォーマンスの取得方法
中国のサイト (中国語または英語) を選択することで、最適なサイトパフォーマンスが得られます。その他の国の MathWorks のサイトは、お客様の地域からのアクセスが最適化されていません。
南北アメリカ
- América Latina (Español)
- Canada (English)
- United States (English)
ヨーロッパ
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
