Report generator to Word Table how to use AlowBreakAcrossPages

조회 수: 13 (최근 30일)
Daniel MONTERRAIN
Daniel MONTERRAIN 2023년 8월 22일
댓글: Daniel MONTERRAIN 2023년 9월 6일
good morning
I used report gnerator to export matlab data to word, in tables.
Sometimes le line of my table flow on 2 pages. I dont wnat that , i want word to go to tonexte page if the new line ios too high for the remaining space on the page.
I think i have to use AlowBreakAcrossPages(tf) with tf= false.
but i do not understand how to use this component or property or method or object
must i put it in a style ?
should it be associated to the entire table ofr to each line
I need an exanple to understand.
thank you

답변 (3개)

Rahul Singhal
Rahul Singhal 2023년 8월 29일
Hi Daniel,
You can refer to the example in the MATLAB command-line help for this class:
>> help mlreportgen.dom.AllowBreakAcrossPages
-Rahul

Divyanshu
Divyanshu 2023년 8월 29일
Hi Daniel,
I understand that you are trying to disable the page-breaks so that if there is a long row which cannot fit on the current page then it should be moved to the next page completely.
Here is a possible workaround which you can refer to, for achieving the same:
word = actxserver('Word.Application');
doc = word.Documents.Open('Absolute Path to your generated doc file');
numSections = doc.Sections.Count;
% Loop through each section and disable page breaks
for i = 1:numSections
section = doc.Sections.Item(i);
% Insert continuous section break
section.Range.InsertBreak(3); % 3 represents wdSectionBreakContinuous
end
doc.Save;
doc.Close;
word.Quit;
Refer the following documentations for better understanding:

Namnendra
Namnendra 2023년 9월 5일
Hey Daniel,
I understand that you want to move a table row to new page if the row doesn't fit in the page. For that you want to use the "mlreportgen.dom.AllowBreakAcrossPages" class object.
To achieve this, you need to add this property to the "Style" property of the table.
Example code:-
table = mlreportgen.dom.Table();
tableStyles = {mlreportgen.dom.AllowBreakAcrossPages('false')};
table.Style = [table.Style tableStyles];
This will force a row to start on the next page when it cannot fit on the current page.
To know more, kindly refer to following documentation:-
I hope the above information helps you.
Thank you.
Namnendra Gupta
  댓글 수: 1
Daniel MONTERRAIN
Daniel MONTERRAIN 2023년 9월 6일
HI,
on my computer wirth matlab R2019 your seems not to operate
with tableStyles = {mlreportgen.dom.AllowBreakAcrossPages('false')}; there is an error
Error using mlreportgen.dom.AllowBreakAcrossPages
No constructor 'mlreportgen.dom.AllowBreakAcrossPages' with matching signature found.
with tableStyles = {mlreportgen.dom.AllowBreakAcrossPages(false)}, there is no error but no impact on the result
until now no solution

댓글을 달려면 로그인하십시오.

제품


릴리스

R2016b

Community Treasure Hunt

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

Start Hunting!

Translated by