示例#1
0
        public static void Run()
        {
            //ExStart:UsingWorkBookChartcellAsDatalabel
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_Charts();



            string lbl0 = "Label 0 cell value";
            string lbl1 = "Label 1 cell value";
            string lbl2 = "Label 2 cell value";

            // Instantiate Presentation class that represents a presentation file

            using (Presentation pres = new Presentation(dataDir + "chart2.pptx"))
            {
                ISlide slide = pres.Slides[0];


                IChart chart = pres.Slides[0].Shapes.AddChart(ChartType.Bubble, 50, 50, 600, 400, true);

                IChartSeriesCollection series = chart.ChartData.Series;

                series[0].Labels.DefaultDataLabelFormat.ShowLabelValueFromCell = true;

                IChartDataWorkbook wb = chart.ChartData.ChartDataWorkbook;

                series[0].Labels[0].ValueFromCell = wb.GetCell(0, "A10", lbl0);
                series[0].Labels[1].ValueFromCell = wb.GetCell(0, "A11", lbl1);
                series[0].Labels[2].ValueFromCell = wb.GetCell(0, "A12", lbl2);

                pres.Save(path + "resultchart.pptx", Aspose.Slides.Export.SaveFormat.Pptx);
            }
            //ExEnd:UsingWorkBookChartcellAsDatalabel
        }
        public static void Run()
        {
            //ExStart:NumberFormat
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_Charts();

            // Create directory if it is not already present.
            bool IsExists = System.IO.Directory.Exists(dataDir);

            if (!IsExists)
            {
                System.IO.Directory.CreateDirectory(dataDir);
            }

            // Instantiate the presentation// Instantiate the presentation
            Presentation pres = new Presentation();

            // Access the first presentation slide
            ISlide slide = pres.Slides[0];

            // Adding a defautlt clustered column chart
            IChart chart = slide.Shapes.AddChart(ChartType.ClusteredColumn, 50, 50, 500, 400);

            // Accessing the chart series collection
            IChartSeriesCollection series = chart.ChartData.Series;

            // Setting the preset number format
            // Traverse through every chart series
            foreach (ChartSeries ser in series)
            {
                // Traverse through every data cell in series
                foreach (IChartDataPoint cell in ser.DataPoints)
                {
                    // Setting the number format
                    cell.Value.AsCell.PresetNumberFormat = 10; //0.00%
                }
            }

            // Saving presentation
            pres.Save(dataDir + "PresetNumberFormat_out.pptx", SaveFormat.Pptx);
            //ExEnd:NumberFormat
        }
示例#3
0
        public static void Run()
        {
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_Charts();

            using (Presentation presentation = new Presentation())
            {
                // Adding chart
                IChart chart = presentation.Slides[0].Shapes.AddChart(ChartType.ClusteredColumn, 50, 50, 600, 400, true);
                IChartSeriesCollection series = chart.ChartData.Series;
                if (series[0].Overlap == 0)
                {
                    // Setting series overlap
                    series[0].ParentSeriesGroup.Overlap = -30;
                }

                // Write the presentation file to disk
                presentation.Save(dataDir + "SetChartSeriesOverlap_out.pptx", SaveFormat.Pptx);
            }
        }
示例#4
0
        public static void Run()
        {
            //ExStart:InvertIfNegativeForIndividualSeries
            string dataDir = RunExamples.GetDataDir_Charts();

            using (Presentation pres = new Presentation())
            {
                IChart chart = pres.Slides[0].Shapes.AddChart(ChartType.ClusteredColumn, 50, 50, 600, 400, true);
                IChartSeriesCollection series = chart.ChartData.Series;
                chart.ChartData.Series.Clear();

                series.Add(chart.ChartData.ChartDataWorkbook.GetCell(0, "B1"), chart.Type);
                series[0].DataPoints.AddDataPointForBarSeries(chart.ChartData.ChartDataWorkbook.GetCell(0, "B2", -5));
                series[0].DataPoints.AddDataPointForBarSeries(chart.ChartData.ChartDataWorkbook.GetCell(0, "B3", 3));
                series[0].DataPoints.AddDataPointForBarSeries(chart.ChartData.ChartDataWorkbook.GetCell(0, "B4", -2));
                series[0].DataPoints.AddDataPointForBarSeries(chart.ChartData.ChartDataWorkbook.GetCell(0, "B5", 1));

                series[0].InvertIfNegative = false;

                series[0].DataPoints[2].InvertIfNegative = true;

                pres.Save(dataDir + "", SaveFormat.Pptx);
            }
        }