Tuesday, April 23, 2024 :: Login  

Insert Barchart into Powerpoint

 

public void InsertBarChart(chartsettings cs, Microsoft.Office.Interop.PowerPoint._Slide oSlide, string[,] datarr)
        {
            int i, j;

            Microsoft.Office.Interop.Graph.Chart oChart;
            Microsoft.Office.Interop.Graph.Axis oAxis;

            oChart = (Microsoft.Office.Interop.Graph.Chart)oSlide.Shapes.AddOLEObject(150, 150, 480, 320, "MSGraph.Chart", "", Microsoft.Office.Core.MsoTriState.msoFalse, "", 0, "", Microsoft.Office.Core.MsoTriState.msoFalse).OLEFormat.Object;
            //wrdChart.Application.Visible   =   false;

            oChart.Application.PlotBy = Microsoft.Office.Interop.Graph.XlRowCol.xlColumns;


            if (cs.charttype == "vbar")
            {
                oChart.ChartType = Microsoft.Office.Interop.Graph.XlChartType.xlBarClustered;
            }
            else
            {
                oChart.ChartType = Microsoft.Office.Interop.Graph.XlChartType.xlColumnClustered;
            }


            oAxis = (Microsoft.Office.Interop.Graph.Axis)oChart.Axes(1, 1);
            oChart.Application.DataSheet.Cells.Clear();


            for (int dd = 0; dd <= datarr.GetLength(0) - 1; dd++)
            {
                for (int de = 0; de <= datarr.GetLength(1) - 1; de++)
                {
                    oChart.Application.DataSheet.Cells[dd + 1, de + 1] = datarr.GetValue(dd, de);
                }
            }

            //axis.MaximumScale   =   1;
            //axis.MajorUnit   =   0.1;

            oChart.Legend.Position = Microsoft.Office.Interop.Graph.XlLegendPosition.xlLegendPositionBottom;
            oChart.HasTitle = true;
            oChart.ChartTitle.Text = "Here it is...";


            //wrdChart.Legend.Delete();
            oChart.Width = 500;

            //wrdChart.Height   =   666;
            //oShape.Height   =   oWord.InchesToPoints(3.57f);

            oChart.Application.Update();
            oChart.Application.Quit();
        }

Privacy Policy www.made4dotnet.com 2020

Map IP Address
Powered byIP2Location.com

   Terms Of Use   ::   Privacy Statement   ::   Copyright (c) 2024 www.made4dotnet.com - .NET Development