Telerik Forums
Reporting Forum
1 answer
1.0K+ views

Hi, 

I am trying to create a report that includes a table dynamically generated, I will not use the viewer control, just I would like to generate the table from a DataTable but after compose the with the method "GenerateTable" and save the file I always get the error "An error has occurred while processing Table 'xxxx':
Table Body has 2 rows but 0 are expected"

What is wrong?, any help would be appreciated.

namespace ReportLibrary
{
    partial class GenericReport
    {
        #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.Drawing.StyleRule styleRule1 = new Telerik.Reporting.Drawing.StyleRule();
            this.pageHeaderSection1 = new Telerik.Reporting.PageHeaderSection();
            this.detail = new Telerik.Reporting.DetailSection();
            this.pageFooterSection1 = new Telerik.Reporting.PageFooterSection();
            ((System.ComponentModel.ISupportInitialize)(this)).BeginInit();
            //
            // pageHeaderSection1
            //
            this.pageHeaderSection1.Height = Telerik.Reporting.Drawing.Unit.Inch(1D);
            this.pageHeaderSection1.Name = "pageHeaderSection1";
            //
            // detail
            //
            this.detail.Height = Telerik.Reporting.Drawing.Unit.Inch(2D);
            this.detail.Name = "detail";
            //
            // pageFooterSection1
            //
            this.pageFooterSection1.Height = Telerik.Reporting.Drawing.Unit.Inch(1D);
            this.pageFooterSection1.Name = "pageFooterSection1";
            //
            // GenericReport
            //
            this.Items.AddRange(new Telerik.Reporting.ReportItemBase[] {
            this.pageHeaderSection1,
            this.detail,
            this.pageFooterSection1});
            this.Name = "GenericReport";
            this.PageSettings.Margins = new Telerik.Reporting.Drawing.MarginsU(Telerik.Reporting.Drawing.Unit.Inch(1D), Telerik.Reporting.Drawing.Unit.Inch(1D), Telerik.Reporting.Drawing.Unit.Inch(1D), Telerik.Reporting.Drawing.Unit.Inch(1D));
            this.PageSettings.PaperKind = System.Drawing.Printing.PaperKind.Letter;
            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.Inch(6.125D);
            ((System.ComponentModel.ISupportInitialize)(this)).EndInit();
 
        }
        #endregion
 
        private Telerik.Reporting.PageHeaderSection pageHeaderSection1;
        private Telerik.Reporting.DetailSection detail;
        private Telerik.Reporting.PageFooterSection pageFooterSection1;
    }
}

 

 

namespace ReportLibrary
{
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Windows.Forms;
    using Telerik.Reporting;
    using Telerik.Reporting.Drawing;
 
    /// <summary>
    /// Summary description for GenericReport
    /// </summary>
    public partial class GenericReport : Telerik.Reporting.Report
    {
        private DataSet dataSet;
 
        public GenericReport(DataSet dataSet)
        {
            //
            // Required for telerik Reporting designer support
            //
            InitializeComponent();           
 
            //
            // TODO: Add any constructor code after InitializeComponent call
            //    
 
            foreach (DataTable dataTable in dataSet.Tables)
            {
                Telerik.Reporting.Table table = null;
                table  = GenerateTable(dataTable);
                this.detail.Items.Add(table);                  
            }                  
        }
 
        private Telerik.Reporting.Table GenerateTable(DataTable dataTable)
        {
            Telerik.Reporting.Table table = new Table();
            table.Name = dataTable.TableName;
             
            //Create columns
            int counterColumn = 0;
            foreach (System.Data.DataColumn column in dataTable.Columns)
            {
                //Add column
                table.Body.Columns.Add(new Telerik.Reporting.TableBodyColumn(Telerik.Reporting.Drawing.Unit.Inch(1D)));            
                 
                //Create group to include column
                Telerik.Reporting.TableGroup tmpTableGroup = new Telerik.Reporting.TableGroup();
                tmpTableGroup.Name = "tableGroup" + counterColumn;
                 
                //Column textBox
                Telerik.Reporting.TextBox tmpTextBox = new Telerik.Reporting.TextBox();
                tmpTextBox.Name = column.ColumnName;
                tmpTextBox.Value = column.ColumnName;
 
                tmpTableGroup.ReportItem = tmpTextBox;
                table.ColumnGroups.Add(tmpTableGroup);
 
                table.Items.Add(tmpTextBox);
 
                counterColumn++;
            }
 
            //Create rows
            int counterRow = 0;
            foreach (System.Data.DataRow row in dataTable.Rows)
            {               
                table.Body.Rows.Add(new Telerik.Reporting.TableBodyRow(Unit.Pixel(50)));
 
                for (int i = 0; i < dataTable.Columns.Count; i++)
                {
                    Telerik.Reporting.TextBox tmpTextBox = new Telerik.Reporting.TextBox();
                    tmpTextBox.Name = "dd";
                    tmpTextBox.Value = row.ItemArray[i].ToString();
                    tmpTextBox.Size = new Telerik.Reporting.Drawing.SizeU(Telerik.Reporting.Drawing.Unit.Inch(1D), Telerik.Reporting.Drawing.Unit.Inch(1D));
 
                    table.Body.SetCellContent(counterRow, i, tmpTextBox);                  
                    table.Items.Add(tmpTextBox);
                }
 
                counterRow++;
            }
             
            table.Location = new Telerik.Reporting.Drawing.PointU(Telerik.Reporting.Drawing.Unit.Inch(0.20000000298023224D), Telerik.Reporting.Drawing.Unit.Inch(0.30000001192092896D));
                        
            return table;
        }
                      
    }
}

 

FMorales
Top achievements
Rank 1
 answered on 11 May 2017
2 answers
220 views

Hi,

I have report which dynamically create a htmltextbox. Upon exporting to Excel via Report Viewer, the htmltextbox where merge. Is it possible to set it to nowrap and not merge programatically?.  (Please see Attachment.) 

I tried to set  can grow to false/true but no luck.

Appreciate your help.

Thank you.

private Telerik.Reporting.HtmlTextBox CreateTxtHeader(string FieldName, double swidth, double PosX, double PosY, bool isBold)
    {
        Telerik.Reporting.HtmlTextBox txtHead = new Telerik.Reporting.HtmlTextBox();
        txtHead.Size = new Telerik.Reporting.Drawing.SizeU(Unit.Inch(swidth), Telerik.Reporting.Drawing.Unit.Inch(0.3));
        txtHead.Location = new Telerik.Reporting.Drawing.PointU(Telerik.Reporting.Drawing.Unit.Inch(PosX), Telerik.Reporting.Drawing.Unit.Inch(PosY));
        txtHead.Style.BorderStyle.Default = BorderType.None;
        txtHead.Style.Font.Bold = isBold;
        txtHead.Style.Font.Size = Telerik.Reporting.Drawing.Unit.Point(intScale);
        txtHead.Style.Font.Name = "Arial";
        txtHead.Style.TextAlign = HorizontalAlign.Left;
        txtHead.Style.VerticalAlign = VerticalAlign.Middle;
        txtHead.StyleName = FieldName;
        txtHead.Value = FieldName;
        txtHead.CanGrow = true;
        return txtHead;
    }

 

-Im using Telerik Reporting Q3 2015 9.2.15.930

Von Aaron
Top achievements
Rank 2
 answered on 11 May 2017
2 answers
225 views

Hi,

I need to modify, when loading, a picturebox value from a report generated in TRDX and kept in a DB.

I know that's maybe because my knowlage is limitated... but after several tries and too many hours searching I can't find the correct way. Anyone can help??

I'm develloping in asp.net webforms, c#, VS2013.

Here'a a code snippet of my question:

 

XmlReportSource mapa = new XmlReportSource();
string xml = dal.LeMapa(connection, Session["Report"].ToString());
mapa.Xml = xml.Replace("DBDev",connection);
mapa.Parameters.Add("Sigla", Session["Sigla"].ToString());
ReportViewer.ReportSource = mapa;

XmlReportSource instanceReportSource = (XmlReportSource)this.ReportViewer.ReportSource;
Report report = (Report)instanceReportSource.ToString();
PictureBox img = report.Items.Find("logo", true)[0] as PictureBox;
DataTable dt = dal.LeLogoEmpresa(Connection);
if (dt.Rows.Count > 0)
    foreach (DataRow dr in dt.Rows)
    {
        img.Value = dr["Logotipo"];
        img.MimeType = dr["ImgTip"].ToString();
        break;
}

How canI find the picturebox??

Thanks.

Stef
Telerik team
 answered on 10 May 2017
1 answer
157 views

I created a report and am exporting it as an XLS.  How do I set the Scale of the report so that when I open it up in Excel it shows as 60% instead of 100%?

 

thanks

Stef
Telerik team
 answered on 10 May 2017
1 answer
696 views

Hello,

I have designed a report with the report wizzard and used the table template for the layout. The dataSource comes from an azure sql database. In preview and html preview I get all records displayed properly on one single page ( ... notice that the entry in Report.Properties.ApplicationSettings.DataSource is set to 'none' !!).

Now I want to group the records, but when I go to add new group, in the 'Edit Grouping / new expression' there is no field to select.

Otherwise, when I enter in Report.Properties.ApplicationSettings.DataSource the same dataSource that I selected when the report was built with the wizzard, I can select a field in the 'Edit Grouping' dialog -> but then in preview and html preview I get 101 pages each with all the same records on it (besides it takes a lot of time to show them eventually).

Please help

Regards, Manfred

 

Katia
Telerik team
 answered on 10 May 2017
1 answer
69 views

Hi,

I was using the Telerik reporting which uses SubReports, everything was working on just fine on Telerik Reporting Q1 2016 SP1 (version 10.0.16.204) but upon updating the version  to telerik reporting R3 2016 (version 10.2.16.914) it stopped working, it looks like the lifecycle has changed. 

Katia
Telerik team
 answered on 10 May 2017
1 answer
177 views

<select all> is missing in html5 for MultiValue parameter.

In the report designer I see the <slect all> option but it does not display in the html5 version.

How can I get that to display correctly?

Marty

Stef
Telerik team
 answered on 09 May 2017
5 answers
238 views

Hello,
here is a list of problems I find with the WPF report viewer and some possible enhancements:

1. In the print preview mode, when the zoom is set to ”Whole page”, the code calculates a zoom factor. Doing so, it makes a round of the value, instead of a ceiling. The result is that, depending on the size of the window, there are sometimes a scroller that is shown and active. For example, if the zoom to display the whole page is 108.4%, it is displayed with a zoom of 108% and the scroller appears.

2. The whole control is enclosed in a border. In the case the control is displayed in a window, and only it is in the window, this border should not be there: please add an option to disable the border. At least, bind the BorderThickness property of the control to this border.

3. There are 2 display mode: Interactive view and print preview. In some cases, the interactive view is not useful, so there should be a way to disable the button, or better remove it. At the same time the button is removed, you should also remove the first 4 buttons, which are only used in this mode.

4. The export button content should be customizable: we should be able to specify which formats are displayed there.

Patrick
-         
In
the print preview mode, when the zoom is set to ”Whole page”, the code
calculates a zoom factor. Doing so, it makes a round of the value, instead of a
ceiling. The result is that, depending on the size of the window, there are
sometimes a scroller that is shown and active. For example, if the zoom to
display the whole page is 108.4%, it is displayed with a zoom of 108% and the
scroller appears.

-         
The
whole control is enclosed in a border. In the case the control is displayed in
a window, and only it is in the window, this border should not be there: please
add an option to disable the border. At least, bind the BorderThickness
property of the control to this border.

-         
There
are 2 display mode: Interactive view and print preview. In some cases, the
interactive view is not useful, so there should be a way to disable the button,
or better remove it. At the same time the button is removed, you should also
remove the first 4 buttons, which are only used in this mode.

-         
The
export button content should be customizable: we should be able to specify
which formats are displayed there.


 

Stef
Telerik team
 answered on 09 May 2017
1 answer
347 views

In our UI, the user has the ability to export their reports to multiple formats including PowerPoint.

We have noticed that the PowerPoint exports don't always work.  Sometimes, the reports will go to PowerPoint with not issue and sometimes they it seems the export will just stop and the download is never received.

One thing that I have noticed is the reports that return larger amounts of data seem to not work as reliably.  They will render in the report viewer, but the PowerPoint export never shows up.

Any help is appreciated.

Thanks,

Phillip

Katia
Telerik team
 answered on 09 May 2017
1 answer
128 views

Hello,

We have recent upgraded from Reporting Q2 2015 SP1 to Reporting R1 2017 SP2 11.0.17.406 and we are having an issue with report books. Anything that causes a refresh causes all of the parameter viewstates to collapse. If we fill them with pre-saved values and attempt to display the report book, they also collapse and rendering the book fails because no parameters can now be found. Not experiencing this issue with single reports, only report books.

Is there somewhere i should be looking specifically to address this? Using VS2017's debugger did not help much, only to show that the viewstates are gone before the first parameter is ever retrieved. Any insight would be most appreciated.

Katia
Telerik team
 answered on 09 May 2017
Top users last month
Shiori
Top achievements
Rank 2
Iron
Tien
Top achievements
Rank 1
Iron
Robert
Top achievements
Rank 1
Rob
Top achievements
Rank 4
Bronze
Bronze
Iron
Geoff
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?