Aspose.Cells.Examples.CSharp.Charts.InsertingControlsintoCharts.AddingLabelControl.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 the designer chart in the second sheet.
            Worksheet sheet = workbook.Worksheets[1];
            Aspose.Cells.Charts.Chart chart = sheet.Charts[0];

            // Add a new label to the chart.
            Aspose.Cells.Drawing.Label label = chart.Shapes.AddLabelInChart(100, 100, 350, 900);

            // Set the caption of the label.
            label.Text = "A Label In Chart";

            // Set the Placement Type, the way the
            // Label is attached to the cells.
            label.Placement = Aspose.Cells.Drawing.PlacementType.FreeFloating;

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