Quantcast
Viewing all articles
Browse latest Browse all 11

Add any customize text in crystal reports by .net code

In my requirement I have to show few search parameter in crystal reports which is passed from aspx page.
And that is not hard coded fixed because I have 10-15 parameters and I want to place it dynamically if whatever parameter’s value available that only needs to be attach in reports.

So I have implemented this by below approaches.
In Crystal reports rpt file I have take one default fields with “SearchTextRight” and “SearchTextLeft” to display value left and right side corner.

This both fields “CanGrouw” property set as “True” and attach each of the search parameter by “\n” so automatically new line added and text object’s height will increased.
Below are the code we have used for that.

 ReportClass rptH = GenerateReportClasss(Server.MapPath("~/Reports/GetReortData.rpt"));
            
            /// Attach serarch fields

            SearchDraw oSearchDrow = AttachCustomerHours(collection);
            if (oSearchDrow.SearchingStringLeft != string.Empty)
            {
                TextObject SeachTextLeft = (TextObject)rptH.ReportDefinition.ReportObjects["SearchTextLeft"];
                SeachTextLeft.Text = oSearchDrow.SearchingStringLeft;
            }
            if (oSearchDrow.SearchingStringRight != string.Empty)
            {
                TextObject SeachTextRight = (TextObject)rptH.ReportDefinition.ReportObjects["SearchTextRight"];
                SeachTextRight.Text = oSearchDrow.SearchingStringRight;
            }
            AttachLocalizationCustomerHours(rptH);
            rptH.Refresh();

            rptH.SetDataSource(Ds.Tables[0]);

Now all text will attached in reports’ PDF or excel file.

Let me know for more details

Thanks,
Amit Patel
amitpatel.it@gmail.com
“Enjoy Programming”


Image may be NSFW.
Clik here to view.
Image may be NSFW.
Clik here to view.

Viewing all articles
Browse latest Browse all 11

Trending Articles