How do i reopen a Report which is created with a word tamplate and fill specific holes
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Tiffany
el 5 de Abr. de 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.
Respuestas (0)
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!