How to write to word file using utf-8 encoding

8 Ansichten (letzte 30 Tage)
Ole
Ole am 26 Aug. 2017
Beantwortet: Walter Roberson am 27 Aug. 2017
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();

Antworten (1)

Walter Roberson
Walter Roberson am 27 Aug. 2017

Kategorien

Mehr zu Data Import and Export finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by