How to write to word file using utf-8 encoding

7 ビュー (過去 30 日間)
Ole
Ole 2017 年 8 月 26 日
回答済み: Walter Roberson 2017 年 8 月 27 日
I cannot save cyrilic to word file. I tried also reading a text file in utf8 but cannot write it with the same encoding. How to save text to word file with specific encoding.
clear all; close all;
delete('test.docx')
feature('DefaultCharacterSet', 'UTF-8')
word = actxserver('Word.Application');
word.Visible = 1;
document = word.Documents.Add;
selection = word.Selection;
selection.TypeText('1-1 ');
selection.TypeText('абв');
selection.TypeParagraph;
selection.TypeText('1-2');
selection.TypeText('абв');
selection.TypeParagraph;
selection.TypeText('Text here');
selection.Style='Heading 1';
selection.TypeParagraph;
H1 = document.Styles.Item('Heading 1')
H1.Font.Name = 'Garamond';
H1.Font.Size = 12;
H1.Font.Bold = 1;
H1.Font.TextColor.RGB=0;
selection.TypeParagraph
% document = invoke(word.documents,'add');
selection.TypeParagraph
selection.TypeText('End')
document.SaveAs2([pwd '/test.docx']);
word.Quit();

回答 (1 件)

Walter Roberson
Walter Roberson 2017 年 8 月 27 日

カテゴリ

Help Center および File ExchangeData Import and Export についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by