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

Free Support Forum - aspose.com

ExactDateTimeParseFormats does not Follow Date Formats using .NET | LINQ Reporting

input Json is
{ “AuthorityNumber”: “1715-1”,
“StartDate”: “2021-08-06”,
“ExpiryDate”: “2035-08-05”,
}

tags in Word document template is
<<[AuthorityNumber]>>
<<[StartDate]:“dd-MMM-yyyy”>>
<<[ExpiryDate] :“dd-MMM-yyyy”>>

Now, if without any setting on JsonDataLoadOptions.ExactDateTimeParseFormat
The result is
1/1/1715 12:00:00 AM
06-Aug-2021
05-Aug-2035

If I add a setting
JsonDataLoadOptions options = new JsonDataLoadOptions();
options.ExactDateTimeParseFormats = Enumerable.Empty();

The result is
1715-1
2021-08-06
2035-08-05

However what I want is
1715-1
06-Aug-2021
05-Aug-2035

Could you please show me how to do it?
I also tried <<[AuthorityNumber]:upper>>
It is not working at all

@zhenyu.wang

We have logged this problem in our issue tracking system as WORDSNET-22585. You will be notified via this forum thread once this issue is resolved.

We apologize for your inconvenience.

@zhenyu.wang

We have closed this issue (WORDSNET-22585) as ‘Not a Bug’. Please use the following code example to get the desired output.

var doc = new Aspose.Words.Document(MyDir + "LINQTemplate.docx");
var json = File.ReadAllText(MyDir + "JSON_Data.json");

List<String> formats = new List<String>();
formats.Add("yyyy-MM-dd");

JsonDataLoadOptions options = new JsonDataLoadOptions();
options.SimpleValueParseMode = JsonSimpleValueParseMode.Strict;
options.ExactDateTimeParseFormats = formats;

var dataStream = new MemoryStream(Encoding.ASCII.GetBytes(json));
var jsonDataSource = new JsonDataSource(dataStream, options);

var engine = new ReportingEngine();
engine.BuildReport(doc, jsonDataSource);

doc.Save(MyDir + "21.8.docx");