Saving strings (ex. 0222222) from MATLAB to Excel using xlswrite is saving as a numeric.

4 ビュー (過去 30 日間)
Dankur Mcgoo
Dankur Mcgoo 2018 年 3 月 12 日
回答済み: Fangjun Jiang 2018 年 3 月 12 日
Hello,
I am trying to save a string (i.e. 02222222) into excel. I need to keep the leading zero, but when I use xlswrite in MATLAB is converts it to a number, so I lose the leading 0.
I currently have my data saved in a cell array as a string.
Any clue if this is possible?
  2 件のコメント
Rik
Rik 2018 年 3 月 12 日
Have you tried wrapping the values in double quotes? Excel has a tendency to be smart-ass and change the data type if you don't include " to denote strings.
Dankur Mcgoo
Dankur Mcgoo 2018 年 3 月 12 日
As in in front of the number (ex. "02222222)?

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

回答 (1 件)

Fangjun Jiang
Fangjun Jiang 2018 年 3 月 12 日
Add a single quote in front to deal with Excel
a={'"022','''022','022'}
xlswrite('test.xls',a);
winopen test.xls

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by