Telerik Forums
Reporting Forum
5 answers
485 views
Hello,

From the documentation, it doesn't seem hard to create a report programmatically: 

Telerik.Reporting.Report report = new Telerik.Reporting.Report();
  
            string sql = @"SELECT * FROM Recipient";
            string connectionString = "Data Source=EVAN-PC\\SQLEXPRESS;Initial Catalog=AccufloMaster;Integrated Security=True;User ID=sa;Password=creative";
            System.Data.SqlClient.SqlDataAdapter adapter = new System.Data.SqlClient.SqlDataAdapter(sql, connectionString);
            report.DataSource = adapter;
            report.Name = "recipientReport";
              
            return View(report);




However, After I have the report created, how do I view it using the MVC report viewer (which I already have set up). Are there some additional properties I need to set? Ideally, I thought I could just pass the entire Report object to the view and into the viewer, but there is no overlord for that. So once I have the report created programmatically (I have to do this for reasons beyond this thread), how I can view it in the report viewer?


@model Telerik.Reporting.Report
 
 
@using Telerik.Reporting.Examples.CSharp
@{
    ViewBag.Title = "Telerik HTML5 Report Viewer MVC Demo";
}
 
@section styles
{
 
 
 
    <style>
        #reportViewer1 {
            position: absolute;
            left: 5px;
            right: 5px;
            top: 5px;
            bottom: 5px;
            overflow: hidden;
            font-family: Verdana, Arial;
        }
    </style>
 
    <link href="@Url.Content("~/ReportViewer/styles/telerikReportViewer-8.1.14.804.css")" rel="stylesheet" />
}
 
@{
    var typeReportSource = new TypeReportSource() { TypeName = typeof(ReportCatalog).AssemblyQualifiedName };
   // typeReportSource.Parameters.Add("OrderNumber", Model.SelectedInvoice);
    //ReportSource(new UriReportSource() { Uri = "Product Catalog.trdx" })
}
 
 
@(Html.TelerikReporting().ReportViewer()
        // Each report viewer must have an id - it will be used by the initialization script
        // to find the element and initialize the report viewer.
        .Id("reportViewer1")
        // The url of the service which will provide the report viewer with reports.
        // The service must be properly configured so that the report viewer can
        // successfully communicate with the server.
        // For more information on how to configure the service please check http://www.telerik.com/help/reporting/telerik-reporting-rest-conception.html.
        .ServiceUrl(Url.Content("~/api/reports/"))
        // The url for the report viewer template. The template can be edited -
        // new functionalities can be added and unneeded ones can be removed.
        // For more information please check http://www.telerik.com/help/reporting/html5-report-viewer-templates.html.
        .TemplateUrl(Url.Content("~/ReportViewer/templates/telerikReportViewerTemplate-8.1.14.804.html"))
        // Strongly typed ReportSource - TypeReportSource or UriReportSource.
        .ReportSource(Model.Name)
        // Specifies whether the viewer is in interactive or print preview mode.
        // PRINT_PREVIEW - Displays the paginated report as if it is printed on paper. Interactivity is not enabled.
        // INTERACTIVE - Displays the report in its original width and height witn no paging. Additionally interactivity is enabled.
        .ViewMode(ViewModes.PRINT_PREVIEW)
        // Sets the scale mode of the viewer.
        // Three modes exist currently:
        // FIT_PAGE - The whole report will fit on the page (will zoom in or out), regardless of its width and height.
        // FIT_PAGE_WIDTH - The report will be zoomed in or out so that the width of the screen and the width of the report match.
        // SPECIFIC - Uses the scale to zoom in and out the report.
        .ScaleMode(ScaleModes.SPECIFIC)
        // Zoom in and out the report using the scale
        // 1.0 is equal to 100%, i.e. the original size of the report
        .Scale(1.0)
        // Sets whether the viewer’s client session to be persisted between the page’s refreshes(ex. postback).
        // The session is stored in the browser’s sessionStorage and is available for the duration of the page session.
        .PersistSession(false)
        // Sets the print mode of the viewer.
        .PrintMode(PrintMode.AutoSelect)
)
 
@section scripts
{  
    <!--kendo.all.min.js can be used as well instead of kendo.web.min.js and kendo.mobile.min.js-->
    <script src="@Url.Content("~/ReportViewer/js/telerikReportViewer-8.1.14.804.js")"></script>
 
    <!--kendo.mobile.min.js - optional, if gestures/touch support is required-->
 
}

Stef
Telerik team
 answered on 10 Oct 2014
5 answers
552 views
I am currently working on a Range Bar graph that has dates on it.
It reads data from a database and displays properly, my only problem is that when there is a lot of data the rows (shrink) get very small to allow for all the data to fit.  Is there a way to adjust the rows so that they stay a constant height and the graph itself grows in height to fit all the data points?

This first image is one that doesnt have many datapoints in it:


then once I add more data into the database i get this:

So is there any way to keep the rows a constant height and just increase the total high of the graph to fit the extra data in without making it smaller?

Thanks








Nasko
Telerik team
 answered on 10 Oct 2014
3 answers
484 views
I built a small test web application using your mvc how to and example reports and everything worked great. I then replicated my steps inside of a larger web application and when I try to bring up a report inside the html 5 viewer now I get an "Internal Server Error: undefined" message inside the viewer. No further information that I can see. What can I do to find out what's wrong? Trial and error so far has not resulted in anything...

Thanks
Jan
Top achievements
Rank 1
 answered on 09 Oct 2014
8 answers
595 views
Hi,

We have installed Report Designer Q2 2014, Visual Studio Express 2012 for Web and Oracle DB 11g. Right now I am able to design a report, connect to the Oracle DB by using SqlDataSource and able to preview the report contents as well.

Now in Visual Studio Web Forms Solutions, I have couple of issues:

Issue 1:

When I added the Telerik controls to Toolbox section from 'C:\Program Files (x86)\Telerik\Reporting Q2 2014\Bin\Telerik.Reporting.dll', it added all the controls but only ReportViewer is enabled and rest are disabled. In my understanding I cannot use any Telerik controls except the ReportViewer, why is these disabled?

Issue 2:

I have added the ReportViewer to my aspx page and have set the ReportSource to the .trdx file I designed. When I run that web page to view the report I am keep getting a error as below:

-----------
An
error has occurred while processing Table 'table1':
A network-related or instance-specific error occurred while establishing
a connection to SQL Server. The server was not found or was not
accessible. Verify that the instance name is correct and that SQL Server
is configured to allow remote connections. (provider: Named Pipes
Provider, error: 40 - Could not open a connection to SQL Server)
------------- InnerException -------------
The network path was not found
--------------

As I had read in one of the thread (sorry I am not able to get that thread link) that, we need to install ODP.Net to connect to the Oracle DB from VS.Net. So I had installed the ODP.Net (ODAC121012) as well. But still I am getting the same error. One thing, I am not able to understand is, even though I have connected the Report to Orcle DB, why in the error it's says that 'Could not open the connection to SQL Server'.

Can some one please guide me on this as earliest?

Regards,

Sree Harshavardhana
Sree Harshavardhana
Top achievements
Rank 1
 answered on 09 Oct 2014
4 answers
591 views
I followed the wizzard and made no changes to the report layout besides what the wizzard did and when I export to Excel there are two extra blank rows between every row of data.  What is causing this?

The report has a labels group header and detail...
Stef
Telerik team
 answered on 09 Oct 2014
3 answers
92 views
Hello,
I am using sub-reports. I have a report containing two sub-report. Each sub report points to different business data object. 
In the sub-reports how can we arrange data so that it makes more sense?
In the report you can see the data appears mixed, please refer attachment.
First nine columns are from (Column A to J) subreport1 and last four columns  (Column K to N) are from subreport2.
Can we do some arrangements so that the data is separated as per red markings?
I want data item 2 to start in subrepor1 after we are finished displaying data for data item 1 in subreport2. 
Please advice.
Regards,
Sandeep
Stef
Telerik team
 answered on 08 Oct 2014
5 answers
1.3K+ views
Hi,
I'm trying to generate a labeling report form which contains several text boxes, a bar-code section and quantity.
What I would like to do is that setting up a column and create a loop to iterate the column as much an exact number the quantity values.
(FYI : the column has a two sided labels.)

I think, all I need to do is create a loop only in Detail section/OR create a loop WITH Detail section.
So, I generated a form and put all boxes and a barcode in the detail section.
I wrote a code behind by using method; ReportItemBase[] ItemCollection in C#

http://www.telerik.com/community/forums/reporting/telerik-reporting/loop-through-all-controls.aspx

Unfortunately, I can not create a loop to iterate the column as much an exact number of the quantity values.

Change settings, conditional formatting and code behind
Any concerns and comments would be appreciated it.

Sincerely,
H

bob
Top achievements
Rank 1
 answered on 08 Oct 2014
2 answers
108 views
Hi

I am trying to build a report programmatically. In this report I try to add a textbox on PageHeader.
But the report is still empty. 

I search solution in forum, but I didn't see someone needing help to this problem.

This is a part of what I did, it might be something wrong, I dont know.

Panel PanelMonth = Construct_Panel("PanelMonth", this.Width.Value, 0.2, 0, 0);
TextBox LblMonth= Construct_TextBox("LblMonth", this.Width.Value, 0.2, 0, 0, " October");
PanelMonth.Items.Add(LblMonth);
this.pageHeaderSection1.Items.Add(PanelMonth);

Please, can you help me, thanks in advance

Paul S.

Pauline
Top achievements
Rank 1
 answered on 07 Oct 2014
2 answers
135 views
Hi

I'm trying to set a background image on a bubble chart, but I haven't managed to get it to appear. It works fine if I set a background on the overall graph, but not on the plotareastyle.

The code generated from the designer is below, any idea where I'm going wrong.

Another quick question, I'm trying to use a background image instead of Marked Zones, as these don't seem to be supported on the Graph object - are they hiding on the Graph object under another name anywhere?

Thanks

---

namespace ReportTest
{
partial class Report1
{
#region Component Designer generated code
/// <summary>
/// Required method for telerik Reporting designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
Telerik.Reporting.GraphGroup graphGroup1 = new Telerik.Reporting.GraphGroup();
Telerik.Reporting.GraphGroup graphGroup4 = new Telerik.Reporting.GraphGroup();
Telerik.Reporting.GraphTitle graphTitle1 = new Telerik.Reporting.GraphTitle();
Telerik.Reporting.NumericalScale numericalScale1 = new Telerik.Reporting.NumericalScale();
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Report1));
Telerik.Reporting.NumericalScale numericalScale2 = new Telerik.Reporting.NumericalScale();
Telerik.Reporting.DataColumn dataColumn1 = new Telerik.Reporting.DataColumn();
Telerik.Reporting.DataColumn dataColumn2 = new Telerik.Reporting.DataColumn();
Telerik.Reporting.DataColumn dataColumn3 = new Telerik.Reporting.DataColumn();
Telerik.Reporting.DataColumn dataColumn4 = new Telerik.Reporting.DataColumn();
Telerik.Reporting.GraphGroup graphGroup2 = new Telerik.Reporting.GraphGroup();
Telerik.Reporting.GraphGroup graphGroup3 = new Telerik.Reporting.GraphGroup();
Telerik.Reporting.Drawing.StyleRule styleRule1 = new Telerik.Reporting.Drawing.StyleRule();
this.detailSection1 = new Telerik.Reporting.DetailSection();
this.graph1 = new Telerik.Reporting.Graph();
this.cartesianCoordinateSystem1 = new Telerik.Reporting.CartesianCoordinateSystem();
this.graphAxis1 = new Telerik.Reporting.GraphAxis();
this.graphAxis2 = new Telerik.Reporting.GraphAxis();
this.csvDataSource1 = new Telerik.Reporting.CsvDataSource();
this.lineSeries1 = new Telerik.Reporting.LineSeries();
((System.ComponentModel.ISupportInitialize)(this)).BeginInit();
//
// detailSection1
//
this.detailSection1.Height = Telerik.Reporting.Drawing.Unit.Cm(11.795207977294922D);
this.detailSection1.Items.AddRange(new Telerik.Reporting.ReportItemBase[] {
this.graph1});
this.detailSection1.Name = "detailSection1";
//
// graph1
//
graphGroup1.Name = "seriesGroup";
this.graph1.CategoryGroups.Add(graphGroup1);
this.graph1.CoordinateSystems.Add(this.cartesianCoordinateSystem1);
this.graph1.DataSource = this.csvDataSource1;
this.graph1.Docking = Telerik.Reporting.DockingStyle.Fill;
this.graph1.Legend.Style.LineColor = System.Drawing.Color.LightGray;
this.graph1.Legend.Style.LineWidth = Telerik.Reporting.Drawing.Unit.Cm(0D);
this.graph1.Legend.Style.Visible = false;
this.graph1.Location = new Telerik.Reporting.Drawing.PointU(Telerik.Reporting.Drawing.Unit.Cm(0D), Telerik.Reporting.Drawing.Unit.Cm(0D));
this.graph1.Name = "graph1";
this.graph1.PlotAreaStyle.BackgroundImage.ImageData = ((System.Drawing.Image)(resources.GetObject("graph1.PlotAreaStyle.BackgroundImage.ImageData")));
this.graph1.PlotAreaStyle.BackgroundImage.MimeType = "image/png";
this.graph1.PlotAreaStyle.BackgroundImage.Repeat = ((Telerik.Reporting.Drawing.BackgroundRepeat)((Telerik.Reporting.Drawing.BackgroundRepeat.RepeatX | Telerik.Reporting.Drawing.BackgroundRepeat.RepeatY)));
this.graph1.PlotAreaStyle.LineColor = System.Drawing.Color.LightGray;
this.graph1.PlotAreaStyle.LineWidth = Telerik.Reporting.Drawing.Unit.Cm(0D);
this.graph1.PlotAreaStyle.Visible = true;
this.graph1.Series.Add(this.lineSeries1);
graphGroup4.Groupings.Add(new Telerik.Reporting.Grouping("=Fields.Label"));
graphGroup4.Name = "labelGroup";
graphGroup4.Sortings.Add(new Telerik.Reporting.Sorting("=Fields.Label", Telerik.Reporting.SortDirection.Asc));
this.graph1.SeriesGroups.Add(graphGroup4);
this.graph1.Size = new Telerik.Reporting.Drawing.SizeU(Telerik.Reporting.Drawing.Unit.Cm(17.799999237060547D), Telerik.Reporting.Drawing.Unit.Cm(11.795207977294922D));
this.graph1.Style.BackgroundImage.MimeType = "image/png";
this.graph1.Style.Padding.Bottom = Telerik.Reporting.Drawing.Unit.Pixel(10D);
this.graph1.Style.Padding.Left = Telerik.Reporting.Drawing.Unit.Pixel(10D);
this.graph1.Style.Padding.Right = Telerik.Reporting.Drawing.Unit.Pixel(10D);
this.graph1.Style.Padding.Top = Telerik.Reporting.Drawing.Unit.Pixel(10D);
graphTitle1.Position = Telerik.Reporting.GraphItemPosition.TopCenter;
graphTitle1.Style.LineColor = System.Drawing.Color.LightGray;
graphTitle1.Style.LineWidth = Telerik.Reporting.Drawing.Unit.Cm(0D);
graphTitle1.Text = "October 2014";
this.graph1.Titles.Add(graphTitle1);
//
// cartesianCoordinateSystem1
//
this.cartesianCoordinateSystem1.Name = "cartesianCoordinateSystem1";
this.cartesianCoordinateSystem1.XAxis = this.graphAxis1;
this.cartesianCoordinateSystem1.YAxis = this.graphAxis2;
//
// graphAxis1
//
this.graphAxis1.MajorGridLineStyle.LineColor = System.Drawing.Color.LightGray;
this.graphAxis1.MajorGridLineStyle.LineWidth = Telerik.Reporting.Drawing.Unit.Pixel(1D);
this.graphAxis1.MinorGridLineStyle.LineColor = System.Drawing.Color.LightGray;
this.graphAxis1.MinorGridLineStyle.LineWidth = Telerik.Reporting.Drawing.Unit.Pixel(1D);
this.graphAxis1.MinorGridLineStyle.Visible = false;
this.graphAxis1.Name = "graphAxis1";
numericalScale1.Maximum = 10D;
numericalScale1.Minimum = 0D;
this.graphAxis1.Scale = numericalScale1;
this.graphAxis1.Title = "X - Label";
//
// graphAxis2
//
this.graphAxis2.MajorGridLineStyle.LineColor = System.Drawing.Color.LightGray;
this.graphAxis2.MajorGridLineStyle.LineWidth = Telerik.Reporting.Drawing.Unit.Pixel(1D);
this.graphAxis2.MajorGridLineStyle.Visible = true;
this.graphAxis2.MinorGridLineStyle.LineColor = System.Drawing.Color.LightGray;
this.graphAxis2.MinorGridLineStyle.LineWidth = Telerik.Reporting.Drawing.Unit.Pixel(1D);
this.graphAxis2.MinorGridLineStyle.Visible = false;
this.graphAxis2.Name = "graphAxis2";
numericalScale2.Maximum = 10D;
numericalScale2.Minimum = 0D;
this.graphAxis2.Scale = numericalScale2;
this.graphAxis2.Title = "Y - Label";
//
// csvDataSource1
//
dataColumn1.Name = "A";
dataColumn1.Type = Telerik.Reporting.SimpleType.Integer;
dataColumn2.Name = "B";
dataColumn2.Type = Telerik.Reporting.SimpleType.Integer;
dataColumn3.Name = "C";
dataColumn3.Type = Telerik.Reporting.SimpleType.Integer;
dataColumn4.Name = "Label";
this.csvDataSource1.Columns.Add(dataColumn1);
this.csvDataSource1.Columns.Add(dataColumn2);
this.csvDataSource1.Columns.Add(dataColumn3);
this.csvDataSource1.Columns.Add(dataColumn4);
this.csvDataSource1.FieldSeparators = new char[] {
','};
this.csvDataSource1.HasHeaders = true;
this.csvDataSource1.Name = "csvDataSource1";
this.csvDataSource1.RecordSeparators = new char[] {
'\r',
'\n'};
this.csvDataSource1.Source = "A,B,C,Label\r\n1,2,3,Item One\r\n2,3,5,Item Two\r\n5,4,9,Item Three\r\n8,6,14,Item Four";
//
// lineSeries1
//
graphGroup2.Name = "seriesGroup";
this.lineSeries1.CategoryGroup = graphGroup2;
this.lineSeries1.CoordinateSystem = this.cartesianCoordinateSystem1;
this.lineSeries1.DataPointLabel = "=Fields.Label + \",\" + Sum(Fields.C)";
this.lineSeries1.DataPointLabelStyle.Visible = true;
this.lineSeries1.DataPointStyle.Visible = true;
this.lineSeries1.LegendItem.Value = "C";
this.lineSeries1.LineStyle.LineWidth = Telerik.Reporting.Drawing.Unit.Pixel(1D);
this.lineSeries1.LineStyle.Visible = false;
this.lineSeries1.MarkerMaxSize = Telerik.Reporting.Drawing.Unit.Pixel(50D);
this.lineSeries1.MarkerMinSize = Telerik.Reporting.Drawing.Unit.Pixel(5D);
this.lineSeries1.MarkerSize = Telerik.Reporting.Drawing.Unit.Pixel(5D);
this.lineSeries1.MarkerType = Telerik.Reporting.DataPointMarkerType.Circle;
this.lineSeries1.Name = "lineSeries1";
graphGroup3.Groupings.Add(new Telerik.Reporting.Grouping("=Fields.Label"));
graphGroup3.Name = "labelGroup";
graphGroup3.Sortings.Add(new Telerik.Reporting.Sorting("=Fields.Label", Telerik.Reporting.SortDirection.Asc));
this.lineSeries1.SeriesGroup = graphGroup3;
this.lineSeries1.Size = "=Sum(Fields.C)";
this.lineSeries1.X = "=Sum(Fields.A)";
this.lineSeries1.Y = "=Sum(Fields.B)";
//
// Report1
//
this.Items.AddRange(new Telerik.Reporting.ReportItemBase[] {
this.detailSection1});
this.Name = "Report1";
this.PageSettings.Margins = new Telerik.Reporting.Drawing.MarginsU(Telerik.Reporting.Drawing.Unit.Mm(25.399999618530273D), Telerik.Reporting.Drawing.Unit.Mm(25.399999618530273D), Telerik.Reporting.Drawing.Unit.Mm(25.399999618530273D), Telerik.Reporting.Drawing.Unit.Mm(25.399999618530273D));
this.PageSettings.PaperKind = System.Drawing.Printing.PaperKind.A4;
styleRule1.Selectors.AddRange(new Telerik.Reporting.Drawing.ISelector[] {
new Telerik.Reporting.Drawing.TypeSelector(typeof(Telerik.Reporting.TextItemBase)),
new Telerik.Reporting.Drawing.TypeSelector(typeof(Telerik.Reporting.HtmlTextBox))});
styleRule1.Style.Padding.Left = Telerik.Reporting.Drawing.Unit.Point(2D);
styleRule1.Style.Padding.Right = Telerik.Reporting.Drawing.Unit.Point(2D);
this.StyleSheet.AddRange(new Telerik.Reporting.Drawing.StyleRule[] {
styleRule1});
this.Width = Telerik.Reporting.Drawing.Unit.Cm(17.799999237060547D);
((System.ComponentModel.ISupportInitialize)(this)).EndInit();

}
#endregion

private Telerik.Reporting.DetailSection detailSection1;
private Telerik.Reporting.Graph graph1;
private Telerik.Reporting.CartesianCoordinateSystem cartesianCoordinateSystem1;
private Telerik.Reporting.GraphAxis graphAxis1;
private Telerik.Reporting.GraphAxis graphAxis2;
private Telerik.Reporting.CsvDataSource csvDataSource1;
private Telerik.Reporting.LineSeries lineSeries1;

}
}


Stef
Telerik team
 answered on 07 Oct 2014
3 answers
127 views
Hello

i follow this sample to create a report multi column.

http://www.telerik.com/help/reporting/advanced-creating-multi-column-reports.html


But i have the column on top to bottom , not the left to right,
i try with 2 columns or 3 Columns or 4 , it's the same,

What is the good way to get a good report multi column ? like this

http://demos.telerik.com/reporting/product-tags/demo.aspx

thanks for your help
Nasko
Telerik team
 answered on 07 Oct 2014
Top users last month
Chester
Top achievements
Rank 1
Iron
Simon
Top achievements
Rank 1
Iron
Douglas
Top achievements
Rank 2
Iron
Iron
SUNIL
Top achievements
Rank 3
Iron
Iron
Iron
Marco
Top achievements
Rank 3
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?