Excel header title from html code

I have a GUI with an uitable whose header's title (variable "header") uses html code. I want to export the uitable data (included its header) to an Excel spreadsheet. This is the code written for this task:
%# header = get(htable,'ColumnName');
header = {'<center>Component X<br />(km/s<sup>2</sup>)</center>', ...
'<center>Component Y<br />(km/s<sup>2</sup>)</center>', ...
'<center>Component Z<br />(km/s<sup>2</sup>)</center>'},
numeric_data = rand(3,3);
data_Matrix = [header ; num2cell(numeric_data)],
xlswrite('file.xls',data_Matrix);
However, I can not get Excel spreadsheet header title appears written correctly.

 채택된 답변

Jan
Jan 2011년 11월 21일

1 개 추천

What happens in the Excel display? Does Excel display HTML formatting at all?
You can try this:
LF = char(10);
Sq = char(178);
header = {['Component X', LF, '(km/s', Sq, ')'], ...
['Component Y', LF, '(km/s', Sq, ')'], ...
['Component Z', LF, '(km/s', Sq, ')']};
[EDITED: Missing quotes inserted]

댓글 수: 3

Julián Francisco
Julián Francisco 2011년 11월 21일
@Jan Simon: Thank you for your answer. However, I have got the following error:
Expression or statement is incorrect--possibly unbalanced (, {, or [.
for the line corresponding to header.
Jan
Jan 2011년 11월 21일
@Julian: Did you try to fix the problem? I forgot some quotes.
Julián Francisco
Julián Francisco 2011년 11월 22일
@Jan Simon: Yes, I did. Thank you back.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

제품

질문:

2011년 11월 20일

Community Treasure Hunt

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

Start Hunting!

Translated by