fprintf to word file with red text

17 ビュー (過去 30 日間)
Tyler Murray
Tyler Murray 2016 年 10 月 20 日
コメント済み: Jan 2016 年 10 月 22 日
I am using fprintf to write to a text file. Since a text file only displays plain text I was looking to see about printing to Microsoft word and putting failed text in red. I know you can do fprintf(2, 'string') and the text will appear red in the command window. But when you write to a specific file such as MyFile, fprintf(2, MyFile, 'string') errors out. Is there a certain format to do this? Thanks.
  2 件のコメント
Chaya N
Chaya N 2016 年 10 月 20 日
編集済み: Chaya N 2016 年 10 月 20 日
Try an excel file instead(?)
While you may not be able to write in color into your file, you could probably add an extra comments column (with 'o' for successful and 'x' for failed data) or always mark it up in color later.
Chaya N
Chaya N 2016 年 10 月 21 日
I believe the syntax you are using for the fprintf command is wrong. Please look it up here .

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

回答 (2 件)

KSSV
KSSV 2016 年 10 月 22 日
編集済み: Jan 2016 年 10 月 22 日
fileID = fopen('myfile.txt','w');
str='I love Matlab';
fprintf(fileID,'%s',str);
fclose(fileID);
  1 件のコメント
Jan
Jan 2016 年 10 月 22 日
The detail "Microsoft word and putting failed text in red" is missing in this answer.

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


Walter Roberson
Walter Roberson 2016 年 10 月 22 日
There is no way to output colored text to a plain text file.
Outputting data that Microsoft Word will interpret as indicating something with red text may be practical.
  • you could output RTF (Rich Text Format)
  • you could use ActiveX to connect to Word and give it the necessary commands to insert text, select part of it, and color the selection.

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by