Aspose.Cells.Examples.CSharp.Charts.InsertingControlsintoCharts.AddingPictureToChart.Run C# (CSharp) Method

Run() public static method

public static Run ( ) : void
return void
        public static void Run()
        {
            // ExStart:1
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);

            // Open the existing file.
            Workbook workbook = new Workbook(dataDir + "chart.xls");

            // Get an image file to the stream.
            FileStream stream = new FileStream(dataDir + "logo.jpg", FileMode.Open, FileAccess.Read);

            // Get the designer chart in the second sheet.
            Worksheet sheet = workbook.Worksheets[0];
            Aspose.Cells.Charts.Chart chart = sheet.Charts[0];

            // Add a new picture to the chart.
            Aspose.Cells.Drawing.Picture pic0 = chart.Shapes.AddPictureInChart(50, 50, stream, 40, 40);

            // Get the lineformat type of the picture.
            Aspose.Cells.Drawing.LineFormat lineformat = pic0.Line;          

            // Set the dash style.
            lineformat.DashStyle = Aspose.Cells.Drawing.MsoLineDashStyle.Solid;

            // Set the line weight.
            lineformat.Weight = 4;    

            // Save the excel file.
            workbook.Save(dataDir + "chart.out.xls");
            // ExEnd:1
        
        }
    }
AddingPictureToChart