We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

Changing the report content before the report is loaded on runtime

Thread ID:

Created:

Updated:

Platform:

Replies:

112497 Sep 25,2013 01:12 PM Oct 1,2013 07:11 AM WPF 3
loading
Tags: ReportViewer
Ronnie
Asked On September 25, 2013 01:12 PM

I am currently looking at Syncfusion Reports. I found out that you are using *.rdlc files to generate the report. Do you have samples that changes the content of a report before the rdlc is loaded on runtime?

For e.g. I have a Title label which I would like to change its location, width, height, font face before I load the report.

Thank you.

Anandakumar S [Syncfusion]
Replied On September 26, 2013 08:23 AM

Hi Ronnie,

 

Thanks for using Syncfusion Products.

 

You can modify the rdlc report contents using Syncfusion ReportDesigner. Please find attached sample for your reference.

 

RDLC sample:

http://www.syncfusion.com/downloads/support/directtrac/general/PreviewRDCL1320517865425448622.zip

 

Customization samples:

http://www.syncfusion.com/uploads/user/directTrac/111476/Report Designer-2127117473.zip

 

Please let us know if you have any questions.

 

Regards,

Anandakumar S


Ronnie
Replied On September 28, 2013 10:53 AM

Hello Anandakumar,

Thanks for your reply and examples. However I don't want the user be able to change the layout of the report themselves.

Let say I have an *.rdl file which has a Title and Description saved as centered. Then I have these certain users or clients of my application that when they load this rdl file, the Title and Description must be positioned Right Aligned. I would like to achieve this before loading the report and on runtime.

Anandakumar S [Syncfusion]
Replied On October 1, 2013 07:11 AM

Hi Ronnie,

 

Thanks for your update.

 

You can change the report in code behind by modifying needed properties of report items in the ReportDefinition. Please find the sample code to modify ReportDefinition below.

 

Serializing Report and modifying the ReportDefinition.

 

FileInfo info = new FileInfo("../../Sales Report.rdl");

FileStream stream = new FileStream(info.FullName, FileMode.Open, FileAccess.Read, FileShare.Read);

XElement rdl = XElement.Load(XmlReader.Create(stream));

string Namespace = (from attribute in rdl.Attributes() where attribute.Name.LocalName == 'xmlns' select attribute.Value).FirstOrDefault();

string Version = (Regex.IsMatch(Namespace, @'\d{4}') ? Regex.Match(Namespace, @'\d{4}').Value : string.Empty);

XmlSerializer xs = new XmlSerializer(typeof(Syncfusion.RDL.DOM.ReportDefinition), Namespace);

Syncfusion.RDL.DOM.ReportDefinition report;

using (StringReader reader = new StringReader(rdl.ToString()))

{

report = (Syncfusion.RDL.DOM.ReportDefinition)xs.Deserialize(reader);

}

//Similarly you can change the positions of Header,Footer items of the report from the collection report.Page.PageFooter.ReportItems and report.Page.PageHeader.ReportItems

foreach (var reportItem in report.Body.ReportItems)

{

reportItem.Height = new Syncfusion.RDL.DOM.Size(25);

reportItem.Width = new Syncfusion.RDL.DOM.Size(150);

//Position of the reportitem

reportItem.Left = new Syncfusion.RDL.DOM.Size(180);

reportItem.Top = new Syncfusion.RDL.DOM.Size(180);

}

 

Please let us know if you have any questions.

 

Thanks,

Anandakumar S


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;