How to insert an image to table entry in this situation in Report Generator ?
8 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Tong Wang
el 2 de Jul. de 2018
Comentada: Tong Wang
el 4 de Jul. de 2018
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
0 comentarios
Respuesta aceptada
Rahul Singhal
el 3 de Jul. de 2018
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.
Más respuestas (0)
Ver también
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!