Inaccurate results when writing xls through writetable

4 ビュー (過去 30 日間)
Yazan
Yazan 2022 年 5 月 21 日
コメント済み: Yazan 2022 年 5 月 21 日
Hello everyone.
I am using Matlab R2021b. I write then save .xls files from a table using writetable. After saving, I write again on the same file but without deleting the older version first. If I do so, I get strange results in some cases, e.g., the last cell gets duplicated, some characters are added to some cells. If I delete the older version before saving the new one, I have no issues. Is this a known issue?
  2 件のコメント
Image Analyst
Image Analyst 2022 年 5 月 21 日
I've never noticed that. You're writing the very same array both times, right? Not a smaller one the second time, which would leave the existing cells that don't get written over? You're specifying the upper left cell the same both times, right, like 'A1'? Can you attach your data in a .mat file and attach the code that demonstrates what you think is the problem? Can you download the latest version (R2022a) and try it there also?
Yazan
Yazan 2022 年 5 月 21 日
You guessed it. I was not setting "WriteMode" to "overwritesheet". Thank you.

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

採用された回答

Voss
Voss 2022 年 5 月 21 日
From the documentation for writetable:
  • If filename is the name of an existing spreadsheet file, then the writing function writes the data to the specified location, but does not overwrite any values outside the range of the input data.
Does that explain the behavior you are seeing?
  1 件のコメント
Yazan
Yazan 2022 年 5 月 21 日
It does indeed. Rechecked the documentation: the default value of "WriteMode" is "inplace" for xls, and not "overwritesheet", as I was assuming. Apparently, I was overwriting an existing table with one of one less row, which caused the impression that the last cell was getting duplicated. Appreciate the help.

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

その他の回答 (0 件)

カテゴリ

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

タグ

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by