Adding Headers and Footers to Holes in Template in Matlab Report
Show older comments
I have created a template in Microsoft word where I added Holes in the header and footer. Now I am trying to use matlab to fill it out.
This is the code I am using.
docHeaders = rpt.CurrentDOCXSection.PageHeaders;
while ~strcmp(docHeaders.CurrentHoleId,'#end#')
docHeaders.CurrentHoleId
docHeaders.CurrentHoleType
switch docHeaders.CurrentHoleId
case 'HeaderASTM'
append(docHeaders,app.ASTMVersionDropDown.Value);
end
moveToNextHole(docHeaders);
end
close(docHeaders);
the holes match, append method return an object, but when I open the document, the holes are empty.
1 Comment
baptiste boudier
on 9 Aug 2019
Did you find a solution to this problem ?
Answers (1)
ahmed920
on 9 Aug 2019
0 votes
5 Comments
baptiste boudier
on 9 Aug 2019
Thank you fot your answer!
I have created a template in Microsoft word (Template.dotx) with 2 holes in the header.
Here is the code:
import mlreportgen.report.*;
import mlreportgen.dom.*;
D = Document('myDoc','docx','Template.dotx');
open(D);
docHeaders = D.CurrentPageLayout.PageHeaders;
% Filling first hole
docHeaders.moveToNextHole;
append(docHeaders,'Text Hole #1');
% Filling second hole
docHeaders.moveToNextHole;
append(docHeaders,'Text Hole #2');
close(D)
rptview(D)
When I open the document, the holes are empty like you but if I double click in the header in word like if I wanted to edit manually the document then it magically appears!
ahmed920
on 9 Aug 2019
ahmed920
on 9 Aug 2019
baptiste boudier
on 9 Aug 2019
Yes it's like if Word needed a refresh at the end.
ahmed920
on 9 Aug 2019
Categories
Find more on MATLAB Report Generator Task Examples in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!