Report Generator: Embedded Code for List Items

1 visualización (últimos 30 días)
Deborah Johnson
Deborah Johnson el 29 de Feb. de 2024
Respondida: Kausthub el 19 de Mzo. de 2024
I am trying to make a bullet list as single line and not paragraph. The Error: Arrays have incompatible sizes for this operation. What do you recommend?
rpt = Report('ListItems','pdf');
step1 = ListItem('Discrepancies:');
textForItem1 = Text('note 1: Waypoint 3...');
step2 = ListItem(textForItem1);
textForItem2 = Text('note 2: Plots 6d and 6e:...');
step3 = ListItem(textForItem2);
procedure = OrderedList();
append(procedure,step1);
append(procedure,step2);
append(procedure,step3);
%append(rpt,procedure);
add(rpt, procedure);

Respuestas (1)

Kausthub
Kausthub el 19 de Mzo. de 2024
Hi Deborah, it is unclear of what you mean by "to make a bullet list as single line and not paragraph" and as far as I know the smallest type of content that could be added to a report is a paragraph and there is no API to only add a line to a report. Also, the code provided above runs without any errors so I was not able to reproduce the error that is mentioned. But here is an attempt to solve your query.
import mlreportgen.dom.*;
import mlreportgen.report.*
% METHOD 1
% Usualy way of creating bullet points
% where each bullet points starts in a new line
rpt = Report('ListItems','pdf');
step1 = ListItem('First Point');
textForItem1 = Text('Second Point');
step2 = ListItem(textForItem1);
textForItem2 = Text('Third Point');
step3 = ListItem(textForItem2);
procedure = OrderedList();
append(procedure,step1);
append(procedure,step2);
append(procedure,step3);
add(rpt, procedure);
% METHOD 2
% If you want all the points in a single line without new line
% combine the bullet points into a single string and format the string
% accordingly
combinedText = [char(183), 'First Point ', char(183), 'Second Point ', char(183) 'Third Point'];
para = Paragraph(combinedText);
para.Style = {LineSpacing(5)};
append(rpt, para);
close(rpt)
rptview(rpt)
The first method is the usual way of creating bullet points where each bullet points start in a new line and the second one is where the bullet points are combined in a single line without the new lines. The output is a PDF whose contents are:
Hope this helps!

Productos


Versión

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by