Add subscript Text to header of Table in pdf by MATLAB Report Generator
    12 visualizaciones (últimos 30 días)
  
       Mostrar comentarios más antiguos
    
    Masood Salik
 el 22 de Feb. de 2021
  
    
    
    
    
    Editada: Rahul Singhal
    
 el 1 de Mzo. de 2021
            How can I add subscript to the Header of the Table in Matlab Report Generator?
I tried this code. It does make the subscipt in UITable. But does not write text in pdf.
import mlreportgen.report.*
import mlreportgen.dom.*
rpt = Report('subscriptTable','pdf');
h = uitable('Data', [1 2; 3 4], 'ColumnName', {'<HTML>&Omega', '<HTML>P<SUB>i'})
headerLabels=h.ColumnName
bodyContent=h.Data
tbl = FormalTable(headerLabels,bodyContent);
tbl.Border = 'solid';
tbl.ColSep = 'solid';
tbl.RowSep = 'solid';
add(rpt,tbl);
close(rpt)
rptview(rpt)
0 comentarios
Respuesta aceptada
  Rahul Singhal
    
 el 1 de Mzo. de 2021
        
      Editada: Rahul Singhal
    
 el 1 de Mzo. de 2021
  
      Hi Masood,
You can use the DOM mlreportgen.dom.HTML object to include the HTML content, used in the uitable column names, in the DOM FormalTable. Make sure that the input HTML follows the requirements as specified here: https://www.mathworks.com/help/rptgen/ug/prepare-html-code-for-dom-reports.html 
Below is an example code:
import mlreportgen.report.*
import mlreportgen.dom.*
rpt = Report('subscriptTable','pdf');
h = uitable('Data', [1 2; 3 4], 'ColumnName', {'<html>Ω</html>', '<html>P<sub>i</sub></html>'})
% Create table header row containing HTML content
tblHeaderRow = TableRow();
for i = 1:length(h.ColumnName)
    te = TableEntry();
    append(te,HTML(h.ColumnName{i})); % append content using DOM HTML object
    append(tblHeaderRow,te);
end
bodyContent=h.Data
tbl = FormalTable(bodyContent); % create table with just body content
append(tbl.Header,tblHeaderRow); % append the header row
tbl.Border = 'solid';
tbl.ColSep = 'solid';
tbl.RowSep = 'solid';
add(rpt,tbl);
close(rpt)
rptview(rpt)
Thanks,
Rahul
0 comentarios
Más respuestas (0)
Ver también
Categorías
				Más información sobre MATLAB Report Generator Task Examples en Help Center y File Exchange.
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

