Type Conversion

How can i convert a string to integer in linq scripting.
I need to use sum() function but it is appending the values as string.

My XML

	<Row>
	   <amount>10</amount>
	</Row>
	<Row>
            <amount>20</amount>
	</Row>

Linq scripting in word

Total: <<[Row.sum(s => s.amount)]>>

Hi there,

Thanks for your inquiry. We will appreciate it if you please share your sample code along with input and output documents here. It will help us to address your issue exactly…

Best Regards,

Please find the requested details below,

In the word template we use this function to get sum:

<<[Row.sum(s => s.VarNumber+0)]>>

But in the output we are getting the sum as below,

70000.555.2333

The xml data is,

<Results>
	<Row>
		<VarNumber>70000</VarNumber>
	</Row>
	<Row>
		<VarNumber>555</VarNumber>
	</Row>
	<Row>
		<VarNumber>2333</VarNumber>
	</Row>
</Results>

Hi Nithin,

Thanks for sharing additional information. You need to convert string to integer in your template as following.

<<[Row.sum(s => Integer.parseInt(s.VarNumber))]>>

Please note you need to add java.lang.Integer class to Known External Type of Reporting Engine. Please check Setting up Known External Types section of following documentation for more details. It will help you to accomplish the task.Linqoutput.pdf (9.1 KB)

LINQ Reporting Engine API

com.aspose.words.Document doc = new com.aspose.words.Document("Linq_Row.docx");
ReportingEngine engine = new ReportingEngine();
engine.getKnownTypes().add(java.lang.Integer.class);
DataSet ds = new DataSet();
ds.readXml("Type_Test.xml");
engine.buildReport(doc, ds);
doc.save("Linqoutput.pdf");

Best Regards,