Hello!
I would like to test Aspose with a word template which have header and footer. In the header and footer I would like to show common data of my object and in the middle I would like to show the data of my list, which is a property of my object.
But when I iterate through my List-Property of my object, I get the following error:
System.InvalidOperationException: 'An error has been encountered at the end of expression ‘m.Liste.B’. Can not get the value of member ‘Liste’ on type 'Aspose_Header_Footer.Models.ListItem
How is the procedure or the best way, when I would like to show property values (for e.g. “HeaderProperty1”) of my object in the header and how can i iterate through another property which is a list?
Here is my sample project, so that you can reproduce my problem!
Aspose_Header_Footer.zip (371.0 KB)
Thank you in advance for your answer!
Best regards
Batiatos
@Batiatos
Please use the following LINQ Reporting syntax to avoid the shared issue. We have attached the modified template document and output document with this post for your kind reference.
Header_Footer.docx (22.2 KB)
output.pdf (34.9 KB)
<<foreach [m in Sachkonten.Liste]>><<[m.Bezeichnung]>>
<</foreach>>
@tahir.manzoor
Hello and thank you for your help!
I have two questions left:
-
How can I display the “HeaderProperty1” of my object in the header of my word-file? These header properties are for my header or footer and the List is for the middle, I mean the list is the content.
-
Is there a way to keep the texts (data records) together across pages? The last data record on the 1st page has a long text in the 3rd column and is therefore also displayed on the 2nd page.
I would like to display this last data record of the 1st page, on the 2nd page first.
An example can be seen in the screenshot.
Screenshot.JPG (77.8 KB)
Here is the current example projekt:
Aspose_Header_Footer.zip (455.2 KB)
Thank you in advance for your answer!
Best regards
Batiatos
@Batiatos
You are using mail merge field {MERGEFIELD Sachkonten.HeaderProperty1 } in your document. You can check it by pressing Alt + F9 after opening the document in MS Word.
Please use LINQ Reporting syntax <<[ Sachkonten.HeaderProperty1]>> to get the desired output. We suggest you please read the following article.
@tahir.manzoor
Thank you for your help…it works!
Best regards
Batiatos
@Batiatos
Thanks for your feedback. Please feel free to ask if you have any question about Aspose.Words, we will be happy to help you.