How to insert an image to table entry in this situation in Report Generator ?

조회 수: 11 (최근 30일)
I saw code like this could change the text content of an entry after building the table:
table.entry(1,1).Children(1).Content = 'Header A';
i tried to use some similar codes like below to insert an image into a certain entry ,
table.entry(1,1).Children(1).Content = Image('number.jpg')
or
table1.entry(1,1).append(Image('number.jpg'));
but they all failed, could anyone please give me some tips?
Thanks in advance

채택된 답변

Rahul Singhal
Rahul Singhal 2018년 7월 3일
Hi Tong,
For the case where you are updating the Content property to change the text in a table entry, that particular child of the table entry must be a a mlreportgen.dom.Text object. So you are actually accessing the DOM Text object and updating its Content property. As you can see from the documentation of the Content property, it just accepts text specified as character vector, so it works fine when you assign a 'A Header' to it but fails when you assign an Image object to it.
On the other hand, you should be able to use the append method of the table entry to add an Image object. For e.g., the below code will append an image to the first table entry.
t = mlreportgen.dom.Table(magic(2));
i = mlreportgen.dom.Image(which('b747.jpg'));
t.entry(1,1).append(i);
If this doesn't help, can you share the exact code how you are creating the table before appending an image to it's table entry, and also what is the error message you are encountering, so that I will be able to suggest specific to your use case.
  댓글 수: 1
Tong Wang
Tong Wang 2018년 7월 4일
Hi Rahul
Thanks for your detailed explanation, i retried this code, it works now, thank you!

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

추가 답변 (0개)

Community Treasure Hunt

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

Start Hunting!

Translated by