How do i reopen a Report which is created with a word tamplate and fill specific holes
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
if app.Pushbutton.Value
import mlreportgen.dom.*;
D = mlreportgen.dom.Document("Report", "docx", "Report_Template.dotx"); % Template with Rich Text elements
open(D);
while ~strcmp(D.CurrentHoleId,'5')
switch D.CurrentHoleId
case '1'
append(D, num2str(10)); % Example for Number value
case '2'
append(D, num2str(12));
case '3'
append(D, Text);
case '4'
append(D, Text2);
end
moveToNextHole(D);
end
close(D);
end
%% It works well up to here
if app.Pushbutton2.Value
import mlreportgen.dom.*;
open(D);
while true
if strcmp(D.CurrentHoleId, '5')
break;
end
moveToNextHole(D);
end
while ~strcmp(D.CurrentHoleId, '7')
switch D.CurrentHoleId
case '5'
append(D, Text3);
case '6'
append(D, Text4);
end
moveToNextHole(D);
end
close(D);
end
Hello,
i use appDesigner and i want to add content to a report, which is created with a word template. The content should be added when you press a pushbutton in app designer. So in the Template are rich text elements with sequential numbers from 1 to in this case 7 (CurrentHoleId s). My code works fine until i want to reopen it. First i tryed to not closing it until the next pushbutton request but that didnt work.
How can i solve this problem? Thank you.
Best Regards
Lukas Rackl
5 Kommentare
Tiffany
am 5 Apr. 2024
Hi Lukas,
According to the MathWorks Documentation for close, "Once a document is closed, you can no longer append content to it. Closing the document outputs any remaining content, such as remaining template text." This is the reason why you encounter an error message when trying to use open on a closed document. Here is the documentation link for "close": https://www.mathworks.com/help/rptgen/ug/mlreportgen.dom.document.close.html.
Antworten (0)
Siehe auch
Kategorien
Mehr zu MATLAB Report Generator Task Examples finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!