Telerik Forums
Reporting Forum
4 answers
147 views
Hi
I just made a small code pice to put in a row in a report. Just put the code in your report file and call it from your construter.

Sample 1: eks. "addEndRow("Hallo");
 /// <summary> 
        /// Tilføjer den sidste række data til denne siden  
        /// </summary> 
        /// <param name="tekst">Den tekst der skal stå i rækken</param> 
        public void addEndRow(string tekst)  
        {  
            if (tekst == null)    // Undersøger om tekst er null hvis dette sættes tekst til en tom string  
            {  
                tekst = "";     // Sætter tekst til en tom string  
            }  
 
            // Oprettelse af panel til indhold af tekstboks             
            var panel_1 = new Panel  
            {  
                Size =  
                    new SizeU(  
                    new Unit(10.45,  
                             ((UnitType.Cm))),  
                    new Unit(1,  
                             ((UnitType.Cm)))),  
                Dock = DockStyle.Left,  
                Style = { BorderStyle = { Default = BorderType.Solid } }  
            };  
 
            // Oprettelse af tekstboks til indhold af tekst  
            var textBox_1 = new TextBox  
            {  
                Value = tekst,  
                Dock = DockStyle.Top,  
                Style =  
                {  
                    TextAlign = HorizontalAlign.Left,  
                    VerticalAlignVerticalAlign = VerticalAlign.Top  
                },  
                Height = new Unit(1.5, UnitType.Cm),  
                Width = new Unit(1, UnitType.Cm),  
            };  
 
            panel_1.Items.AddRange(new ReportItemBase[] { textBox_1 });  
            panel_1.Dock = DockStyle.Top;  
 
            //Tilføjer panel til detail delen i rapporten  
            detail.Items.Add(panel_1);  
        } 

Sample 2. data is a array of string with lengh 6. addDataRow("1", "tekst_1", "tekst_2", new string[] { "x", "-", "-", "-", "-", "-" });
  /// <summary> 
        /// Opretter en række til at indsætte data i  
        /// </summary> 
        /// <param name="nr">det nummer der skal stå i det første felt</param> 
        /// <param name="tekst_1">Den tekst der skal stå i den første række</param> 
        /// <param name="tekst_2">Den tekst der skal stå i den anden række</param> 
        /// <param name="data">Dette er et array med "X" eller " ". De tjekmark som skal anvendes</param> 
        public void addDataRow(string nr, string tekst_1, string tekst_2, string[] data)  
        {  
            // Undersøger paremere for null  
            if (nr == null)  
            {  
                nr = "<n/a>";  
            }  
 
            if (tekst_1 == null)  
            {  
                tekst_1 = "<n/a>";  
            }  
 
            if (tekst_2 == null)  
            {  
                tekst_2 = "<n/a>";  
            }  
 
            if (data != null)  
            {  
                if (data.Length != 6)  
                    throw new Exception("Data længde på rapport forkert. Længde = " + data.Length +  
                                        ", men skulle være 6. ");  
            }  
            else  
            {  
                throw new Exception("data = null: fejl");  
            }  
 
            // Oprettelse af paneler  
            var panel_1 = new Panel  
                              {  
                                  Size =  
                                      new SizeU(  
                                      new Unit(10.45,  
                                               ((UnitType.Cm))),  
                                      new Unit(1,  
                                               ((UnitType.Cm)))),  
                                  Dock = DockStyle.Left,  
                                  Style = { BorderStyle = { Default = BorderType.Solid } }  
                              };  
            var panel_2 = new Panel  
                              {  
                                  Dock = DockStyle.Left,  
                                  Style = { BorderStyle = { Left = BorderType.Solid } },  
                                  Size =  
                                      new SizeU(  
                                      new Unit(10.446890830993652,  
                                               ((UnitType.Cm))),  
                                      new Unit(1.5,  
                                               ((UnitType.Cm))))  
                              };  
            var panel_3 = new Panel  
                              {  
                                  Width = new Unit(3.5, UnitType.Cm),  
                                  Height = new Unit(1.5, UnitType.Cm),  
                                  Style = { BorderStyle = { Left = BorderType.Solid } },  
                                  Dock = DockStyle.Right  
                              };  
            var panel_4 = new Panel { Dock = DockStyle.Right };  
 
            // Oprettelse af tekstbokse  
            var textBox_1 = new TextBox  
                                {  
                                    Value = nr,  
                                    Dock = DockStyle.Left,  
                                    Style =  
                                        {  
                                            TextAlign = HorizontalAlign.Center,  
                                            VerticalAlignVerticalAlign = VerticalAlign.Middle,  
                                        },  
                                    Height = new Unit(1.5, UnitType.Cm),  
                                    Width = new Unit(1, UnitType.Cm)  
                                };  
            var textBox_2 = new TextBox  
                                {  
                                    Value = tekst_1,  
                                    Height = new Unit(0.5, UnitType.Cm),  
                                    Dock = DockStyle.Top,  
                                    Style = { BorderStyle = { Bottom = BorderType.Solid } }  
 
                                };  
            var textBox_3 = new TextBox  
                                {  
                                    Dock = DockStyle.Top,  
                                    Value = tekst_2,  
                                    Height = new Unit(0.5, UnitType.Cm)  
                                };  
            var textBox_4 = new TextBox  
                                {  
                                    Size =  
                                        new SizeU(  
                                        new Unit(0.5,  
                                                 ((UnitType.Cm))),  
                                        new Unit(1.5,  
                                                 ((UnitType.Cm)))),  
                                    Style =  
                                        {  
                                            TextAlign = HorizontalAlign.Center,  
                                            VerticalAlignVerticalAlign = VerticalAlign.Middle,  
                                            BorderStyle =  
                                                {  
                                                    Left = BorderType.Solid,  
                                                    Right = BorderType.Solid  
                                                }  
                                        },  
                                    Value = data[2],  
                                    Dock = DockStyle.Right  
                                };  
            var textBox_5 = new TextBox  
                                {  
                                    Size =  
                                        new SizeU(  
                                        new Unit(0.5,  
                                                 ((UnitType.Cm))),  
                                        new Unit(1.5,  
                                                 ((UnitType.Cm)))),  
                                    Style =  
                                        {  
                                            TextAlign = HorizontalAlign.Center,  
                                            VerticalAlignVerticalAlign = VerticalAlign.Middle,  
                                            BorderStyle = { Left = BorderType.Solid }  
                                        },  
                                    Value = data[1],  
                                    Dock = DockStyle.Right  
                                };  
            var textBox_6 = new TextBox  
                                {  
                                    Size =  
                                        new SizeU(  
                                        new Unit(0.5,  
                                                 ((UnitType.Cm))),  
                                        new Unit(1.5,  
                                                 ((UnitType.Cm)))),  
                                    Style =  
                                        {  
                                            TextAlign = HorizontalAlign.Center,  
                                            VerticalAlignVerticalAlign = VerticalAlign.Middle  
                                        },  
                                    Value = data[0],  
                                    Dock = DockStyle.Right  
                                };  
            var textBox_7 = new TextBox  
                                {  
                                    Size =  
                                        new SizeU(  
                                        new Unit(0.5,  
                                                 ((UnitType.Cm))),  
                                        new Unit(1.5,  
                                                 ((UnitType.Cm)))),  
                                    Style =  
                                        {  
                                            TextAlign = HorizontalAlign.Center,  
                                            VerticalAlignVerticalAlign = VerticalAlign.Middle,  
                                            BorderStyle = { Left = BorderType.Solid }  
                                        },  
                                    Value = data[5],  
                                    Dock = DockStyle.Right  
                                };  
            var textBox_8 = new TextBox  
                                {  
                                    Size =  
                                        new SizeU(  
                                        new Unit(0.5,  
                                                 ((UnitType.Cm))),  
                                        new Unit(1.5,  
                                                 ((UnitType.Cm)))),  
                                    Style =  
                                        {  
                                            TextAlign = HorizontalAlign.Center,  
                                            VerticalAlignVerticalAlign = VerticalAlign.Middle,  
                                            BorderStyle = { Left = BorderType.Solid }  
                                        },  
                                    Value = data[4],  
                                    Dock = DockStyle.Right  
                                };  
            var textBox_9 = new TextBox  
                                {  
                                    Size =  
                                        new SizeU(  
                                        new Unit(0.5,  
                                                 ((UnitType.Cm))),  
                                        new Unit(1.5,  
                                                 ((UnitType.Cm)))),  
                                    Style =  
                                        {  
                                            TextAlign = HorizontalAlign.Center,  
                                            VerticalAlignVerticalAlign = VerticalAlign.Middle,  
                                            BorderStyle = { Left = BorderType.Solid }  
                                        },  
                                    Value = data[3],  
                                    Dock = DockStyle.Right  
                                };  
 
            panel_2.Items.AddRange(new ReportItemBase[] { textBox_2, textBox_3 });  // Indsætter tekstboks 1 og 2 i panel 2  
            panel_4.Width = new Unit(0.5, UnitType.Cm);                             // Sætter bredden på panel 4 til 0.5 cm  
            panel_4.Height = new Unit(1, UnitType.Cm);                              // Sætter højden på panel 4 til 1 cm  
 
            panel_3.Items.AddRange(new ReportItemBase[] { textBox_7, textBox_8, textBox_9, panel_4, textBox_4, textBox_5, textBox_6 });     // Indsætter tekstbokse og panler i panel 3  
            panel_1.Items.AddRange(new ReportItemBase[] { textBox_1, panel_2, panel_3 });   // Indsætter tekstbokse og paneler i panel1  
            panel_1.Dock = DockStyle.Top;                                           // Dockter panel 1 til top  
 
            if (detail != null)                                                     // Underøsger om detail sektionens objekt er null  
            {  
                detail.Items.Add(panel_1);                                          // Indsætter panel 1 i detail sektoinen som er det område som indeholder hoved- data i rapporten  
            }  
        } 

Sample 3: setData(@"c:\pic1.jpg", "This is fine"); // Put in a path for a foto.
        /// <summary>  
        /// Sætter billed ind på siden  
        /// </summary>  
        /// <param name="filename">Sti til der hvor der ligger en billed fil</param>  
        /// <param name="text">Den firgur tekst der står under billedet</param>  
        /// <param name="s">Størrelse på billed</param>  
        public void setData(string filename, string text, params SizeU[] s)  
        {  
            try 
            {  
                if (!File.Exists(filename))  
                {  
                    text += Environment.NewLine + "Filen blev ikke fundet (" + filename + ")";  
                }  
 
                //Opretter tekstboks til at indeholde tekst der skal stå under hver billed  
                using (var textBox_1 = new TextBox  
                                           {  
                                               Size = new SizeU(new Unit(2, UnitType.Cm),  
                                                                new Unit(0.6, UnitType.Cm)),  
                                               Value = ("Figur " + figur_nr + ": " + text),  
                                               Dock = DockStyle.Top,  
                                               Multiline = true,  
                                               Style = {TextAlign = HorizontalAlign.Center}  
                                           })  
                {  
                    using (var pictureBox_1 = new PictureBox  
                                                  {  
                                                      Dock = DockStyle.Top,  
                                                      Value = new Bitmap(filename),  
                                                      Sizing = ImageSizeMode.ScaleProportional,  
                                                      Size = new SizeU(Unit.Cm(10), Unit.Cm(10))  
                                                  })  
                    {  
                        detail.Items.Add(pictureBox_1); // Indsætter billed objekt  
                    }  
                    detail.Items.Add(textBox_1); // Indsætter tekst der står under billedet  
                }  
 
                figur_nr++; // Forøger figur_nr med en   
            }  
 
            catch (Exception ex)  
            {  
                //Opretter tekstboks med fejlbesked i  
                var textBox_1 = new TextBox  
                                    {  
                                        Size =  
                                            new SizeU(  
                                            new Unit(2.0000002384185791, UnitType.Cm),  
                                            new Unit(0.60000020265579224, UnitType.Cm)),  
                                        Value =  
                                            ("Der opstod en fejl i indsættelse af billeder i PDF. Fejl:" + ex.Message),  
                                        Dock = DockStyle.Top,  
                                        Multiline = true,  
                                        Style = {TextAlign = HorizontalAlign.Center}  
                                    };  
 
                detail.Items.Add(textBox_1); // Indsætter tekst fejlbeskrivelse  
            }  
        } 

Sample 4: 

AddRow(

"Type", "Name", "Adress", "Phone number.:"); // Put in a Row. Call this metode to build op a page of rows with stuff 

        /// <summary>  
        /// Opretter en række med de personer som har medvirket til dette eftersyn  
        /// </summary>  
        /// <param name="str1">Faggruppebeskrivelse (type)</param>  
        /// <param name="str2">JuridiskNavn (navn mm.)</param>  
        /// <param name="str3">Adresse (Består af adr1 og adr2)</param>  
        /// <param name="str4">Telefonnummer. Det telefon nummer som anvendes til at kontakte denne person</param>  
        public void AddRow(string str1, string str2, string str3, string str4)  
        {  
            if (str1 == null)  
            {  
                str1 = "";  
            }  
 
            if (str2 == null)  
            {  
                str2 = "";  
            }  
            if (str3 == null)  
            {  
                str3 = "";  
            }  
            if (str4 == null)  
            {  
                str4 = "";  
            }  
 
            // Oprettelse af paneler  
            var panel_1 = new Panel  
            {  
                Size =  
                    new SizeU(  
                    new Unit(15,  
                             ((UnitType.Cm))),  
                    new Unit(0.5,  
                             ((UnitType.Cm)))),  
                Dock = DockStyle.Right,  
                Style = { BorderStyle = { Default = BorderType.Solid } }  
            };  
            var panel_3 = new Panel  
            {  
                Width = new Unit(15, UnitType.Cm),  
                Height = new Unit(0.5, UnitType.Cm),  
                Style = { BorderStyle = { Left = BorderType.None } },  
                Dock = DockStyle.Left  
            };  
            var panel_4 = new Panel { Dock = DockStyle.Right };  
 
            // Oprettelse af tekstbokse  
            var textBox_7 = new TextBox  
            {  
                Size =  
                    new SizeU(  
                    new Unit(3.5,  
                             ((UnitType.Cm))),  
                    new Unit(0.5,  
                             ((UnitType.Cm)))),  
                Style =  
                {  
                    TextAlign = HorizontalAlign.Left,  
                    VerticalAlign = VerticalAlign.Middle,  
                    BorderStyle = { Left = BorderType.Solid }  
                },  
                Value = str1,  
                Dock = DockStyle.Left  
            };  
 
            var textBox_8 = new TextBox  
            {  
                Size =  
                    new SizeU(  
                    new Unit(3.5,  
                             ((UnitType.Cm))),  
                    new Unit(0.5,  
                             ((UnitType.Cm)))),  
                Style =  
                {  
                    TextAlign = HorizontalAlign.Left,  
                    VerticalAlign = VerticalAlign.Middle,  
                    BorderStyle = { Left = BorderType.Solid }  
                },  
                Value = str2,  
                Dock = DockStyle.Left  
            };  
 
            var textBox_9 = new TextBox  
            {  
                Size =  
                    new SizeU(  
                    new Unit(3.5,  
                             ((UnitType.Cm))),  
                    new Unit(0.5,  
                             ((UnitType.Cm)))),  
                Style =  
                {  
                    TextAlign = HorizontalAlign.Left,  
                    VerticalAlign = VerticalAlign.Middle,  
                    BorderStyle = { Left = BorderType.Solid }  
                },  
                Value = str3,  
                Dock = DockStyle.Left  
            };  
 
            var textBox_10 = new TextBox  
            {  
                Size =  
                    new SizeU(  
                    new Unit(3.5,  
                             ((UnitType.Cm))),  
                    new Unit(0.5,  
                             ((UnitType.Cm)))),  
                Style =  
                {  
                    TextAlign = HorizontalAlign.Left,  
                    VerticalAlign = VerticalAlign.Middle,  
                    BorderStyle = { Left = BorderType.Solid }  
                },  
                Value = str4,  
                Dock = DockStyle.Right  
            };  
 
            panel_3.Items.AddRange(new ReportItemBase[] { textBox_7, textBox_9, textBox_8, textBox_10 });  
 
            panel_1.Items.AddRange(new ReportItemBase[] { panel_3 });  
            panel_1.Dock = DockStyle.Top;  
 
            if (str2.Length < 2 && str3.Length < 2 && str4.Length < 2)  
            {  
                panel_1.Style.BorderStyle.Default = BorderType.None;  
                panel_3.Style.BorderStyle.Left = BorderType.None;  
                textBox_9.Style.BorderStyle.Left = BorderType.None;  
                textBox_8.Style.BorderStyle.Left = BorderType.None;  
                // textBox_7.Style.BorderStyle.Left = BorderType.None;  
                textBox_10.Style.BorderStyle.Left = BorderType.None;  
                //textBox_10.Style.BorderStyle.Right = BorderType.Solid;  
                panel_1.Style.BorderStyle.Right = BorderType.Solid;  
                textBox_7.Style.Font.Bold = true;  
            }  
 
            if (detail != null)  
                detail.Items.Add(panel_1);  
        }  
 

Sincerely,
Janus S. Andersen
Janus Pedersen
Top achievements
Rank 2
 answered on 19 Feb 2009
7 answers
292 views
Hi

Reporting's TextBox.WordWrap does not appear to function.

With WordWrap set to false, I still get wrapping instead of truncating.

Designer view

HTML report view

version is beta 2.
Mike
Top achievements
Rank 1
 answered on 18 Feb 2009
1 answer
291 views
Hello,

I load the data for several of my reports through a web services layer, which can sometimes be a tad slow (as you might expect). I display a Windows Form dialog that has a report viewer embedded in it, and the dialog then requests the report data asynchronously.

What I would like to do is force the report viewer to show the "progress" animation while I'm out fetching data through the web service. But there doesn't seem to be a method within the viewer class that would support such.

Is there a way to do this? If so, how?
Steve
Telerik team
 answered on 18 Feb 2009
1 answer
118 views
Hi,

Can I put a RadGrid Control inside Report control? it'll be a great help in reporting issues.

Thanks
Steve
Telerik team
 answered on 18 Feb 2009
1 answer
221 views
HI,

    I just like to know if it's possible to create the index in the Telerik Reporting?  that means, i have a report that shows the page number with some content, and i will have another page just display certain keywords with the page number after it?

Thanks.
Steve
Telerik team
 answered on 18 Feb 2009
1 answer
122 views
Hello! I'm just getting used to the report designer, so these could totally be my ignorance - if there's a good way to do what i'm asking, please enlighten me!

Here are two things I'm missing from the designer (that are -gasp- included in competitive products):
1) Since my datasources aren't accessible at design time, I would LOVE to be able to specify a DataSourceSchema at design time and point it at an .xsd file, for instance (which I could easily make from my data objects by doing a WriteXmlSchema,say), so that the designer could still give me a list of fields and such.

2) The designer snap-to-grid is a bit odd.  If I set my snap to grid size at .05 inches, and start dragging a text box, I get snap sizes that are just a bit shy of the grid - for example, it will snap to .89in by .34 in, rather than .9 by .35.  Perhaps this is done to prevent text boxes from overlapping, however I WANT them to overlap - I have a very boxy form to reproduce and having to adjust them all manually is a bummer.  My output format is PDF and can handle the overlap.  Can we get an option (or is there one) to actually snap everything to the grid?

Thanks,
Scott
Steve
Telerik team
 answered on 17 Feb 2009
1 answer
120 views
How do I create a common PageheaderSection for different of report.

I created a baseclass that inherits from telerik.reporting, this baseclass will create the header.
All my report will inherit from the baseclass in turn will have a method to setup the PageHeaderSection and PageHeaderFooter.  Is this the correct way of creating a common pageheadersection and pageheaderfooter?

Thanks,
Steve
Telerik team
 answered on 17 Feb 2009
3 answers
145 views
Hi,

I am currently evaluating the latest trial package of Telerik reporting. I  get the following error, when cancelling a export to excel (translated from SE to EN):

InvalidOperationException - Its not possible to call Invoke or BeginInvoke in a control before the window reference is created.

Is this a known issue and will it be ammended in future releases?

Also I would like to know why Telerik is considerably slower, compared to Crystal Report, when rendering the exact same report?

Br,
Jonas
Steve
Telerik team
 answered on 17 Feb 2009
8 answers
694 views
I am creating the subreports programmatically with the Dock property set to "Top".
The subreports render fine in the web viewer but when exported to pdf they overlap.
I have about 6 subreport in total, however only two of them are overlapping.

Any ideas?

Ryan Emptage
Top achievements
Rank 1
 answered on 17 Feb 2009
1 answer
135 views
Hello!  So I've noticed a really odd behavior in the report designer.  If I have a TextBox, with borders defined, and I do "Bring to Front" on that TextBox, after that it shows in the designer without borders - including if I go to "Styles..."  However when I build/rebuild the project, the borders (correctly) reappear.

If this isn't a known issue, let me know and I can provide more detail on how to reproduce...

-Scott
Steve
Telerik team
 answered on 16 Feb 2009
Top users last month
Edmond
Top achievements
Rank 1
Iron
fabrizio
Top achievements
Rank 2
Iron
Veteran
RobMarz
Top achievements
Rank 2
Iron
Fakhrul
Top achievements
Rank 1
Iron
Tejas
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?