How to write to word file using utf-8 encoding

9 visualizaciones (últimos 30 días)
Ole
Ole el 26 de Ag. de 2017
Respondida: Walter Roberson el 27 de Ag. de 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();

Respuestas (1)

Walter Roberson
Walter Roberson el 27 de Ag. de 2017

Categorías

Más información sobre Data Import and Export en Help Center y File Exchange.

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by