How to write to word file using utf-8 encoding

6 次查看(过去 30 天)
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 CenterFile Exchange 中查找有关 Data Import and Export 的更多信息

标签

产品

Community Treasure Hunt

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

Start Hunting!

Translated by