0
我正在使用xlsread
從Excel文件中讀取MATLAB代碼的輸入,計算後我將其導出到Word以寫出報告(writetoword.m)。在Excel中,有一個字符串,我應該在MATLAB中閱讀並在Word中輸出。如何將MATLAB的輸出寫入MS Word?
在Excel文件(input.xlsx)中,它被寫成'shoe'。
我閱讀使用
[num,txt,raw] = xlsread('input.xlsx');
eng = txt(14,19); % the word 'shoe' in that excel cell
在writetoword.m
,我寫的,
test = eng;
WordText(ActXWord,test,Style,[0,1]);
function WordText(actx_word_p,text_p,style_p,enters_p,color_p)
if(enters_p(1))
actx_word_p.Selection.TypeParagraph;
end
actx_word_p.Selection.Style = style_p;
if(nargin == 5)
actx_word_p.Selection.Font.Color=color_p;
end
actx_word_p.Selection.TypeText(text_p);
actx_word_p.Selection.Font.Color='wdColorAutomatic';
for k=1:enters_p(2)
actx_word_p.Selection.TypeParagraph;
end
return
它不打印任何東西。該錯誤是在該行
actx_word_p.Selection.TypeText(text_p);
現在如果我寫
test = 'eng';
WordText(ActXWord,test,Style,[0,1]);
它會爲ENG和不鞋。
我該如何解決這個問題?
哇!..工作..非常感謝Doresoom .... – Mithun