How to write to word file using utf-8 encoding

조회 수: 8 (최근 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 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