Telerik Forums
Reporting Forum
3 answers
718 views
Hello,
Currently I'm using Telerik Reporting as internal rendering process of file request. During initialization in MVC application I have following code:
var reportDefinitionFile = Path.Combine(dataFolder, company, "Notice.trdx");
 
            if (!System.IO.File.Exists(reportDefinitionFile))
            {
                throw new HttpException((int)HttpStatusCode.NotFound, "File not found.");
            }
 
            var xmlSerializer = new ReportXmlSerializer();
            var reportDocument = (Report)xmlSerializer.Deserialize(reportDefinitionFile);
 
            reportDocument.ReportParameters["ContactId"].Value = n.ToString("D");
 
            var sds = (SqlDataSource)reportDocument.DataSource;
            sds.ConnectionString = database.ConnectionString;
 
            this.SetConnectionString(reportDocument.Items, database.ConnectionString);
 
            // create a ReportSource object
            var reportSource = new InstanceReportSource { ReportDocument = reportDocument };
            var reportProcessor = new ReportProcessor();
 
            RenderingResult result = reportProcessor.RenderReport("PDF", reportSource, null);
So as you can see I render file and return it normaly as MVC File
return File(result.DocumentBytes, "application/pdf", "File.pdf");
I'm also changing internal connection string because the same report can run against different databases:
private void SetConnectionString(IEnumerable<ReportItemBase> items, string connectionString)
        {
            foreach (ReportItemBase ib in items)
            {
                if (ib.Items != null)
                {
                    this.SetConnectionString(ib.Items, connectionString);
                }
 
                Type type = ib.GetType();
                PropertyInfo dataSourceProperty = type.GetProperty("DataSource");
                if (dataSourceProperty == null)
                {
                    continue;
                }
 
                var dataSource = dataSourceProperty.GetValue(ib, null) as System.Web.UI.WebControls.SqlDataSource;
                if (dataSource != null)
                {
                    dataSource.ConnectionString = connectionString;
                }
            }
        }

My question now is how to use report generated by line:
var reportSource = new InstanceReportSource { ReportDocument = reportDocument };
 in HTML5 MVC application?

I cannot find any example how to use such automatic report in new functionality.
Could you help me?
Stef
Telerik team
 answered on 06 Nov 2013
3 answers
90 views
I'm getting the following error when exporting to pdf, any idea?

Server Error in '/' Application.

Cannot set new clip region in an inner graphic state level.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.NotImplementedException: Cannot set new clip region in an inner graphic state level.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

[NotImplementedException: Cannot set new clip region in an inner graphic state level.]
   Telerik.Reporting.Pdf.Rendering.PdfRenderer.SetClip(GraphicsPath path, CombineMode combineMode) +267
   Telerik.Reporting.Pdf.Drawing.PdfGraphics.SetClip(GraphicsPath path, CombineMode combineMode) +72
   Telerik.Reporting.Pdf.Drawing.PdfGraphics.SetClip(RectangleF rect, CombineMode mode) +51
   Telerik.Reporting.ImageRendering.CanvasPdf.SetClip(RectangleF rect, CombineMode mode) +88
   Telerik.Reporting.ImageRendering.CanvasBase.SetClipOnPage(RectangleF rect, CombineMode mode) +85
   Telerik.Reporting.ImageRendering.RenderingElement.RenderToPage(RectangleRF clip, RoundedFloat parentLeft, RoundedFloat parentTop, RoundedFloat parentReservedTop, RoundedFloat parentReservedBottom, RoundedFloat parentReservedLeft, RoundedFloat parentReservedRight) +1102
   Telerik.Reporting.ImageRendering.CompositionBase.RenderPageSection(PageArea pageArea, RenderingElement pageSection, Single height) +585
   Telerik.Reporting.ImageRendering.CompositionBase.ApplyPageSections() +174
   Telerik.Reporting.ImageRendering.CompositionBase.SendPhysicalPages(Boolean force) +52
   Telerik.Reporting.ImageRendering.CompositionBase.End() +74
   Telerik.Reporting.ImageRendering.CompositionPdf.End() +39
   Telerik.Reporting.ImageRendering.CompositionBase.Dispose(Boolean disposing) +22
   Telerik.Reporting.ImageRendering.CompositionPdf.Dispose(Boolean disposing) +11
   Telerik.Reporting.ImageRendering.CompositionBase.System.IDisposable.Dispose() +17
   Telerik.Reporting.ImageRendering.ImageRendererBase.RenderReport(Report report, Hashtable renderingContext, Hashtable deviceInfo, CreateStream createStreamCallback, EvaluateHeaderFooterExpressions evalHeaderFooterCallback) +224
   Telerik.Reporting.ImageRendering.ImageRendererBase.Telerik.Reporting.Processing.IRenderingExtension.Render(Report report, Hashtable renderingContext, Hashtable deviceInfo, CreateStream createStreamCallback, EvaluateHeaderFooterExpressions evalHeaderFooterCallback) +21
   Telerik.Reporting.Processing.ReportProcessor.Render(IList`1 reports, ExtensionInfo extensionInfo, Hashtable renderingContext, Hashtable deviceInfo, CreateStream createStreamCallback) +427
   Telerik.Reporting.Processing.ReportProcessor.RenderReport(String format, IReportDocument reportDocument, Hashtable deviceInfo, Hashtable renderingContext, CreateStream createStreamCallback) +419
   Telerik.ReportViewer.WebForms.ServerReport.Render(HttpResponse response, String format, Int32 pageIndex) in ServerReport.cs:110
   Telerik.ReportViewer.WebForms.ReportExportOperation.PerformOperation(NameValueCollection urlQuery, HttpContext context) in ReportExportOperation.cs:15
   Telerik.ReportViewer.WebForms.HttpHandler.ProcessRequest(HttpContext context) in HttpHandler.cs:71
   System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +181
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +75


Version Information: Microsoft .NET Framework Version:2.0.50727.3603; ASP.NET Version:2.0.50727.3053
Stef
Telerik team
 answered on 06 Nov 2013
3 answers
302 views
Hi,

I have been using telerik version with aspx like this:

<script runat="server">
 public override void VerifyRenderingInServerForm(Control control)
 {
 // to avoid the server form (<form runat="server"> requirement
 }
 protected override void OnLoad(EventArgs e)
 {
    base.OnLoad(e);
    var instanceReportSource = new Telerik.Reporting.InstanceReportSource();
    instanceReportSource.ReportDocument = new UI.Web.Areas.Reporting.Test1();
    ReportViewer1.ReportSource = instanceReportSource;
 }
</script>
<form id="form1" runat="server">
    <telerik:ReportViewer ID="ReportViewer1" runat="server"></telerik:ReportViewer>
</form>

This worked fine. Now I would like to use MVC Report Viewer. So I went through the tutorial How-to: Using HTML5 Report Viewer extension in an ASP.NET MVC4 application But got stuck at the end. Problem is the part bellow:

@(Html.TelerikReporting().ReportViewer() _
    .Id("reportViewer1") _
    .ServiceUrl("/api/reports/") _
    .TemplateUrl("/ReportViewer/templates/telerikReportViewerTemplate.htmll") _
    .ReportSource(New UriReportSource() With {.Uri = "Product Catalog.trdx"}) _
    .ViewMode(ViewModes.INTERACTIVE) _
    .ScaleMode(ScaleModes.SPECIFIC) _
    .Scale(1.0) _
    .PersistSession(True)
)

I'm using Visual Studio integrated report designer and I don't have any html template or trdx file. So I at least figured out this code:

Html.TelerikReporting().ReportViewer()
       .Id("reportViewer1")
       .TemplateUrl("/Reporting/telerikReportViewerTemplate.html")
       .ReportSource(new Telerik.Reporting.TypeReportSource("UI.Web, Areas.Reporting.Test1"))
       .ViewMode(ViewModes.INTERACTIVE)
       .ScaleMode(ScaleModes.SPECIFIC)
       .Scale(1.0)
       .PersistSession(true)

But problem is that the template looks like whole report design for some tutorial and when I ommit the TemplateUrl method. I get exception that it is required, but I don't know how to get my own html template from VS designer.

Second problem is where should I set my DataSource? I thinks it should be somehow resolved in ReportsController from tutorial. Or should it be passed directly in the html extension?
Stef
Telerik team
 answered on 06 Nov 2013
2 answers
456 views
Hi! In one table I've got one column with client address, and for parsing purpose it has this char(:) like(st.:Some street,:apt.:30).

Of Course! I don't want to show this char in report.

So, the question is, how can I remove or replace this char from address column?
Thank You in advance!

Stef
Telerik team
 answered on 06 Nov 2013
5 answers
105 views
Hi,

After the update some reports suddenly have a border. I found that the report got a border with of 1pt, that i can change to 0pt.
So if i do that on al my reports then i'm ok.

But when we set a backgound image it does not stretch the report so you can only see a part of the backgoundimage.
The image is set from code behind like:

Bitmap imagedata =new Bitmap(Image.FromFile(HostingEnvironment.MapPath(string.Format("~/images/global/duplicaat-{0}.gif",languageId == 2 ? "FR" : "NL"))));

report.Style.BackgroundImage.ImageData = imagedata;


In de attached files you can see "licaat" while the image says "Duplicaat".

How can i make the report stretch to see the complete background image?
Koen L
Top achievements
Rank 1
 answered on 06 Nov 2013
1 answer
111 views
Hi,
I am trying to design report which will present for each row from SQL table some text boxes plus Tiff file in picture box which is bound to the row, Can I achieve it with Telerik Reporting? Any hints would be appreciated.
Jacek
Arron
Top achievements
Rank 1
 answered on 06 Nov 2013
5 answers
362 views
Hello. I have a textbox that is partially hiding some text before it wraps to the next line. The issue is very similar to this one: http://www.telerik.com/community/forums/reporting/telerik-reporting/issue-with-text-wrapping-in-textbox.aspx. I have tried all of the suggestions made in that thread with no luck.

I have the Reporting Q2 2013 version installed.

I've made the textbox display all of the text successfully by making the textbox extend past the 10.5in width but that messed up the printed version.

I've attached a screenshot of the problem. Notice how the right side is missing its text. That text IS THERE; I can highlight the text then copy/paste into Notepad++ and see all of the text.... just not in the report.

Can someone please help me figure this out? What other information would be helpful to you all?

One more thing, this is in a sub report. The main report and the subreport both have widths of 10.5in ( I've verified that ). 
Andrew
Top achievements
Rank 1
 answered on 05 Nov 2013
1 answer
208 views
Hi 
When we use the currency format on the reporting TextBox, there is no way to set the flow direction of the (wpf)TextBox.
As you can see on the attached image the currency mark is located right to the value.
When I use a wpf tool, such as snoop, i can see that when i set the flow direction leftToRight, the format is alligned as expected.
is there a way to change the flow direction of the (wpf)TextBox that is eventually generated by the report?
or, is there a way to allign it in another way?
Thanks
Nasko
Telerik team
 answered on 05 Nov 2013
5 answers
160 views
Hello everyone,

Since the latest Firefox update, the Report Viewer is unable to print the reports. I'm aware we need the Adobe Acrobat Plugin and of course this plugin is installed. In Internet Explorer everything works as normal.

This issue can be repoduced:
- Go to http://demos.telerik.com/reporting/barcodes/demo.aspx or any other report in the Report Viewer
- Click Print Button

Anyone have an idea to fix this issue?

Regards,

Jesse
Peter
Telerik team
 answered on 05 Nov 2013
1 answer
345 views
how to count non-null rows or rows that are not 1

I have a report and I want to get some totals where I show a total or all the rows that exist (there are rows that have null values and I don't want those counted) or I have a different column that is either zero or one and I want a count of all the 1's.

Problem is I am getting all the rows, regardless of the actual value.

I tried stuff like this for the 1's
= Count(Fields.MyValue = 1)
but that returns the same thing as 
= Count(Fields.MyValue)

Or looking for the values that are null I tried something like this
= Count(Fields.MyValue is not null)

How do I get a count of just the non-nulls or the 1's?
Squall
Top achievements
Rank 1
 answered on 04 Nov 2013
Top users last month
Rob
Top achievements
Rank 3
Bronze
Iron
Iron
Sergii
Top achievements
Rank 1
Iron
Iron
Dedalus
Top achievements
Rank 1
Iron
Iron
Lan
Top achievements
Rank 1
Iron
Doug
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?