How to save a uitable as either a png, jpeg, pdf, excel?

19 visualizaciones (últimos 30 días)
camicat
camicat el 28 de Feb. de 2020
Comentada: Walter Roberson el 2 de Mzo. de 2020
Hi!
I have uitable that I created that changes the background color of the data row depending if certain conditions are met. I am now trying to export that out of matlab and save it as either a png, jpeg, pdf, excel table (I'm not picky). It is very important to maintain the background color of the table rows as it is what gives them utility. I'm not sure how to go about this, working with R2019b.

Respuestas (1)

Walter Roberson
Walter Roberson el 28 de Feb. de 2020
saveas() or print() the figure .
You might be able to create a new figure and copyobj() the uitable into it, and saveas() or print() that figure -- thereby ignoring everything else that is in the original figure. export_fig() from the File Exchange might be willing to do that on your behalf.
  4 comentarios
camicat
camicat el 2 de Mzo. de 2020
Ah dang ok, it was so easy to do through the uifigure function! I'm not necessarily tied to using app designer, is there another way to obtain the same functionality with a traditional table?
Walter Roberson
Walter Roberson el 2 de Mzo. de 2020
You can color individual cells in uitable() of traditional figures by using a trick.
In order to color an individual cell, you must set your Data property to a 2D cell array of values. For any column in which even one entry is to be colored, the entire column must be converted to character vectors, even if you are trying to show numeric values. For example if you were trying to do the traditional weather reports showing temperatures with red color for the daily high and blue for the daily low, then the entire column would have too be converted to character vector.
Once you have the column in character vector for, in order to color any one entry, you must convert it into HTML 1.1 format, independently of all of the other entries in the row, by putting in <html> at the beginning of the character vector. You can omit the </html> at the end of the vector, though. Then you can include HTML coloring and HTML character entities such as <TD bgcolor="red">-11.2&deg;C</TD>
Remember, this <html> prefix must be put independently into each character vector.
Technically it is possible to use HTML <TABLE> inside a cell, and even to put multiple table entries including using TR and TD. The problem with this is that the renderer assumes that you only have a single normal line, so sizing the entries properly is difficult to impossible if you do that. You can even use HTML image insertion, which is a pain to get right but it does work.

Iniciar sesión para comentar.

Categorías

Más información sobre Maintain or Transition figure-Based Apps en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by