How can I erase Sheet1 Sheet2 and Sheet3 in excel file using writetable function in matlab?

2 ビュー (過去 30 日間)
metehan akinci
metehan akinci 2019 年 4 月 23 日
コメント済み: dpb 2019 年 4 月 25 日
I m using write table function to create an excel file yet i can not erase sheet names which are 1 2 3. How can I erase the Sheet 1-2-3?
writetable(t1,'test2.xlsx','Sheet','a')
writetable(t2,'test2.xlsx','Sheet','b');
writetable(t3,'test2.xlsx','Sheet','c');
when i open the test2 file. i dont want to see Sheet1-2-3. I just want to see Sheetnames which are a b and c.

回答 (1 件)

dpb
dpb 2019 年 4 月 23 日
編集済み: dpb 2019 年 4 月 24 日
Modifying workbook properties isn't what writetable does--it just writes to a given sheet, creating one of that name if it doesn't exist. That's the same behavior in xlswrite
There is no builtin ML function to do such other manipulations of a workbook; you'll have to do that via COM.
Alternatively, build a template workbook that you duplicate for new workbooks with the desired sheet name(s) and write to (the new copy of) it instead.
  4 件のコメント
Walter Roberson
Walter Roberson 2019 年 4 月 24 日
Ah, I did not notice that problem.
MATLAB does create Sheet2 and Sheet3 deliberately. I cannot tell at the moment if it creates Sheet1 deliberately (or merely expects it to be created) as that gets down into built-in functions.
dpb
dpb 2019 年 4 月 25 日
Excel won't let you create a workbook without at least one sheet so Sheet1 is in Excel itself.
You can open a new blank workbook with only Sheet1 but not an empty zero-sheet instance so OP would still be stuck with one unwanted sheet.
I wonder why TMW chose to create the two extras automagically; I'd never dug into that portion of the code on the writing side; I've stolen huge chunks of the read side to use to build other tools around for specific purposes like reading the comments fields and formulas as well as content.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeSpreadsheets についてさらに検索

タグ

製品


リリース

R2016a

Community Treasure Hunt

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

Start Hunting!

Translated by