new line in report paragraph

36 ビュー (過去 30 日間)
Oliver Warlow
Oliver Warlow 2020 年 5 月 21 日
コメント済み: Oliver Warlow 2020 年 5 月 21 日
Hi,
I am using the report generator to do some simple reports. I want to auomatically write a paragraph of text over several lines. However I can;t seem to find a way of doing this without adding each line of text in turn.
I would like to do for example produce what the following code would to the command window:
sprintf('first line\nsecond line')
however if I to add that as either Text or Paragraph as per:
para = Paragraph();
append(para, Text(sprintf('first line\nsecond line')));
I just get everything on the same line.
I have had a hunt around, but can't seem to find the property I need to adjust or syntax I need to use to get text acrossmultiple lines.
Thanks
Oli.

採用された回答

Rahul Singhal
Rahul Singhal 2020 年 5 月 21 日
Hi Oliver,
Set the WhiteSpace property of the Paragraph object to preserve any white spaces and line breaks in the content. For e.g.,
para = Paragraph();
append(para, Text(sprintf('first line\nsecond line')));
para.WhiteSpace = 'preserve';
Also see mlreportgen.dom.WhiteSpace format for more details and examples.
Thanks,
Rahul
  1 件のコメント
Oliver Warlow
Oliver Warlow 2020 年 5 月 21 日
great thanks, i thought I has already tried 'preserve', but obviously hadn't don't it correctly
O.

サインインしてコメントする。

その他の回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by