Telerik Forums
Reporting Forum
1 answer
1.0K+ views

I created a report with subreport in Standalone Report Designer. I want to export it to PDF programmatically. I created an example Windows Form Application which gets parameters from user with textboxes. And when user writes values to its indicated textbox and then presses export to pdf. Then my application export it to pdf. But I have something wrong there. I must get the datasource or connection from my report file in order to set it in the program. How can I do this ?

I will share my app's picture.

Here is my code : 

 

01.    private void BtnExportPDF_Click(object sender, EventArgs e)
02.    {
03.        var reportProcessor = new Telerik.Reporting.Processing.ReportProcessor();
04. 
05.        // set any deviceInfo settings if necessary
06.        var deviceInfo = new System.Collections.Hashtable();
07. 
08. 
09. 
10.        //                  -2-
11.        // ***Declarative (TRDP/TRDX) report definitions***
12.        var reportSource = new UriReportSource();
13. 
14.        // reportName is the path to the TRDP/TRDX file
15.        reportSource.Uri = @"C:\Users\OE\Desktop\TelerikReport\Deneme.trdp";
16.        //var reportPackager = new ReportPackager();
17.        //using (var sourceStream = System.IO.File.OpenRead(@"C:\Users\OE\Desktop\TelerikReport\Deneme.trdp"))
18.        //{
19.        //    var report = (Report)reportPackager.UnpackageDocument(sourceStream);
20.        //}
21.        //Telerik.Reporting.SqlDataSource sqlDataSource = new Telerik.Reporting.SqlDataSource();
22.        //sqlDataSource.ProviderName = "System.Data.SqlClient";
23.        //sqlDataSource.ConnectionString = "Data Source=(local)\\SQLEXPRESS;Initial Catalog=AdventureWorks;Integrated Security=True";
24.         
25. 
26.        //                  -2-
27. 
28.        //                  -3-
29.        // ***Instance of the report definition***
30.        //var reportSource = new Telerik.Reporting.InstanceReportSource();
31. 
32.        // Report1 is the class of the report. It should inherit Telerik.Reporting.Report class
33.        //reportSource.ReportDocument = new Report1();
34.        //                  -3-
35.        object parameterValue = txtBasDep.Text;
36.        reportSource.Parameters.Add("basdepid", parameterValue);
37.        object parameterValue1 = txtBitDep.Text;
38.        reportSource.Parameters.Add("bitdepid", parameterValue1);
39.        object parameterValue2 = txtSonDogum.Text;
40.        reportSource.Parameters.Add("sondogumtar", parameterValue2);
41. 
42.        Telerik.Reporting.Processing.RenderingResult result = reportProcessor.RenderReport("PDF", reportSource, deviceInfo);
43. 
44.        // Pass parameter value with the Report Source if necessary
45. 
46. 
47.        string fileName = result.DocumentName + "." + result.Extension;
48.        string path = @"C:\Users\OE\Desktop\TelerikReport";
49.        string filePath = System.IO.Path.Combine(path, fileName);
50. 
51.        using (System.IO.FileStream fs = new System.IO.FileStream(filePath, System.IO.FileMode.Create))
52.        {
53.            fs.Write(result.DocumentBytes, 0, result.DocumentBytes.Length);
54.        }
55. 
56.        MessageBox.Show("The report has been exported!", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
57.    }
58.}
Silviya
Telerik team
 answered on 16 Sep 2019
1 answer
148 views

Hello,

I have an old code that works perfectly until today.

i use html5 reporting viewer to display the report.

when user click on print button - the chrome print dialog should be display, but in chrom 77 it's doesn't work.

I try debbuging the code, it seems that work and not failed but nothing happend:

 function printDesktop(src) {
            if (!iframe) {
                iframe = document.createElement("IFRAME");
                iframe.style.display = "none";
            }
            iframe.src = src;
            document.body.appendChild(iframe);
        }

 

Thanks,

Sari

Neli
Telerik team
 answered on 16 Sep 2019
1 answer
89 views

Hi, attached you will find a simple graph with lines. But, as you can see, the value for the fisrt tear 2018 is 0.2, but ius display the point above the second year 2019 even its value is higher (0.3)

Please also want to know how to ignore 0 or null point, in the same image 2019 and posteriors year does not has values yet, so we need to ignore them (lines must ends at the last point with value)

 

Thanks

Alejandro

 

Alejandro Genovesi
Top achievements
Rank 2
 answered on 13 Sep 2019
3 answers
125 views
Hello, The print button in the reports we made with Telerik Reporting 6.0.12.215 does not work after Chrome's new update. They all worked until yesterday. Can you check in urgently? All of our reports have begun to embarrass.
Neli
Telerik team
 answered on 12 Sep 2019
1 answer
106 views

We have a .NET Core Web API project.  Our TRDP and TRDX files are located in wwwroot/reports/.

At design time in the Standalone Designer, the reports preview as expected with the correct data.

That SAME report file at runtime does not request the data, the data method is not invoked.

The below method takes the report, processes it, but the data method never gets called by the report processor.  

I've look at the TRDX file and the assembly name, method and parameter is in the correctly.

 

What could possibly cause this?  The controller has access to the data source assembly and can execute the methods, but the report processor method that is in the same controller, does not invoke the data method.

Thank you in advance,

Karl

 private HttpResponseMessage MakePdfResult(ReportSource report)
        {
            var rp = new ReportProcessor();
            var pdf = rp.RenderReport("PDF", report, null);
            var result = new HttpResponseMessage { Content = new ByteArrayContent(pdf.DocumentBytes) };
            result.Content.Headers.ContentType = new MediaTypeHeaderValue("application/pdf");
            return result;
        }

Karl
Top achievements
Rank 1
 answered on 12 Sep 2019
1 answer
962 views

On our test server if we set Storage to default location which is in C:\Windows\TEMP folder we get unauthorized access exception, would setting Storage to "C:/Temp" cause any security issues, or are there better standard locations for storing temp files?

Telerik.Reporting.Services.ReportServiceConfiguration ReportConfiguration = new Telerik.Reporting.Services.ReportServiceConfiguration
    {
        ReportResolver = new ReportFileResolver(HttpContext.Current.Server.MapPath("~/MyReports"))
                .AddFallbackResolver(new ReportTypeResolver()),
        Storage = new Telerik.Reporting.Cache.File.FileStorage()
    };

 

Silviya
Telerik team
 answered on 12 Sep 2019
1 answer
86 views

Loading failed.

Is it just on my computer?   Chrome/IE on Win7, WinServer 12

Silviya
Telerik team
 answered on 11 Sep 2019
2 answers
655 views

I'm trying to follow the info on this page: https://docs.telerik.com/reporting/programmatic-exporting-report. However it doesn't show what the TypeName should be. I've tried many variations from other examples but I always get this error when the RenderReport line tries to execute: 

Exception Details: System.ArgumentNullException: Value cannot be null.
Parameter name: type

 

var PDFSource = new TypeReportSource();
PDFSource.TypeName = "rptVAC";
var ReportProcessor = new ReportProcessor();
PDFSource.Parameters.Add(new Telerik.Reporting.Parameter("VACId", vacId));
var result = ReportProcessor.RenderReport("PDF", PDFSource, null);
Larry
Top achievements
Rank 1
 answered on 10 Sep 2019
2 answers
237 views

Hi everyone,

I have updated the telerik reporting version from R1 2019(13.0.19.123)  to R2 2019 (13.1.19.618) version. I use Visual Studio 2017 but can't see into Report Designer for VS2017 the JSON datasource or CSV Datasource.  I mean are these features only appear in Standalone Report Designer or they has been included into Visual Studio Report Desginer?

See image #1 and #2 attached in order to see what is the popup I see in VS Report Designer when I try to connect with a Service.

 

Thanks,

David G.

Todor
Telerik team
 answered on 10 Sep 2019
1 answer
805 views
My View
 
<style>
 
        #reportViewer1 {
            position: relative;
            width: 1300px;
            height: 900px;
        }
    </style>
 
@(Html.TelerikReporting().ReportViewer()
        .Id("reportViewer1")
        .ServiceUrl(Url.Content("/api/reports/"))
        .TemplateUrl("/Resources/Templates/telerikReportViewerTemplate.html")
        .ReportSource(new UriReportSource() { Uri = "Report1.trdp" })
        .ViewMode(ViewMode.Interactive)
        .ScaleMode(ScaleMode.Specific)
        .Scale(1.0)
        .PersistSession(false)
        .PrintMode(PrintMode.AutoSelect)
)
 
My controller
 
namespace OvalWeb.Controllers
{
    using System.IO;
    using System.Web;
    using Telerik.Reporting.Cache.File;
    using Telerik.Reporting.Services;
    using Telerik.Reporting.Services.Engine;
    using Telerik.Reporting.Services.WebApi;
 
    //The class name determines the service URL.
    //ReportsController class name defines /api/report/ service URL.
    public class ReportsController : ReportsControllerBase
    {
        static ReportServiceConfiguration preservedConfiguration;
 
        static IReportServiceConfiguration PreservedConfiguration
        {
            get
            {
                if (null == preservedConfiguration)
                {
                    preservedConfiguration = new ReportServiceConfiguration
                    {
                        HostAppId = "OvalWebReport",
                        Storage = new FileStorage("C:/Storage"),
                        ReportResolver = CreateResolver(),
                        // ReportSharingTimeout = 0,
                        // ClientSessionTimeout = 15,
                    };
                }
                return preservedConfiguration;
            }
        }
 
        public ReportsController()
        {
            this.ReportServiceConfiguration = PreservedConfiguration;
        }
 
        static IReportResolver CreateResolver()
        {
            var appPath = HttpContext.Current.Server.MapPath("~/");
            var reportsPath = Path.Combine(appPath, @"Report\Designs\Ventas\Tickets\Familia");
 
            return new ReportFileResolver(reportsPath)
                .AddFallbackResolver(new ReportTypeResolver());
        }
    }
}

 

It shows me the error attached.

What could be the problem?

Francisco
Top achievements
Rank 1
 answered on 10 Sep 2019
Top users last month
Ambisoft
Top achievements
Rank 2
Iron
Pascal
Top achievements
Rank 2
Iron
Matthew
Top achievements
Rank 1
Sergii
Top achievements
Rank 1
Andrey
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?