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.
采纳的回答
writetable(TableObj,'test.xlsx','FileType','spreadsheet','Sheet','MyTable')
8 个评论
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.
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.
Got it. Thanks. I'm set now. I appreciate your help!
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!
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?
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!选择网站
选择网站以获取翻译的可用内容,以及查看当地活动和优惠。根据您的位置,我们建议您选择:。
您也可以从以下列表中选择网站:
如何获得最佳网站性能
选择中国网站(中文或英文)以获得最佳网站性能。其他 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)
