How to save a uitable as either a png, jpeg, pdf, excel?
25 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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.
0 Commenti
Risposte (1)
Walter Roberson
il 28 Feb 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 Commenti
Walter Roberson
il 2 Mar 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°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.
Vedere anche
Categorie
Scopri di più su Maintain or Transition figure-Based Apps in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!