[LINQ Reporting Engine] String auto converted to integer and skipping early "0" char

Hello,

I have an Issue with reporting engine, string property in object are auto converted to integer skipping early char “0”.

Exemple:

myObject.myString = "000001125454" will be displayed as 1125454 in the output document using tag <<[myObject.myString]>>

I haven’t the same issue in Excel template or using a variable in word template. It only occurs for nested or custom objects.

I enclosed my test solution, with 2 templates with same datasources: AsposeTest_string.zip (196.7 KB)

  • An Excel template.xlsx: no convertion problem

  • A Word,template.docx: conversion problem

In both template, I put three data sources:

  • variable ==> no issue
  • custom object ==> conversion issue in word doc only
  • nested object ==> conversion issue in word doc only

PDF template output:

Is a way to avoid “0” skipping in my template?

Thank you

@bgam

This is an expected behavior that is explained at the end of Accessing JSON Data. You can apply JsonSimpleValueParseMode.Strict to skip parsing of string values as shown in the following snippet:

JsonDataLoadOptions options = new JsonDataLoadOptions();
options.SimpleValueParseMode = JsonSimpleValueParseMode.Strict;
JsonDataSource dataSource = new JsonDataSource(..., options);

Also, I have noticed that you use serialization of a custom object into JSON before passing to LINQ Reporting Engine. Please note that this is not necessary and you can pass an instance of a custom type directly to the engine as shown, for instance, at Hello World Example.

@ivan.lyagin; thanks for your help, it’s now working using your snippet

1 Like

Hi, I have same problem, but when using XmlDataSource…
In Xml I have:

<Phone>+421907123456</Phone>
<Phone>0907123456</Phone>

But in docx it looks like:

421907123456
907123456

Is there a way how to tell not to convert this property to number?

Thanks in advance…

@miloskojezko

For XmlDataSource, XML schema can be used to specify data types through one of XmlDataSource’s constructors.

If XML schema is not present and automatic recognition of data types does not fit your scenario, a DataSet instance loaded from XML (see DataSet.ReadXml) could be passed to LINQ Reporting Engine alternatively.