LINQ reporting issue with no input data throws error can not apply operator '-' to operands

I want to build a word report.
I have two data cases: data_yes.json and data_no.json.
(I have enabled the AllowMissingMembers feature.)
However, when I was calculating the subtraction, It reported the wrong:

buildReport Failed:{“RequestId”:“Root=1-6107b8af-39132c372a072f026a2b35d5”,“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 ‘((totalSpace-availSpace)*’. Can not apply operator ‘-’ to operands of type ‘System.Object’ and ‘System.Object’.”},“Message”:“Error while build report”}}

I think when the data is missing,the following logical judgments should be skipped.
question1: Is there a way to solve it?(Attached is my sample code.)
build_word_report2.zip (16.5 KB)

question2: Sometimes my data looks like this: 10.1.1.1:8080.
When I build the word report,I want to split the string by “:” and get the first element in the array , such as IP 10.1.1.1.
Is there a similar function like “$var.split(’:’)[0]” in LINQ Reporting Engine?

@Lifa

Thanks for sharing the template and data file. Please also provide your sample code used to call the BuildReport API method.

package main
import (
    "fmt"
    "io"
    "io/ioutil"
    "os"
    "github.com/aspose-words-cloud/aspose-words-cloud-go/v2007/api"
    "github.com/aspose-words-cloud/aspose-words-cloud-go/v2007/api/models"
)
func main() {
    config, _ := models.NewConfiguration("config.json")
    wordsApi, ctx, _ := api.CreateWordsApi(config)
    template, _ := os.Open("template_new_custom.docx")
    data, _ := ioutil.ReadFile("data.json")
    settingConfig := []string{"AllowMissingMembers"}
    settings := models.ReportEngineSettings{DataSourceType: "Json", ReportBuildOptions: settingConfig}

    response, err_BuildReport := wordsApi.BuildReportOnline(ctx, template, string(data), settings, nil)

    defer response.Body.Close()
    if err_BuildReport != nil {
        fmt.Println("buildReport Failed:" + err_BuildReport.Error())
    }
    output, _ := os.Create("result.docx")
    defer output.Close()
    io.Copy(output, response.Body)
}

1 Like

@Lifa

After the initial investigation, we have logged a ticket WORDSCLOUD-1694 for further investigation and rectification. We will keep you updated about the issue resolution progress.

@Lifa

After initial investigation, we have logged a ticket WORDSCLOUD-1695 for further investigation and rectification. We will notify as soon as it is resolved.

thanks for the awesome information.

1 Like

Hi.How is ticket WORDSCLOUD-1694 and 1695 going? :smiley:

@Lifa

About WORDSCLOUD-1964, we have investigated the issue and found it is expected behavior. As per API reference, ReportBuildOptions.AllowMissingMembers makes the engine to treat missing object members as null literals. So the ((totalSpace–availSpace)*100)/totalSpace template expression is treated as ((null–null)*100)/null. If you try to compile an expression like ((null–null)*100)/null using a C# compiler, you get a compile-time error. Similarly, the engine throws an exception, so this is an expected behavior rather than a bug.

The simplest way to work around this restriction is using of a typecast to a nullable numeric type as shown in the attached modified template.

template_new_custom_modified.docx (19.1 KB)

@Lifa

We have investigated the WORDSCLOUD-1695 ticket and fount that as per Microsoft documentation, a string.Split overload accepting a single string argument is available only in the newest versions of .NET. We have tested the scenario using .NET Core 2.1 and it works as expected. If using .NET Core 2.0 or higher is not an acceptable option for you, then you may use another string.Split overload that is available for the .NET version you use.

We fixed the template for the Split method to work correctly. Please see attached document. Hopefully, it will help you to accomplish the task.

ReportTemplate_Fixed.docx (10.1 KB)

Nice! This way worked for me!
Thank you very much!

1 Like

“.Split(’:’).FirstOrDefault()” can also solve my problems.Thanks again! :smiley:
But the official documentation seems to have no description of this function?

1 Like

The issues you have found earlier (filed as WORDSCLOUD-1694,WORDSCLOUD-1695) have been fixed in this update. This message was posted using Bugs notification tool by Ivanov_John

Hi.
After I updated the SDK to https://github.com/aspose-words-cloud/aspose-words-cloud-go/tree/master/v2110/api, I found vip.Split(‘:’).FirstOrDefault() was unavailable.

@Lifa

We are sorry for the inconvenience. We have noticed the issue with 21.10 and we are reopening the related issue for investigation. We will share an update with you asap.

[quote=“alexsunny123, post:6, topic:7814, full:true”]

thanks my issue has been fixed.

1 Like