We're sorry AsposeCloud doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.cloud

How to handle missing data in LINQ reporting in Aspose.Words REST API?

hello,I want to know the size of the array in advance.
Is there any way like this to get the length of the array:
if len(xxx) == 0{
fmt.Println(“no error”);
}else{
for i:=0;i<len(xxx);i++{
… …
}
}

@Lifa

Please share some more details of your requirement, so we will guide you accordingly.

sorry. I didn’t describe it very well.
I want to use a template to generate a Word report.
I have two data cases: data_yes.json and data_no.json.(The attachment has been uploaded.)
build_word_report.zip (16.8 KB)

the problem is when I use the data_no.json.An error has occurred:
buildReport Failed:{“RequestId”:“Root=1-61039cd2-7234e87e0d61f8ca5558abbe”,“Error”:{“Code”:“ErrorInvalidInputData”,“DateTime”:“0001-01-01T00:00:00Z”,“Description”:“Operation Failed. The input data is not valid.”,“InnerError”:{“DateTime”:“0001-01-01T00:00:00Z”,“Message”:“An error has been encountered at the end of expression ‘in bingofsInfo]\u003e’. Can not get the value of member ‘bingofsInfo’ on type ‘System.Data.DataRow’.”},“Message”:“Error while build report”}}

I guess it’s because I don’t have the corresponding field in my JSON structure.
But I have judged by “if else”,
If the conditions in “if else” are met, the contents of the “for loop” should not be executed any further.(Please check out my word template)
Is there a way to solve it?

@Lifa

Please enable AllowMissingMembers value of ReportBuildOptions enum to avoid this error.

reportEngineSettings: new ReportEngineSettings()
{
    DataSourceType = ReportEngineSettings.DataSourceTypeEnum.Json,
    DataSourceName = "",
    ReportBuildOptions = new List<ReportBuildOptions>()
        {
        ReportBuildOptions.AllowMissingMembers,
        ReportBuildOptions.RemoveEmptyParagraphs
        }
},

Furthermore, in your scenario, you can also use Any() enumeration extension method in conditional block to check the data availability. Please check the second example in the working with common conditional block section.

Thank you very much for your guidance!
It solved a lot of my problems!
Sorry,I did not consult the document in detail.

1 Like

@Lifa

We are looking into your reported issue. Meanwhile, please share your sample code here as well. It will help us to address your issue exactly.

Sorry,I created a new topic to express my question.