Hi everyone,
I tried out the JsonDataSource for the LinqReportEngine in Aspose.Words. I wanted to display a List of strings as a comma separated text.
In my example I have following json-data:
{
“Name”:“Max Mustermann”,
“Birthday”:“2000-01-01T00:00:00”,
“Ratings”:[“First Rating”],
“Tags”:[“Tag1”,“Tag2”]
}
As you can see there are two arrays of strings: Ratings and Tags. In my Word-Template I used following code to display the arrays:
<<foreach [tag in Tags]>><<[tag.IndexOf()!=0 ? “, “ : “”]>><<[ Tags_Text]>>,<</foreach>>
and
<<foreach [rating in Ratings]>><<[ rating.IndexOf()!=0 ? “, “ : “”]>><<[ Ratings_Text]>>,<</foreach>>
For both lists the same using, but on generate the Report it works only for the Tags-Array. Adding a second item to the Ratings-Array, it also works for this. In case of an array containing only one item, the LinqReportEngine throws folling exception:
’An error has been encountered at the end of expression ’ Ratings_Text]>’. Can not get the value of member ‘Ratings_Text’ on type ‘System.Char’.'
I also added following line in the Word-template:
<< [Ratings] >>
For the single item array the report engine produces the output “First Rating”, but it only works, if the array contains a single item.
Do you have an idea how I can solve this problem? The example is attached.
Thanks and best regards
I used Aspose.Words for .net in Version 19.9.0.
Example.zip (124.3 KB)