public static void Main(string[] args) { // The path to the documents directory. string dataDir = Path.GetFullPath("../../../Data/"); //Create a new Workbook. //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; //Set the fill color of the label. label.FillFormat.ForeColor = Color.Azure; //Save the excel file. workbook.Save(dataDir + "chart_out.xls"); }
public static void Main(string[] args) { //ExStart:1 // The path to the documents directory. string dataDir = Aspose.Cells.Examples.Utils.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); //Create a new Workbook. //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; //Set the fill color of the label. label.FillFormat.ForeColor = Color.Azure; //Save the excel file. workbook.Save(dataDir + "chart.out.xls"); //ExEnd:1 }
public static void Run() { // Open the existing file. Workbook workbook = new Workbook(sourceDir + "sampleAddingLabelControlInChart.xls"); // Get the designer chart in the second sheet. Worksheet sheet = workbook.Worksheets[0]; Aspose.Cells.Charts.Chart chart = sheet.Charts[0]; // Add a new label to the chart. Aspose.Cells.Drawing.Label label = chart.Shapes.AddLabelInChart(600, 600, 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(outputDir + "outputAddingLabelControlInChart.xls"); Console.WriteLine("AddingLabelControlInChart executed successfully."); }