In a report, how can you find out the height of table in pixels ?

1 visualizzazione (ultimi 30 giorni)
I am printing multiple tables in a report but I dont know how long each table will be (and some tables are multiple pages long) and I dont want to start a new table at the bottom of a page if there is only a few rows left. I am aware that the PageBreak option exist but I also dont want to waste a whole page just if there is just one or two rows at the top of the page. Given that a page has always the same height, I figured that if I could find out how high my tables are (in pixels I suppose) then I could automatically place them as I want. In a report, how can you find out the height of table in pixels ?
  2 Commenti
Kevin Holly
Kevin Holly il 24 Apr 2023
Is this a Live Editor export report or a report generated by ther report generator?
Blue
Blue il 24 Apr 2023
Im using the report generator. For example, if we tweak the example here (https://www.mathworks.com/help/rptgen/ug/define-styles-programmatically.html) I wouldnt want another table starting right under this one in the report as there is not enough room at the bottom of the page but I also dont want to use pagebreak automatically if there is only a couple of lines at the top of the page
% Import base classes for the report
import mlreportgen.report.*
import mlreportgen.dom.*
% Data
test(1).Name = "100% Success";
test(1).Description = "Percent of total loss(failing hits) must be==0%";
test(1).Status = "Fail";
test(1).StatusDetail = "Loss=22.33%";
test(2).Name = "No Fail";
test(2).Description = "Fail Count must be ==0";
test(2).Status = "Fail";
test(2).StatusDetail = "Fail Count=69";
test(3).Name = "Fast Hit Rate";
test(3).Description = "Final Throughput must be>=10Hits per second";
test(3).Status = "Pass";
test(3).StatusDetail = "Hits per Second=27.978";
test(4).Name = "Low Execution Time";
test(4).Status = "Pass";
test(4).Description = "Avg. Exe Time(ms) must be <750.0";
test(4).StatusDetail = "Avg Exe Time(ms)=244.33";
test(5).Name = "100% Success";
test(5).Description = "Percent of total loss(failing hits) must be==0%";
test(5).Status = "Fail";
test(5).StatusDetail = "Loss=22.33%";
test(6).Name = "No Fail";
test(6).Description = "Fail Count must be ==0";
test(6).Status = "Fail";
test(6).StatusDetail = "Fail Count=69";
test(7).Name = "Fast Hit Rate";
test(7).Description = "Final Throughput must be>=10Hits per second";
test(7).Status = "Pass";
test(7).StatusDetail = "Hits per Second=27.978";
test(8).Name = "Low Execution Time";
test(8).Status = "Pass";
test(8).Description = "Avg. Exe Time(ms) must be <750.0";
test(8).StatusDetail = "Avg Exe Time(ms)=244.33";
d = Document("report","pdf");
% Styles
styles = containers.Map;
styles("baseHeadingPara") = {Color("darkblue"),FontFamily("Arial")};
styles("heading1Para") = [styles("baseHeadingPara"),{OutlineLevel(1),Bold,...
FontSize("16pt")}];
styles("heading2Para") = [styles("baseHeadingPara"),{OutlineLevel(2),...
OuterMargin("0in","0in","12pt","5pt"),Italic,FontSize("14pt")}];
styles("testSummaryTable") = {Border("solid"),RowSep("solid"),ColSep("solid"),Width("7in")};
styles("testSummaryTableHeader") = {Bold};
styles("testSummaryTableEntry") = {InnerMargin("10pt")};
styles("passText") = {Color("green")};
styles("failText") = {Color("red")};
heading1Para = Paragraph("Load Test Information");
heading1Para.Style = styles("heading1Para");
append(d,heading1Para);
heading2Para = Paragraph("Quality of Service Report Summary");
heading2Para.Style = styles("heading2Para");
append(d,heading2Para);
testSummaryTableHeader = ["Name","Description","Status","Status Detail"];
nTests = numel(test);
testSummaryTableBody = cell(nTests,4);
for t = 1:nTests
testSummaryTableBody{t,1} = test(t).Name;
testSummaryTableBody{t,2} = test(t).Description;
result = test(t).Status;
status = Paragraph(result);
if result == "Pass"
status.Style = styles("passText");
else
status.Style = styles("failText");
end
testSummaryTableBody{t,3} = status;
testSummaryTableBody{t,4} = test(t).StatusDetail;
end
% Create the test summary table
testSummaryTable = FormalTable(testSummaryTableHeader,testSummaryTableBody);
testSummaryTable.Style = styles("testSummaryTable");
testSummaryTable.Header.Style = styles("testSummaryTableHeader");
testSummaryTable.TableEntriesStyle = styles("testSummaryTableEntry");
append(d,testSummaryTable);
close(d);
rptview(d);

Accedi per commentare.

Risposte (1)

Piyush Dubey
Piyush Dubey il 30 Mag 2023
Hi Blue,
Mlreport.dom package has a class named RowHeight, this can be used to set and modify the height of each row in the table. Multiplying the default row height (1in) to the number of rows will give you the height of the total report.
Refer to this documentation for more information:
Hope this helps.

Categorie

Scopri di più su MATLAB Report Generator in Help Center e File Exchange

Tag

Prodotti


Release

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by