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. Image for the cookie policy date
close icon
Starting in 2019, the Reporting control is no longer included in Essential Studio. If you're experiencing issues with the Syncfusion Reporting Platform, Report Viewer, Report Designer, or Report Writer, we recommend migrating to Bold Reports, our dedicated reporting platform.

Bold Reports offers a comprehensive suite of tools and features for all your reporting needs, and we will help you make a smooth transition from the discontinued control. Our support team at https://support.boldreports.com/ is here to assist you with any questions or difficulties you may encounter during the migration process.

We thank you for choosing Syncfusion and appreciate your understanding.

Changing the report content before the report is loaded on runtime

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.

3 Replies

AS Anandakumar S Syncfusion Team September 26, 2013 12:23 PM UTC

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



RO Ronnie September 28, 2013 02:53 PM UTC

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.


AS Anandakumar S Syncfusion Team October 1, 2013 11:11 AM UTC

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


Loader.
Live Chat Icon For mobile
Up arrow icon