Issue :
When report is exported from code, the textbox which displays invoice date do not format the date correctly, The format is set to {0:D}, the result is 01/May/2019 12:00:00 AM.
When same report is exported from report viewer , the date is formatted correctly, i.e. Monday, April 1, 2019
Below is code to export report from code.
Telerik.Reporting.Processing.ReportProcessor reportProcessor =
new
Telerik.Reporting.Processing.ReportProcessor();
System.Collections.Hashtable deviceInfo =
new
System.Collections.Hashtable();
Telerik.Reporting.TypeReportSource typeReportSource =
new
Telerik.Reporting.TypeReportSource();
typeReportSource.TypeName =
typeof
(FCInvoiceHeader).AssemblyQualifiedName;
typeReportSource.Parameters.Add(
"OrderNumber"
, header.InvoiceNumber);
Telerik.Reporting.Processing.RenderingResult result = reportProcessor.RenderReport(
"PDF"
, typeReportSource, deviceInfo);
string
fileName = header.InvoiceNumber +
"."
+ result.Extension;
string
path = @
"C:\FleetCareBulkInvoice\"
;
bool
exists = System.IO.Directory.Exists(path);
if
(!exists)
System.IO.Directory.CreateDirectory(path);
string
filePath = System.IO.Path.Combine(path, fileName);
using
(System.IO.FileStream fs =
new
System.IO.FileStream(filePath, System.IO.FileMode.Create))
{
fs.Write(result.DocumentBytes, 0, result.DocumentBytes.Length);
}