Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
85
Publishing UltraWinChart and UltraWinGrid Together
posted

Hi ,

I want to  Publish UltraWinChart  and UltraWinGrid together to PDF as seen in the Image.

My Chart and Grid are Displayed like this in UI , I need same in PDF

 

I am new to infragistics , I have gone through the example provided in NetAdvantage Toolkit but couldn’t Figure out how to do it.

I am Using some random Code to  Horizontal Group Chart and Grid

 

 

Infragistics.Documents.Report.

IGroup group = s.AddGroup();

group.Borders = new Infragistics.Documents.Report.Borders(Infragistics.Documents.Graphics.Pens.Black);

group.Margins.Vertical = 5;

group.Paddings.All = 5;

 

 

 

group = s.AddGroup();

group.Layout = Infragistics.Documents.Report.

 

 

Layout.Horizontal;

 

 

Infragistics.Documents.Report.

ICanvas gCanvas = group.AddCanvas();

gCanvas.Width =

new Infragistics.Documents.Report.FixedWidth(200);

Infragistics.Documents.Report.

ICanvas gCanvas= group.AddCanvas();

gCanvas.Margins.All = 10;

gCanvas.Width = new Infragistics.Documents.Report.FixedWidth(200);

UltraChart.RenderPdfFriendlyGraphics(gCanvas.CreateGraphics());

 

//Exporting Grid

DocXport.Export(grdSalesData,section);

r.Publish(

"C:\\Report.pdf", FileFormat.PDF);

But When "DocXport.Export" called Its Seems Like it is Always Exporting the Grid in New page.

Is there any Example that will show ,How We can Do it ?

  • 295
    Offline posted
  • 85
    posted

    Thanks Mike For Your Prompt Reply.

    Finally I was able to Fulfill the requirement (Although I have to tweak the display of the Grid little bit, But Its O.k.)

     

    Here is The Logic.

     

    1)      Add a Horizontal Group To Section

    2)      Add the Chart as a Image to one Part of Group 

    3)      Add IGrid to Another part of Group.

    4)      Convert UltraGrid to IGrid By Adding Columns and Rows.

     

     

    Here is the Code Snippet:-

     

      private void ExportToPDF()

            {

                Infragistics.Documents.Report.Report r = new Infragistics.Documents.Report.Report();

                ISection section = null;

                section = r.AddSection();

     

                UltraGridDocumentExporter DocXport = new UltraGridDocumentExporter();

                IText text1 = section.AddText();

                text1.Alignment.Horizontal = Infragistics.Documents.Report.Alignment.Center;

                text1.Style = new Infragistics.Documents.Report.Text.Style(new Infragistics.Documents.Graphics.Font("Verdana", 14), Infragistics.Documents.Graphics.Brushes.Black);

                text1.AddContent("Client Portfolio List (At a glance MITESH)");

              

                // Setup Grid

                Infragistics.Documents.Report.Text.IText text = section.AddText();

                text.Style = normalStyle;

                text.Margins.Bottom = 5;

                text.AddContent("Grid");

     

                Infragistics.Documents.Report.IGroup group = section.AddGroup();

                group.Borders = new Infragistics.Documents.Report.Borders(Infragistics.Documents.Graphics.Pens.Black);

                group.Margins.Vertical = 5;

                group.Background = new Infragistics.Documents.Report.Background(new Infragistics.Documents.Graphics.Color(240, 240, 220));

     

                group = section.AddGroup();

                group.Layout = Infragistics.Documents.Report.Layout.Horizontal;

                group.Margins.Vertical = 5;

                group.Paddings.All = 5;

               

    //In case if You Don’t Want Chart as Image then You can Directly Add Chart to Canvas and add Canvas to Group

     

    //Infragistics.Documents.Report.ICanvas gcanvas = group.AddCanvas();

                //gcanvas.Width = new Infragistics.Documents.Report.FixedWidth(360);

                //gcanvas.Margins.All = 100;

                //gcanvas.Margins.Left = 0;

                //gcanvas.Margins.Right = 15;

                //yourUltraChart.RenderPdfFriendlyGraphics(gcanvas.CreateGraphics(), 340, 250);

     

                Infragistics.Documents.Report.IImage image;

                Infragistics.Documents.Graphics.Image img = GetChartAsImage(yourUltraChart);

                image = group.AddImage(img);

                image.Width = new Infragistics.Documents.Report.FixedWidth(345);

                image.Height = new Infragistics.Documents.Report.FixedHeight(220);

                image.Margins.Left = 0;

                image.Margins.Right = 15;

               

                Infragistics.Documents.Report.Grid.IGrid grid   = group.AddGrid();

     

                grid.Width = new Infragistics.Documents.Report.FixedWidth(245);

                grid.Height = new Infragistics.Documents.Report.FixedHeight(220);                    

    grid.Borders = new Infragistics.Documents.Report.Borders(Infragistics.Documents.Graphics.Pens.Gray);

              

                // Header

                Infragistics.Documents.Report.Grid.IGridHeader header = grid.Header;

                header.Repeat = true;

                Infragistics.Documents.Report.Grid.IGridCell cell;

     

                Infragistics.Documents.Report.Grid.IGridColumn column;

                foreach (UltraGridColumn Ug in yourUltraWinGrid.DisplayLayout.Bands[0].Columns)

                {

                    if (!Ug.Hidden)

                    {

                        column = grid.AddColumn();

                        cell = header.AddCell();

                        cell.ColSpan = 1;

                        cell.Alignment.Vertical = Infragistics.Documents.Report.Alignment.Middle;

                        cell.Borders = new Infragistics.Documents.Report.Borders(Infragistics.Documents.Graphics.Pens.Azure);

                        cell.Background = new Infragistics.Documents.Report.Background(new Infragistics.Documents.Graphics.Color(Color.SkyBlue));

                        text = cell.AddText();                   

                        text.Style = boldStyle;

                        text.Alignment = Infragistics.Documents.Report.TextAlignment.Center;

                        text.AddContent(Ug.Key.ToString());

                    }

                }

     

                Infragistics.Documents.Report.Grid.IGridRow row;

                Infragistics.Documents.Report.Background background1 = new Infragistics.Documents.Report.Background(new Infragistics.Documents.Graphics.LinearGradientBrush(new Infragistics.Documents.Graphics.Color(Color.WhiteSmoke), new Infragistics.Documents.Graphics.Color(Color.WhiteSmoke), 2f));

                Infragistics.Documents.Report.Background background2 = new Infragistics.Documents.Report.Background(new Infragistics.Documents.Graphics.LinearGradientBrush(new Infragistics.Documents.Graphics.Color(Color.White), new Infragistics.Documents.Graphics.Color(Color.White), 2f));

     

                int i = 0;

                foreach (UltraGridRow Ur in yourUltraWinGrid.Rows)

                {

                    row = grid.AddRow();

                    foreach (UltraGridCell Uc in Ur.Cells)

                    {

                        if (!Uc.Column.Hidden)

                        {

                            cell = row.AddCell();

                            cell.RowSpan = 1;

                            cell.Alignment.Vertical = Infragistics.Documents.Report.Alignment.Middle;

                            cell.Borders = new Infragistics.Documents.Report.Borders(Infragistics.Documents.Graphics.Pens.Azure);

                            cell.Background = background1;

                            if (i % 2 == 0)

                            {

                                cell.Background = background2;

                            }

                            text = cell.AddText();

                            text.Style = normalStyle;

                            normalStyle.Font = new Infragistics.Documents.Graphics.Font("Calibri", 9);

                            text.AddContent(Uc.Value.ToString());

                           

                        }

                    }

                    i++;

                }

              

                r.Publish("C:\\Report.pdf", FileFormat.PDF);

            }

     

    private Infragistics.Documents.Graphics.Image GetChartAsImage(UltraChart ultraChart)

            {

                MemoryStream memoryStream = new MemoryStream();

                ultraChart.SaveTo(memoryStream, ImageFormat.Png);

                Infragistics.Documents.Graphics.Image worksheetImage = new Infragistics.Documents.Graphics.Image(Image.FromStream(memoryStream));

                memoryStream.Dispose();

                return worksheetImage;

            }

     

  • 469350
    Suggested Answer
    Offline posted

    I do not believe there is any way to do this.

    You could probably create a report and then add a section and export both the chart and the grid to the same section. But the grid is going to size the section based on the columns in the grid and the necessary page size. And there is no way to get the two controls to appear side-by-side.