コード例 #1
0
        static void Main(string[] args)
        {
            //Create a workbook
            Workbook wb = new Workbook();

            //Add an excel chart
            int chartSheetIndex = AddExcelChartInWorkbook(wb);

            wb.Worksheets.SetOleSize(0, 5, 0, 5);

            Bitmap imgChart = wb.Worksheets[chartSheetIndex].Charts[0].ToImage();

            //Save the workbook to stream
            MemoryStream wbStream = wb.SaveToStream();

            //Create a presentation
            PresentationEx pres = new PresentationEx();
            SlideEx        sld  = pres.Slides[0];

            //Add the workbook on slide
            AddExcelChartInPresentation(pres, sld, wbStream, imgChart);

            //Write the output presentation on disk
            pres.Write("chart.pptx");
        }
コード例 #2
0
        static void Main(string[] args)
        {
            //Create empty presentation
            using (PresentationEx pres = new PresentationEx())
            {
                //Accessing first slide
                SlideEx slide = pres.Slides[0];

                //Addding default chart
                ChartEx ppChart = slide.Shapes.AddChart(ChartTypeEx.ClusteredColumn3D, 20F, 30F, 400F, 300F);

                //Getting Chart data
                ChartDataEx chartData = ppChart.ChartData;

                //Removing Extra default series
                chartData.Series.RemoveAt(1);
                chartData.Series.RemoveAt(1);

                //Modifying chart categories names
                chartData.Categories[0].ChartDataCell.Value = "Bikes";
                chartData.Categories[1].ChartDataCell.Value = "Accessories";
                chartData.Categories[2].ChartDataCell.Value = "Repairs";
                chartData.Categories[3].ChartDataCell.Value = "Clothing";

                //Modifying chart series values for first category
                chartData.Series[0].Values[0].Value = 1000;
                chartData.Series[0].Values[1].Value = 2500;
                chartData.Series[0].Values[2].Value = 4000;
                chartData.Series[0].Values[3].Value = 3000;

                //Setting Chart title
                ppChart.HasTitle             = true;
                ppChart.ChartTitle.Text.Text = "2007 Sales";
                PortionFormatEx format = ppChart.ChartTitle.Text.Paragraphs[0].Portions[0].PortionFormat;
                format.FontItalic                      = NullableBool.True;
                format.FontHeight                      = 18;
                format.FillFormat.FillType             = FillTypeEx.Solid;
                format.FillFormat.SolidFillColor.Color = Color.Black;


                //Setting Axis values
                ppChart.ValueAxis.IsAutomaticMaxValue  = false;
                ppChart.ValueAxis.IsAutomaticMinValue  = false;
                ppChart.ValueAxis.IsAutomaticMajorUnit = false;
                ppChart.ValueAxis.IsAutomaticMinorUnit = false;

                ppChart.ValueAxis.MaxValue          = 4000.0F;
                ppChart.ValueAxis.MinValue          = 0.0F;
                ppChart.ValueAxis.MajorUnit         = 2000.0F;
                ppChart.ValueAxis.MinorUnit         = 1000.0F;
                ppChart.ValueAxis.TickLabelPosition = TickLabelPositionType.NextTo;

                //Setting Chart rotation
                ppChart.Rotation3D.RotationX = 15;
                ppChart.Rotation3D.RotationY = 20;

                //Saving Presentation
                pres.Write("AsposeSampleChart.pptx");
            }
        }
コード例 #3
0
        static void Main(string[] args)
        {
            //Create empty presentation
            using (PresentationEx pres = new PresentationEx())
            {

                //Accessing first slide
                SlideEx slide = pres.Slides[0];

                //Addding default chart
                ChartEx ppChart = slide.Shapes.AddChart(ChartTypeEx.ClusteredColumn3D, 20F, 30F, 400F, 300F);

                //Getting Chart data
                ChartDataEx chartData = ppChart.ChartData;

                //Removing Extra default series
                chartData.Series.RemoveAt(1);
                chartData.Series.RemoveAt(1);

                //Modifying chart categories names
                chartData.Categories[0].ChartDataCell.Value = "Bikes";
                chartData.Categories[1].ChartDataCell.Value = "Accessories";
                chartData.Categories[2].ChartDataCell.Value = "Repairs";
                chartData.Categories[3].ChartDataCell.Value = "Clothing";

                //Modifying chart series values for first category
                chartData.Series[0].Values[0].Value = 1000;
                chartData.Series[0].Values[1].Value = 2500;
                chartData.Series[0].Values[2].Value = 4000;
                chartData.Series[0].Values[3].Value = 3000;

                //Setting Chart title
                ppChart.HasTitle = true;
                ppChart.ChartTitle.Text.Text = "2007 Sales";
                PortionFormatEx format = ppChart.ChartTitle.Text.Paragraphs[0].Portions[0].PortionFormat;
                format.FontItalic = NullableBool.True;
                format.FontHeight = 18;
                format.FillFormat.FillType = FillTypeEx.Solid;
                format.FillFormat.SolidFillColor.Color = Color.Black;

                //Setting Axis values
                ppChart.ValueAxis.IsAutomaticMaxValue = false;
                ppChart.ValueAxis.IsAutomaticMinValue = false;
                ppChart.ValueAxis.IsAutomaticMajorUnit = false;
                ppChart.ValueAxis.IsAutomaticMinorUnit = false;

                ppChart.ValueAxis.MaxValue = 4000.0F;
                ppChart.ValueAxis.MinValue = 0.0F;
                ppChart.ValueAxis.MajorUnit = 2000.0F;
                ppChart.ValueAxis.MinorUnit = 1000.0F;
                ppChart.ValueAxis.TickLabelPosition = TickLabelPositionType.NextTo;

                //Setting Chart rotation
                ppChart.Rotation3D.RotationX = 15;
                ppChart.Rotation3D.RotationY = 20;

                //Saving Presentation
                pres.Write("AsposeSampleChart.pptx");
            }
        }
コード例 #4
0
        public static void CreatePresentation(string filepath)
        {
            //Instantiate a Presentation object that represents a PPT file
            using (PresentationEx pres = new PresentationEx())
            {
                //Instantiate SlideExCollection calss
                SlideExCollection slds = pres.Slides;

                //Add an empty slide to the SlidesEx collection
                slds.AddEmptySlide(pres.LayoutSlides[0]);

                //Save your presentation to a file
                pres.Write(filepath);
            }
        }
コード例 #5
0
        public static void RemovingSlides()
        {
            string MyDir = @"Files\";
            //Instantiate a Presentation object that represents a presentation file
            PresentationEx pres = new PresentationEx(MyDir + "Slides Test Presentation.pptx");

            //Accessing a slide using its index in the slides collection
            SlideEx slide = pres.Slides[0];

            //Removing a slide using its reference
            pres.Slides.Remove(slide);

            //Writing the presentation file
            pres.Write(MyDir + "modified.pptx");
        }
コード例 #6
0
        public static void DeleteSlide(string presentationFile, int slideIndex)
        {
            //Instantiate a PresentationEx object that represents a PPTX file
            using (PresentationEx pres = new PresentationEx(presentationFile))
            {
                //Accessing a slide using its index in the slides collection
                SlideEx slide = pres.Slides[slideIndex];


                //Removing a slide using its reference
                pres.Slides.Remove(slide);


                //Writing the presentation as a PPTX file
                pres.Write(presentationFile);
            }
        }
コード例 #7
0
        // Move a slide to a different position in the slide order in the presentation.
        public static void MoveSlide(string presentationFile, int from, int to)
        {
            //Instantiate PresentationEx class to load the source PPTX file
            using (PresentationEx pres = new PresentationEx(presentationFile))
            {
                //Get the slide whose position is to be changed
                SlideEx sld = pres.Slides[from];
                SlideEx sld2 = pres.Slides[to];

                //Set the new position for the slide
                sld2.SlideNumber = from;
                sld.SlideNumber = to;

                //Write the PPTX to disk
                pres.Write(presentationFile);

            }
        }
コード例 #8
0
        public static void AddingSlidetoPresentation()
        {
            string         MyDir = @"Files\";
            PresentationEx pres  = new PresentationEx();

            //Instantiate SlideCollection class

            SlideExCollection slds = pres.Slides;

            for (int i = 0; i < pres.LayoutSlides.Count; i++)
            {
                //Add an empty slide to the Slides collection
                slds.AddEmptySlide(pres.LayoutSlides[i]);
            }

            //Save the PPTX file to the Disk
            pres.Write(MyDir + "EmptySlide.pptx");
        }
コード例 #9
0
        // Move a slide to a different position in the slide order in the presentation.
        public static void MoveSlide(string presentationFile, int from, int to)
        {
            //Instantiate PresentationEx class to load the source PPTX file
            using (PresentationEx pres = new PresentationEx(presentationFile))
            {
                //Get the slide whose position is to be changed
                SlideEx sld = pres.Slides[from];
                SlideEx sld2 = pres.Slides[to];

                //Set the new position for the slide
                sld2.SlideNumber = from;
                sld.SlideNumber = to;

                //Write the PPTX to disk
                pres.Write(presentationFile);

            }
        }
コード例 #10
0
        static void Main(string[] args)
        {
            using (PresentationEx pres = new PresentationEx())
            {
                //Adding Empty slide
                pres.Slides.AddEmptySlide(pres.LayoutSlides[0]);

                //Adding Autthor
                CommentAuthorEx author = pres.CommentAuthors.AddAuthor("Zeeshan", "MZ");

                //Position of comments

                PointF point = new PointF();
                point.X = 1;
                point.Y = 1;

                //Adding slide comment for an author on slide
                author.Comments.AddComment("Hello Zeeshan, this is slide comment", pres.Slides[0], point, DateTime.Now);
                pres.Write("Comments.pptx");
            }
        }
コード例 #11
0
        static void Main(string[] args)
        {
            using (PresentationEx pres = new PresentationEx())
            {
                //Adding Empty slide
                pres.Slides.AddEmptySlide(pres.LayoutSlides[0]);

                //Adding Autthor
                CommentAuthorEx author = pres.CommentAuthors.AddAuthor("Zeeshan", "MZ");

                //Position of comments

                PointF point = new PointF();
                point.X = 1;
                point.Y = 1;

                //Adding slide comment for an author on slide
                author.Comments.AddComment("Hello Zeeshan, this is slide comment", pres.Slides[0], point, DateTime.Now);
                pres.Write("Comments.pptx");
            }
        }
コード例 #12
0
        static void Main(string[] args)
        {
            //Create a workbook
            Workbook wb = new Workbook();

            //Add an excel chart
            int chartSheetIndex = AddExcelChartInWorkbook(wb);

            wb.Worksheets.SetOleSize(0, 5, 0, 5);

            Bitmap imgChart = wb.Worksheets[chartSheetIndex].Charts[0].ToImage();

            //Save the workbook to stream
            MemoryStream wbStream = wb.SaveToStream();

            //Create a presentation
            PresentationEx pres = new PresentationEx();
            SlideEx sld = pres.Slides[0];

            //Add the workbook on slide
            AddExcelChartInPresentation(pres, sld, wbStream, imgChart);

            //Write the output presentation on disk
            pres.Write("chart.pptx");
        }