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

Free Support Forum - aspose.com

LINQ Reporting Engine Variables

Hello

Is there any support for variables in LINQ templates?
Something like the following:

<<var [MyData d = expensiveDataComputation()]>>
Do something with MyData.
<>


This is something that’s missing in my opinion. It can make templates more readable as well.
If there is nothing like that I would suggest this as a new improvement for the LINQ Reporting Engine.

Hi Adrian,

Thanks for your inquiry. Please use following code example to achieve your requirements. We have attached the input and output documents with this post for your kind reference.

Document doc = new Document(MyDir + "in.docx");

ReportingEngine engine = new ReportingEngine();

String MyData = "Do something with MyData.";

engine.BuildReport(doc, MyData, "MyData");

doc.Save(MyDir + @"Out v16.12.0.docx");

Hello Tahir,

This is not exactly what I need. In my example, MyData was a data type.
Let’s say, I want to use the following code several times like this:

Hello Text
<<[computeMyDataWithParams(“bla”)]>>
Some other text
<<[computeMyDataWithParams(“bla”)]>>
Huhu
<<[computeMyDataWithParams(“bla”)]>>
Haha


Let’s say this function computes some data based on the String parameter that is only known in the Word template. Now, if I use this code in several locations, the template will be harder to read and depending on the implementation of computeMyDataWithParams(), this can be inefficient.

Therefore it would be beneficial to be able to define variables instead the template like my initial example:

<<var [MyData data = computeMyDataWithParams(“bla”)]>>
Hello Text
<<[data]>>
Some other text
<<[data]>>
Huhu
<<[data]>>
Haha
<>

I hope this example is clear.

Hi Adrian,

Thanks for sharing the detail. As per my understanding, you want to call computeMyDataWithParams function only once and use its returned value e.g. "data" multiple times between <> and <>. In this case, the value of "data" will be same in output document. Please confirm this. We will log this feature in our issue tracking system.

Moreover, it would be great if you please share your input template and expected output documents here for our reference. This will help us to understand your scenario, and we will be in a better position to address your concerns accordingly.

Hello Tahir

Yes, in this case, the value of “data” will be the same in the everywhere output document. I would like to be able to use variables just like in a common programming language.
The value of “data” should be computed only ONCE in the <<var […]>> part and then further uses of “data” should just use this computed value, without recomputing it with the function.

The tags <> and <> would define the scope in which this variable can be used, just like <> and <> define the scope, in which a loop variable can be used.

Let’s say this is the input template and the function computeValue(String param) will just return the parameter value of “param”.

<<var [String data = computeValue(“Hello World”)]>>
Text A
<<[data]>>
Text B
<<[data]>>
Text C
<<[data]>>
Text D
<>

The output will look like this, if computeValue() computes the result “Hello World”:

Text A
Hello World
Text B
Hello World
Text C
Hello World
Text D

Hi Adrian,

Thanks for sharing the detail. We have logged this feature request as WORDSNET-14627 in our issue tracking system. You will be notified via this forum thread once this feature is available.

We apologize for your inconvenience.

The issues you have found earlier (filed as WORDSNET-14627) have been fixed in this Aspose.Words for .NET 17.3.0 update and this Aspose.Words for Java 17.3.0 update.


This message was posted using Notification2Forum from Downloads module by aspose.notifier.