We are using the Linq reporting engine to create a Document Generation Template engine.
The users can create a Word file, and where ever they need to fill in a phrase, or section from the database, they simply type in <<[DataSource.First().FieldName]>> in the word file.
This is great! We are loving it.
However, if that particular field is empty in the database, there is no way to inform the user of this in the completed document.
For example, if we have the following:
Hello Mr. <<[DataSource.First().LastName]>>
And the Last name field is empty or null in the database, then when we print out the results in the Word Document, it shows as:
I would like it to show like this:
Hello Mr. LastName
Where LastName is Bold, Italics, and red (or some other set of criteria).
Basically, if the LastName is empty or null, print the field it is tied to in the spot that is missing.
I realize that we can do something like this (where we wrap with an if condition):
Hello Mr. <<if[DataSource.First().LastName==null]>>LastName<><<[DataSource.First().LastName]>><>
The problem I have with this, is that it is so long, and it makes it difficult to maintain our templates. This can be wrapped inside other if conditions, and other tags, and it makes it really difficult to maintain everything.
What I am hoping for is some way to override the Aspose functionality that inserts text, so I can do something custom.
Some thoughts I had were to override Aspose’s Linq template engine. So when the user uses <<[Datasource.First().DateField]-“mm/dd/yy”>>, I can let Aspose do its thing. Then evaluate what Aspose prints out. If it prints out null or empty, then I can get access to the property it was trying to retrieve, and print the words “Missing DateField” in the template.
Do you have any thoughts on how I might be able to do this, or any other alternatives?