Hello,
I try to replace textcontrol in our application with Aspose.Words.
I have a problem with tables that have optional records.
When the table has no record, it leads to an exception.
I’ve set the ReportBuildOptions.AllowMissingMembers
option.
But it is only working for members and not empty tables.
My expression is:
<<data.optionallyfilledtable.value1>>
data is always present with exactly one record.
optionallyfilledtable is filled depending on the application data.
It has 0 to 1 records.
If it has one record all works fine.
If it has none, I get an exception.
I know that I can handle it with the ? syntax.
<<data.optionallyfilledtable?.value1>>
But that leads to a very complicated syntax for the authors of the document templates.
To “nerdy” for our customers.
My expectation is that setting
ReportBuildOptions.AllowMissingMembers
would also include that a missing record is accepted. I don’t see a reason why not.
An additional option like
ReportBuildOptions.AllowMissingRecords
would be also a nice.
@rainer.zehnle
ReportBuildOptions.AllowMissingMembers
has nothing to do with missing rows in a data table as per its reference, so the behavior is expected.
If using of the ?.
operator is not a suitable option, then maybe, it is possible to change the structure of data you pass to the engine?
Thx Ivan for your answer.
Unfortunately it is not helpful for my situation.
Our application has for complex document templates 293 tables. I know that is a lot.
Depending on the data user enter in the application or what options the user chooses to create the final document, tables might have a record or not.
I do not see what I should change in the data structure.
An additional option like ReportBuildOptions.AllowMissingRecords
would be really helpful.
Otherwhise the customers will use everywhere a ?
like in <<data.optionallyfilledtable?.value1>>
.
The customers have no technical background. They simply will not understand what they do.
Therefore it is a goal of our company to keep the syntax language as easy as possibly.
As a developer I like the C# flavor of the syntax. But customers are not developers.
@rainer.zehnle
I do not see what I should change in the data structure.
If all the data tables are always present, then you may simply go through all of them and for every of the tables, check whether it contains a data row or not. If not, then you may add a new default data row (i.e. with all DBNull
values) to it. This approach will let you use syntax like <<[data.optionallyfilledtable.value1]>>
. Then, when value1
happens to be DBNull
, the engine will treat it as null, which is similar to ReportBuildOptions.AllowMissingMembers
behavior.