Free Support Forum - aspose.com

LINQ Reporting Engine does not Sum the Table Column data correctly using Java

version: aspose-words-21.1-jdk17.jar

java linq sum is wrong

147483648 + 2000000000 = -2147483648
2000000000 + 3000000000 = 5000000000

Java Source

String dataDir = “c:\eb6\workspace\Aspose\word\”;
String fileName = “Test.docx”;

Document doc = new Document(dataDir + fileName);
String jsonData = “{“TITLE”:“Test”, “TABLE1”:[{“AMT1”:147483648, “AMT2”:2000000000}, {“AMT1”:2000000000, “AMT2”:3000000000}]”;

ReportingEngine engine = new ReportingEngine();
engine.setOptions(ReportBuildOptions.ALLOW_MISSING_MEMBERS);

try (InputStream inputStream = new ByteArrayInputStream(jsonData.getBytes(“utf-8”))) {
JsonDataSource dataSource = new JsonDataSource(inputStream);
engine.buildReport(doc, dataSource);
}

dataDir = dataDir + “Test_out.docx”;
doc.save(dataDir);

Word Template

AMT1 AMT2
<<foreach [in TABLE1]>><<[AMT1]>> <<[AMT2]>><>
<<[TABLE1.sum(t=>t.AMT1)]>> <<[TABLE1.sum(t=>t.AMT2)]>>

Word Result

AMT1 AMT2
147483648 2000000000
2000000000 3000000000
-2147483648 5000000000

aspose.zip (18.7 KB)

@hks

We have tested the scenario and have managed to reproduce the same issue at our side. For the sake of correction, we have logged this problem in our issue tracking system as WORDSNET-21646. You will be notified via this forum thread once this issue is resolved.

We apologize for your inconvenience.