示例#1
0
 private void btnCreateImage_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         //Opens the existing presentation stream.
         using (IPresentation presentation = Presentation.Create())
         {
             ISlide     slide     = presentation.Slides.Add(SlideLayoutType.TitleOnly);
             IParagraph paragraph = ((IShape)slide.Shapes[0]).TextBody.Paragraphs.Add();
             //Apply center alignment to the paragraph
             paragraph.HorizontalAlignment = HorizontalAlignmentType.Center;
             //Add slide title
             ITextPart textPart = paragraph.AddTextPart("Northwind Management Report");
             textPart.Font.Color = ColorObject.FromArgb(46, 116, 181);
             //Get chart data from xml file
             DataSet dataSet = new DataSet();
             dataSet.ReadXml(@"..\..\..\..\..\..\..\Common\Data\Presentation\Products.xml");
             //Add a new chart to the presentation slide
             IPresentationChart chart = slide.Charts.AddChart(44.64, 133.2, 870.48, 380.16);
             //Set chart type
             chart.ChartType = OfficeChartType.Pie;
             //Set chart title
             chart.ChartTitle = "Best Selling Products";
             //Set chart properties font name and size
             chart.ChartTitleArea.FontName = "Calibri (Body)";
             chart.ChartTitleArea.Size     = 14;
             for (int i = 0; i < dataSet.Tables[0].Rows.Count; i++)
             {
                 chart.ChartData.SetValue(i + 2, 1, dataSet.Tables[0].Rows[i].ItemArray[1]);
                 chart.ChartData.SetValue(i + 2, 2, dataSet.Tables[0].Rows[i].ItemArray[2]);
             }
             //Create a new chart series with the name “Sales”
             AddSeriesForChart(chart);
             //Setting the font size of the legend.
             chart.Legend.TextArea.Size = 14;
             //Setting background color
             chart.ChartArea.Fill.ForeColor           = System.Drawing.Color.FromArgb(242, 242, 242);
             chart.PlotArea.Fill.ForeColor            = System.Drawing.Color.FromArgb(242, 242, 242);
             chart.ChartArea.Border.LinePattern       = OfficeChartLinePattern.None;
             chart.PrimaryCategoryAxis.CategoryLabels = chart.ChartData[2, 1, 11, 1];
             //Saves the presentation instance to the stream.
             presentation.Save("ChartCreationSample.pptx");
             if (System.Windows.MessageBox.Show("Do you want to view the generated PowerPoint Presentation?", "Chart Creation",
                                                MessageBoxButton.YesNo, MessageBoxImage.Information) == MessageBoxResult.Yes)
             {
                 System.Diagnostics.Process.Start("ChartCreationSample.pptx");
                 this.Close();
             }
         }
     }
     catch (Exception exception)
     {
         System.Windows.MessageBox.Show("This Presentation could not be created, please contact Syncfusion Direct-Trac system at http://www.syncfusion.com/support/default.aspx for any queries. ", "OOPS..Sorry!",
                                        MessageBoxButton.OK);
         this.Close();
     }
 }
示例#2
0
        void OnButtonClicked(object sender, EventArgs e)
        {
            MemoryStream stream = new MemoryStream();

            //Create a Presentation instance
            using (IPresentation presentation = Syncfusion.Presentation.Presentation.Create())
            {
                //Add a blank slide to the Presentation
                ISlide slide = presentation.Slides.Add(SlideLayoutType.TitleOnly);
                //Add a empty paragraph to the slide
                IParagraph paragraph = ((IShape)slide.Shapes[0]).TextBody.Paragraphs.Add();
                //Apply center alignment to the paragraph
                paragraph.HorizontalAlignment = HorizontalAlignmentType.Center;
                //Add slide title
                ITextPart textPart = paragraph.AddTextPart("Northwind Management Report");
                textPart.Font.Color = ColorObject.FromArgb(46, 116, 181);
                //Get chart data from xml file
                List <ProductDetails> Products = LoadXMLData();
                //Add a new chart to the presentation slide
                IPresentationChart chart = slide.Charts.AddChart(44.64, 133.2, 870.48, 380.16);
                //Set chart type
                chart.ChartType = OfficeChartType.Pie;
                //Set chart title
                chart.ChartTitle = "Best Selling Products";
                //Set chart properties font name and size
                chart.ChartTitleArea.FontName = "Calibri (Body)";
                chart.ChartTitleArea.Size     = 14;
                //Itterate and set the values to chart
                for (int i = 0; i < Products.Count; i++)
                {
                    ProductDetails product = Products[i];
                    chart.ChartData.SetValue(i + 2, 1, product.ProductName);
                    chart.ChartData.SetValue(i + 2, 2, product.Sum);
                }
                //Create a new chart series with the name �Sales�
                AddSeriesForChart(chart);
                //Set the font size of the legend.
                chart.Legend.TextArea.Size = 14;
                //Set the color formatting to the chart
                chart.ChartArea.Fill.ForeColor           = Syncfusion.Drawing.Color.FromArgb(242, 242, 242);
                chart.PlotArea.Fill.ForeColor            = Syncfusion.Drawing.Color.FromArgb(242, 242, 242);
                chart.ChartArea.Border.LinePattern       = OfficeChartLinePattern.None;
                chart.PrimaryCategoryAxis.CategoryLabels = chart.ChartData[2, 1, 11, 1];
                //Save the presentation instance to a stream.
                presentation.Save(stream);
            }
            stream.Position = 0;
            if (Device.OS == TargetPlatform.WinPhone || Device.OS == TargetPlatform.Windows)
            {
                Xamarin.Forms.DependencyService.Get <ISaveWindowsPhone>().Save("ChartsSample.pptx", "application/vnd.openxmlformats-officedocument.presentationml.presentation", stream);
            }
            else
            {
                Xamarin.Forms.DependencyService.Get <ISave>().Save("ChartsSample.pptx", "application/vnd.openxmlformats-officedocument.presentationml.presentation", stream);
            }
        }
示例#3
0
 /// <summary>
 /// Adds the series for the chart.
 /// </summary>
 /// <param name="chart">Represents the chart instance from the presentation.</param>
 private void AddSeriesForChart(IPresentationChart chart)
 {
     //Add a series for the chart.
     IOfficeChartSerie series = chart.Series.Add("Sales");
     series.Values = chart.ChartData[2, 2, 11, 2];
     //Setting data label
     series.DataPoints.DefaultDataPoint.DataLabels.IsValue = true;
     series.DataPoints.DefaultDataPoint.DataLabels.Position = OfficeDataLabelPosition.Outside;
     series.DataPoints.DefaultDataPoint.DataLabels.Size = 14;
 }
示例#4
0
        void OnButtonClicked(object sender, EventArgs e)
        {
            MemoryStream stream = new MemoryStream();

            //Opens the existing presentation stream.
            using (IPresentation presentation = Syncfusion.Presentation.Presentation.Create())
            {
                ISlide     slide     = presentation.Slides.Add(SlideLayoutType.TitleOnly);
                IParagraph paragraph = ((IShape)slide.Shapes[0]).TextBody.Paragraphs.Add();
                //Apply center alignment to the paragraph
                paragraph.HorizontalAlignment = HorizontalAlignmentType.Center;
                //Add slide title
                ITextPart textPart = paragraph.AddTextPart("Northwind Management Report");
                textPart.Font.Color = ColorObject.FromArgb(46, 116, 181);
                //Get chart data from xml file
                List <ProductDetails> Products = LoadXMLData();
                //Add a new chart to the presentation slide
                IPresentationChart chart = slide.Charts.AddChart(44.64, 133.2, 870.48, 380.16);
                //Set chart type
                chart.ChartType = OfficeChartType.Pie;
                //Set chart title
                chart.ChartTitle = "Best Selling Products";
                //Set chart properties font name and size
                chart.ChartTitleArea.FontName = "Calibri (Body)";
                chart.ChartTitleArea.Size     = 14;
                for (int i = 0; i < Products.Count; i++)
                {
                    ProductDetails product = Products[i];
                    chart.ChartData.SetValue(i + 2, 1, product.ProductName);
                    chart.ChartData.SetValue(i + 2, 2, product.Sum);
                }
                //Create a new chart series with the name “Sales”
                AddSeriesForChart(chart);
                //Setting the font size of the legend.
                chart.Legend.TextArea.Size = 14;
                //Setting background color
                chart.ChartArea.Fill.ForeColor           = Syncfusion.Drawing.Color.FromArgb(242, 242, 242);
                chart.PlotArea.Fill.ForeColor            = Syncfusion.Drawing.Color.FromArgb(242, 242, 242);
                chart.ChartArea.Border.LinePattern       = OfficeChartLinePattern.None;
                chart.PrimaryCategoryAxis.CategoryLabels = chart.ChartData[2, 1, 11, 1];
                //Saves the presentation instance to the stream.
                presentation.Save(stream);
            }
            stream.Position = 0;

            if (stream != null)
            {
                SaveiOS iOSSave = new SaveiOS();
                iOSSave.Save("ChartsPresentation.pptx", "application/mspowerpoint", stream);
            }
        }
示例#5
0
        private void AddDataToCommonCharts(DataTable dataTable, ViewData viewData, IPresentationChart chart, string paName, int nRows)
        {
            chart.ChartType = GetChartType(viewData.ChartType);
            foreach (string item in viewData.SerieList ?? Enumerable.Empty <string>())
            {
                IOfficeChartSerie serie = chart.Series.Add(item);
                int columnIndex         = dataTable.Columns.IndexOf(item) + 1;
                serie.Values = chart.ChartData[2, columnIndex, nRows, columnIndex];
            }
            var paCn = dataTable.Columns.IndexOf(paName) + 1;

            chart.PrimaryCategoryAxis.CategoryLabels = chart.ChartData[2, paCn, nRows, paCn];

            chart.Refresh();
        }
        /// <summary>
        /// Exports the tables and charts to the PowerPoint Slide
        /// </summary>
        /// <param name="presentation">The PowerPoint presnetation to export the charts and tables</param>
        /// <param name="dataTable">The table which has the data</param>
        private static void CreateChartFromDatatable(IPresentation pptxDoc, DataTable dataTable)
        {
            //Get the first slide in the PowerPoint presentation
            ISlide slide = pptxDoc.Slides.Add(SlideLayoutType.Blank);
            //Create a chart and add to the slide
            IPresentationChart chart = slide.Charts.AddChart(100, 10, 700, 500);
            int rowIndex             = 1;
            int colIndex             = 1;

            //Add data to the table in presentation from the DataTable
            foreach (DataRow row in dataTable.Rows)
            {
                foreach (object val in row.ItemArray)
                {
                    string value = val.ToString();
                    chart.ChartData.SetValue(rowIndex, colIndex, value);
                    colIndex++;
                }
                colIndex = 1;
                rowIndex++;
            }
            //Creates a new chart series with the name
            IOfficeChartSerie openPrice = chart.Series.Add("Open Price");

            //Sets the data range of chart series – start row, start column, end row, end column
            openPrice.Values = chart.ChartData[2, 2, 5, 2];

            //Creates a new chart series with the name
            IOfficeChartSerie highPrice = chart.Series.Add("High Price");

            //Sets the data range of chart series – start row, start column, end row, end column
            highPrice.Values = chart.ChartData[2, 3, 5, 3];

            //Creates a new chart series with the name
            IOfficeChartSerie lowPrice = chart.Series.Add("Low Price");

            //Sets the data range of chart series – start row, start column, end row, end column
            lowPrice.Values = chart.ChartData[2, 4, 5, 4];

            //Sets the data range of the category axis
            chart.PrimaryCategoryAxis.CategoryLabels = chart.ChartData[2, 1, 5, 1];

            //Specifies the chart type
            chart.ChartType = OfficeChartType.Column_Clustered;

            //Set the title for the chart
            chart.ChartTitle = "Sales Report";
        }
示例#7
0
        private void CreateLineAndBar(DataTable dataTable, ViewData viewData, IPresentationChart chart, int nRows)
        {
            //Serie1
            IOfficeChartSerie serie1 = chart.Series.Add(viewData.SerieList[0]);
            int columnIndex          = dataTable.Columns.IndexOf(viewData.SerieList[0]);

            serie1.Values    = chart.ChartData[2, columnIndex, nRows, columnIndex];
            serie1.SerieType = OfficeChartType.Column_Clustered;

            //Serie2
            IOfficeChartSerie serie2 = chart.Series.Add(viewData.SerieList[1]);
            int columnIndex2         = dataTable.Columns.IndexOf(viewData.SerieList[1]);

            serie2.Values    = chart.ChartData[2, columnIndex2, nRows, columnIndex2];
            serie2.SerieType = OfficeChartType.Line;
        }
        public ActionResult CreatingChart(string Browser)
        {
            IPresentation presentation = Presentation.Create();
            ISlide        slide        = presentation.Slides.Add(SlideLayoutType.TitleOnly);
            IParagraph    paragraph    = ((IShape)slide.Shapes[0]).TextBody.Paragraphs.Add();

            //Apply center alignment to the paragraph
            paragraph.HorizontalAlignment = HorizontalAlignmentType.Center;
            //Add slide title
            ITextPart textPart = paragraph.AddTextPart("Northwind Management Report");

            textPart.Font.Color = ColorObject.FromArgb(46, 116, 181);
            //Get chart data from xml file
            DataSet dataSet = new DataSet();
            //Load XML file
            string dataPath = ResolveApplicationDataPath("Products.xml");

            dataSet.ReadXml(dataPath);
            //Add a new chart to the presentation slide
            IPresentationChart chart = slide.Charts.AddChart(44.64, 133.2, 870.48, 380.16);

            //Set chart type
            chart.ChartType = OfficeChartType.Pie;
            //Set chart title
            chart.ChartTitle = "Best Selling Products";
            //Set chart properties font name and size
            chart.ChartTitleArea.FontName = "Calibri (Body)";
            chart.ChartTitleArea.Size     = 14;
            for (int i = 0; i < dataSet.Tables[0].Rows.Count; i++)
            {
                chart.ChartData.SetValue(i + 2, 1, dataSet.Tables[0].Rows[i].ItemArray[1]);
                chart.ChartData.SetValue(i + 2, 2, dataSet.Tables[0].Rows[i].ItemArray[2]);
            }
            //Create a new chart series with the name �Sales�
            AddSeriesForChart(chart);
            //Setting the font size of the legend.
            chart.Legend.TextArea.Size = 14;
            //Setting background color
            chart.ChartArea.Fill.ForeColor           = System.Drawing.Color.FromArgb(242, 242, 242);
            chart.PlotArea.Fill.ForeColor            = System.Drawing.Color.FromArgb(242, 242, 242);
            chart.ChartArea.Border.LinePattern       = OfficeChartLinePattern.None;
            chart.PrimaryCategoryAxis.CategoryLabels = chart.ChartData[2, 1, 11, 1];
            //  Saves the presentation
            return(new PresentationResult(presentation, "Chart.pptx", HttpContext.ApplicationInstance.Response));
        }
        private void SlideWithComments2(IPresentation presentation)
        {
            xValue = 650;
            yValue = 90;

            ISlide slide2 = presentation.Slides.Add(SlideLayoutType.Blank);

            IPresentationChart chart = slide2.Shapes.AddChart(230, 80, 500, 400);

            //Specifies the chart title

            chart.ChartTitle = "Sales Analysis";

            //Sets chart data - Row1

            chart.ChartData.SetValue(1, 2, "Jan");

            chart.ChartData.SetValue(1, 3, "Feb");

            chart.ChartData.SetValue(1, 4, "March");

            //Sets chart data - Row2

            chart.ChartData.SetValue(2, 1, 2010);

            chart.ChartData.SetValue(2, 2, 60);

            chart.ChartData.SetValue(2, 3, 70);

            chart.ChartData.SetValue(2, 4, 80);

            //Sets chart data - Row3

            chart.ChartData.SetValue(3, 1, 2011);

            chart.ChartData.SetValue(3, 2, 80);

            chart.ChartData.SetValue(3, 3, 70);

            chart.ChartData.SetValue(3, 4, 60);

            //Sets chart data - Row4

            chart.ChartData.SetValue(4, 1, 2012);

            chart.ChartData.SetValue(4, 2, 60);

            chart.ChartData.SetValue(4, 3, 70);

            chart.ChartData.SetValue(4, 4, 80);

            //Creates a new chart series with the name

            IOfficeChartSerie serieJan = chart.Series.Add("Jan");

            //Sets the data range of chart serie – start row, start column, end row, end column

            serieJan.Values = chart.ChartData[2, 2, 4, 2];

            //Creates a new chart series with the name

            IOfficeChartSerie serieFeb = chart.Series.Add("Feb");

            //Sets the data range of chart serie – start row, start column, end row, end column

            serieFeb.Values = chart.ChartData[2, 3, 4, 3];

            //Creates a new chart series with the name

            IOfficeChartSerie serieMarch = chart.Series.Add("March");

            //Sets the data range of chart series – start row, start column, end row, end column

            serieMarch.Values = chart.ChartData[2, 4, 4, 4];

            //Sets the data range of the category axis

            chart.PrimaryCategoryAxis.CategoryLabels = chart.ChartData[2, 1, 4, 1];

            //Specifies the chart type

            chart.ChartType = OfficeChartType.Column_Clustered_3D;


            slide2.Comments.Add(xValue, yValue, "Author2", "A2", "Do all 3D-chart types support in Presentation library?", DateTime.Now);
        }
示例#10
0
        private void OnButtonClicked(object sender, EventArgs e)
        {
            string resourcePath = "";

                        #if COMMONSB
            resourcePath = "SampleBrowser.Samples.Presentation.Samples.Templates.Images.pptx";
            #else
            resourcePath = "SampleBrowser.Presentation.Samples.Templates.Images.pptx";
            #endif
            Assembly assembly   = typeof(Comments).GetTypeInfo().Assembly;
            Stream   fileStream = assembly.GetManifestResourceStream(resourcePath);

            IPresentation presentation = Syncfusion.Presentation.Presentation.Open(fileStream);

            #region Slide 1
            ISlide slide1 = presentation.Slides[0];
            IShape shape1 = (IShape)slide1.Shapes[0];
            shape1.Left   = 1.27 * 72;
            shape1.Top    = 0.85 * 72;
            shape1.Width  = 10.86 * 72;
            shape1.Height = 3.74 * 72;

            ITextBody   textFrame  = shape1.TextBody;
            IParagraphs paragraphs = textFrame.Paragraphs;
            paragraphs.Add();
            IParagraph paragraph = paragraphs[0];
            paragraph.HorizontalAlignment = HorizontalAlignmentType.Left;
            ITextParts textParts = paragraph.TextParts;
            textParts.Add();
            ITextPart textPart = textParts[0];
            textPart.Text          = "Essential Presentation ";
            textPart.Font.CapsType = TextCapsType.All;
            textPart.Font.FontName = "Calibri Light (Headings)";
            textPart.Font.FontSize = 80;
            textPart.Font.Color    = ColorObject.Black;

            IComment comment = slide1.Comments.Add(0.35, 0.04, "Author1", "A1", "Essential Presentation is available from 13.1 versions of Essential Studio", DateTime.Now);
            #endregion

            #region Slide2

            ISlide slide2 = presentation.Slides.Add(SlideLayoutType.Blank);

            IPresentationChart chart = slide2.Shapes.AddChart(230, 80, 500, 400);

            //Specifies the chart title

            chart.ChartTitle = "Sales Analysis";

            //Sets chart data - Row1

            chart.ChartData.SetValue(1, 2, "Jan");

            chart.ChartData.SetValue(1, 3, "Feb");

            chart.ChartData.SetValue(1, 4, "March");

            //Sets chart data - Row2

            chart.ChartData.SetValue(2, 1, 2010);

            chart.ChartData.SetValue(2, 2, 60);

            chart.ChartData.SetValue(2, 3, 70);

            chart.ChartData.SetValue(2, 4, 80);

            //Sets chart data - Row3

            chart.ChartData.SetValue(3, 1, 2011);

            chart.ChartData.SetValue(3, 2, 80);

            chart.ChartData.SetValue(3, 3, 70);

            chart.ChartData.SetValue(3, 4, 60);

            //Sets chart data - Row4

            chart.ChartData.SetValue(4, 1, 2012);

            chart.ChartData.SetValue(4, 2, 60);

            chart.ChartData.SetValue(4, 3, 70);

            chart.ChartData.SetValue(4, 4, 80);

            //Creates a new chart series with the name

            IOfficeChartSerie serieJan = chart.Series.Add("Jan");

            //Sets the data range of chart serie – start row, start column, end row, end column

            serieJan.Values = chart.ChartData[2, 2, 4, 2];

            //Creates a new chart series with the name

            IOfficeChartSerie serieFeb = chart.Series.Add("Feb");

            //Sets the data range of chart serie – start row, start column, end row, end column

            serieFeb.Values = chart.ChartData[2, 3, 4, 3];

            //Creates a new chart series with the name

            IOfficeChartSerie serieMarch = chart.Series.Add("March");

            //Sets the data range of chart series – start row, start column, end row, end column

            serieMarch.Values = chart.ChartData[2, 4, 4, 4];

            //Sets the data range of the category axis

            chart.PrimaryCategoryAxis.CategoryLabels = chart.ChartData[2, 1, 4, 1];

            //Specifies the chart type

            chart.ChartType = OfficeChartType.Column_Clustered_3D;


            slide2.Comments.Add(0.35, 0.04, "Author2", "A2", "All 3D-chart types are supported in Presentation library.", DateTime.Now);
            #endregion

            #region Slide3
            ISlide slide3 = presentation.Slides.Add(SlideLayoutType.ContentWithCaption);
            slide3.Background.Fill.FillType        = FillType.Solid;
            slide3.Background.Fill.SolidFill.Color = ColorObject.White;

            //Adds shape in slide
            IShape shape2 = (IShape)slide3.Shapes[0];
            shape2.Left   = 0.47 * 72;
            shape2.Top    = 1.15 * 72;
            shape2.Width  = 3.5 * 72;
            shape2.Height = 4.91 * 72;

            ITextBody textFrame1 = shape2.TextBody;

            //Instance to hold paragraphs in textframe
            IParagraphs paragraphs1 = textFrame1.Paragraphs;
            IParagraph  paragraph1  = paragraphs1.Add();
            paragraph1.HorizontalAlignment = HorizontalAlignmentType.Left;
            ITextPart textpart1 = paragraph1.AddTextPart();
            textpart1.Text          = "Lorem ipsum dolor sit amet, lacus amet amet ultricies. Quisque mi venenatis morbi libero, orci dis, mi ut et class porta, massa ligula magna enim, aliquam orci vestibulum tempus.";
            textpart1.Font.Color    = ColorObject.White;
            textpart1.Font.FontName = "Calibri (Body)";
            textpart1.Font.FontSize = 15;
            paragraphs1.Add();

            IParagraph paragraph2 = paragraphs1.Add();
            paragraph2.HorizontalAlignment = HorizontalAlignmentType.Left;
            textpart1               = paragraph2.AddTextPart();
            textpart1.Text          = "Turpis facilisis vitae consequat, cum a a, turpis dui consequat massa in dolor per, felis non amet.";
            textpart1.Font.Color    = ColorObject.White;
            textpart1.Font.FontName = "Calibri (Body)";
            textpart1.Font.FontSize = 15;
            paragraphs1.Add();

            IParagraph paragraph3 = paragraphs1.Add();
            paragraph3.HorizontalAlignment = HorizontalAlignmentType.Left;
            textpart1               = paragraph3.AddTextPart();
            textpart1.Text          = "Auctor eleifend in omnis elit vestibulum, donec non elementum tellus est mauris, id aliquam, at lacus, arcu pretium proin lacus dolor et. Eu tortor, vel ultrices amet dignissim mauris vehicula.";
            textpart1.Font.Color    = ColorObject.White;
            textpart1.Font.FontName = "Calibri (Body)";
            textpart1.Font.FontSize = 15;
            paragraphs1.Add();

            IParagraph paragraph4 = paragraphs1.Add();
            paragraph4.HorizontalAlignment = HorizontalAlignmentType.Left;
            textpart1               = paragraph4.AddTextPart();
            textpart1.Text          = "Lorem tortor neque, purus taciti quis id. Elementum integer orci accumsan minim phasellus vel.";
            textpart1.Font.Color    = ColorObject.White;
            textpart1.Font.FontName = "Calibri (Body)";
            textpart1.Font.FontSize = 15;
            paragraphs1.Add();

            slide3.Shapes.RemoveAt(1);
            slide3.Shapes.RemoveAt(1);

            //Adds picture in the shape
            resourcePath = "";
#if COMMONSB
            resourcePath = "SampleBrowser.Samples.Presentation.Samples.Templates.tablet.jpg";
#else
            resourcePath = "SampleBrowser.Presentation.Samples.Templates.tablet.jpg";
#endif
            fileStream = assembly.GetManifestResourceStream(resourcePath);

            IPicture picture1 = slide3.Shapes.AddPicture(fileStream, 5.18 * 72, 1.15 * 72, 7.3 * 72, 5.31 * 72);
            fileStream.Dispose();

            slide3.Comments.Add(0.14, 0.04, "Author3", "A3", "Can we use a different font family for this text?", DateTime.Now);
            #endregion

            MemoryStream memoryStream = new MemoryStream();

            presentation.Save(memoryStream);
            presentation.Close();
            memoryStream.Position = 0;
            if (Device.RuntimePlatform == Device.UWP)
            {
                Xamarin.Forms.DependencyService.Get <ISaveWindowsPhone>().Save("CommentsSamples.pptx", "application/vnd.openxmlformats-officedocument.presentationml.presentation", memoryStream);
            }
            else
            {
                Xamarin.Forms.DependencyService.Get <ISave>().Save("CommentsSamples.pptx", "application/vnd.openxmlformats-officedocument.presentationml.presentation", memoryStream);
            }
        }
示例#11
0
        private void SlideWithNotes1(IPresentation presentation)
        {
            ISlide slide1 = presentation.Slides[0];
            IShape shape1 = (IShape)slide1.Shapes[0];

            shape1.Left   = 1.27 * 72;
            shape1.Top    = 0.56 * 72;
            shape1.Width  = 9.55 * 72;
            shape1.Height = 5.4 * 72;

            ITextBody   textFrame  = shape1.TextBody;
            IParagraphs paragraphs = textFrame.Paragraphs;

            paragraphs.Add();
            IParagraph paragraph = paragraphs[0];

            paragraph.HorizontalAlignment = HorizontalAlignmentType.Left;
            ITextParts textParts = paragraph.TextParts;

            textParts.Add();
            ITextPart textPart = textParts[0];

            textPart.Text          = "Essential Presentation ";
            textPart.Font.CapsType = TextCapsType.All;
            textPart.Font.FontName = "Calibri Light (Headings)";
            textPart.Font.FontSize = 80;
            textPart.Font.Color    = ColorObject.Black;

            //Adding Notes
            INotesSlide notesSlide    = slide1.AddNotesSlide();
            ITextPart   notesTextPart = notesSlide.NotesTextBody.Paragraphs[0].TextParts.Add();

            notesTextPart.Text = "The slide represents the title content of the presentation";

            IPresentationChart chart = notesSlide.Shapes.AddChart(1.24 * 72, 5.71 * 72, 5 * 72, 3.33 * 72);


            //Specifies the chart title

            chart.ChartTitle = "Sales Analysis";

            //Sets chart data - Row1

            chart.ChartData.SetValue(1, 2, "Jan");

            chart.ChartData.SetValue(1, 3, "Feb");

            chart.ChartData.SetValue(1, 4, "March");

            //Sets chart data - Row2

            chart.ChartData.SetValue(2, 1, 2010);

            chart.ChartData.SetValue(2, 2, 60);

            chart.ChartData.SetValue(2, 3, 70);

            chart.ChartData.SetValue(2, 4, 80);

            //Sets chart data - Row3

            chart.ChartData.SetValue(3, 1, 2011);

            chart.ChartData.SetValue(3, 2, 80);

            chart.ChartData.SetValue(3, 3, 70);

            chart.ChartData.SetValue(3, 4, 60);

            //Sets chart data - Row4

            chart.ChartData.SetValue(4, 1, 2012);

            chart.ChartData.SetValue(4, 2, 60);

            chart.ChartData.SetValue(4, 3, 70);

            chart.ChartData.SetValue(4, 4, 80);

            //Creates a new chart series with the name

            IOfficeChartSerie serieJan = chart.Series.Add("Jan");

            //Sets the data range of chart serie – start row, start column, end row, end column

            serieJan.Values = chart.ChartData[2, 2, 4, 2];

            //Creates a new chart series with the name

            IOfficeChartSerie serieFeb = chart.Series.Add("Feb");

            //Sets the data range of chart serie – start row, start column, end row, end column

            serieFeb.Values = chart.ChartData[2, 3, 4, 3];

            //Creates a new chart series with the name

            IOfficeChartSerie serieMarch = chart.Series.Add("March");

            //Sets the data range of chart series – start row, start column, end row, end column

            serieMarch.Values = chart.ChartData[2, 4, 4, 4];

            //Sets the data range of the category axis

            chart.PrimaryCategoryAxis.CategoryLabels = chart.ChartData[2, 1, 4, 1];

            //Specifies the chart type

            chart.ChartType = OfficeChartType.Column_Clustered;

            chart.ChartTitle = "Chart inside Notes section";
        }
示例#12
0
        private void SlideWithComments(IPresentation presentation)
        {
            #region Slide 1
            ISlide slide1 = presentation.Slides[0];
            IShape shape1 = (IShape)slide1.Shapes[0];
            shape1.Left   = 1.27 * 72;
            shape1.Top    = 0.85 * 72;
            shape1.Width  = 10.86 * 72;
            shape1.Height = 3.74 * 72;

            ITextBody   textFrame  = shape1.TextBody;
            IParagraphs paragraphs = textFrame.Paragraphs;
            paragraphs.Add();
            IParagraph paragraph = paragraphs[0];
            paragraph.HorizontalAlignment = HorizontalAlignmentType.Left;
            ITextParts textParts = paragraph.TextParts;
            textParts.Add();
            ITextPart textPart = textParts[0];
            textPart.Text          = "Essential Presentation ";
            textPart.Font.CapsType = TextCapsType.All;
            textPart.Font.FontName = "Calibri Light (Headings)";
            textPart.Font.FontSize = 80;
            textPart.Font.Color    = ColorObject.Black;

            IComment comment = slide1.Comments.Add(0.5, 0.04, "Author1", "A1", "Essential Presentation is available from 13.1 versions of Essential Studio", DateTime.Now);
            //Author2 add reply to a parent comment
            slide1.Comments.Add("Author2", "A2", "Does it support rendering of slides as images or PDF?", DateTime.Now, comment);
            //Author1 add reply to a parent comment
            slide1.Comments.Add("Author1", "A1", "Yes, you may render slides as images and PDF.", DateTime.Now, comment);
            #endregion

            #region Slide2

            ISlide slide2 = presentation.Slides.Add(SlideLayoutType.Blank);

            IPresentationChart chart = slide2.Shapes.AddChart(230, 80, 500, 400);

            //Specifies the chart title

            chart.ChartTitle = "Sales Analysis";

            //Sets chart data - Row1

            chart.ChartData.SetValue(1, 2, "Jan");

            chart.ChartData.SetValue(1, 3, "Feb");

            chart.ChartData.SetValue(1, 4, "March");

            //Sets chart data - Row2

            chart.ChartData.SetValue(2, 1, 2010);

            chart.ChartData.SetValue(2, 2, 60);

            chart.ChartData.SetValue(2, 3, 70);

            chart.ChartData.SetValue(2, 4, 80);

            //Sets chart data - Row3

            chart.ChartData.SetValue(3, 1, 2011);

            chart.ChartData.SetValue(3, 2, 80);

            chart.ChartData.SetValue(3, 3, 70);

            chart.ChartData.SetValue(3, 4, 60);

            //Sets chart data - Row4

            chart.ChartData.SetValue(4, 1, 2012);

            chart.ChartData.SetValue(4, 2, 60);

            chart.ChartData.SetValue(4, 3, 70);

            chart.ChartData.SetValue(4, 4, 80);

            //Creates a new chart series with the name

            IOfficeChartSerie serieJan = chart.Series.Add("Jan");

            //Sets the data range of chart serie – start row, start column, end row, end column

            serieJan.Values = chart.ChartData[2, 2, 4, 2];

            //Creates a new chart series with the name

            IOfficeChartSerie serieFeb = chart.Series.Add("Feb");

            //Sets the data range of chart serie – start row, start column, end row, end column

            serieFeb.Values = chart.ChartData[2, 3, 4, 3];

            //Creates a new chart series with the name

            IOfficeChartSerie serieMarch = chart.Series.Add("March");

            //Sets the data range of chart series – start row, start column, end row, end column

            serieMarch.Values = chart.ChartData[2, 4, 4, 4];

            //Sets the data range of the category axis

            chart.PrimaryCategoryAxis.CategoryLabels = chart.ChartData[2, 1, 4, 1];

            //Specifies the chart type

            chart.ChartType = OfficeChartType.Column_Clustered_3D;


            slide2.Comments.Add(0.35, 0.04, "Author2", "A2", "Do all 3D-chart types support in Presentation library?", DateTime.Now);

            #endregion
        }
示例#13
0
        /// <summary>
        /// Exports the Data as chart to the PowerPoint Slide
        /// </summary>
        /// <returns>Returns the generated presentation</returns>
        private IPresentation CreateChartFromGrid()
        {
            //Create a new instance of Presentation
            IPresentation presentation = Presentation.Open(ResolveApplicationDataPath("DataTemplate.pptx"));

            foreach (ISlide slide in presentation.Slides)
            {
                //Iterate each shape in the slide
                for (int i = 0; i < slide.Shapes.Count; i++)
                {
                    //Retrieves the shape
                    IShape shape = slide.Shapes[i] as IShape;
                    //Removes the shape from the shape collection.
                    slide.Shapes.Remove(shape);
                }
            }
            int slideIndex = 0;
            //Clone the slide
            ISlide clonedSlide = presentation.Slides[0].Clone();

            //Iterate each data of the Grid
            foreach (PresentationData presentationData in PresentationData.presentationData)
            {
                if (slideIndex > 0)
                {
                    presentation.Slides.Add(clonedSlide);
                }
                //Gets the slide of the presentation
                ISlide slide = slide = presentation.Slides[slideIndex];
                //Adds chart to the slide with position and size
                IPresentationChart chart = slide.Charts.AddChart(100, 10, 700, 500);
                //Set the first row of the chart values
                chart.ChartData.SetValue(1, 2, "Jan");
                chart.ChartData.SetValue(1, 3, "Feb");
                chart.ChartData.SetValue(1, 4, "Mar");
                chart.ChartData.SetValue(1, 5, "Apr");
                chart.ChartData.SetValue(1, 6, "May");
                //Initalize the row index
                int    rowIndex = 2;
                int?[] array    = new int?[] { presentationData.Year, presentationData.Jan, presentationData.Feb, presentationData.Mar, presentationData.Apr, presentationData.May };
                for (int i = 0; i < array.Length; i++)
                {
                    //Initialize the column index
                    int columnIndex = i + 1;
                    //Set the value for chart
                    chart.ChartData.SetValue(rowIndex, columnIndex, array[i].Value);
                    if (columnIndex == array.Length)
                    {
                        //Creates a new chart series with the name
                        IOfficeChartSerie series = chart.Series.Add(array[0].Value.ToString());

                        //Sets the data range of chart series – start row, start column, end row, end column
                        series.Values = chart.ChartData[2, 2, 2, 6];

                        //Sets the data range of the category axis
                        chart.PrimaryCategoryAxis.CategoryLabels = chart.ChartData[1, 2, 1, 6];

                        //Sets the type of the chart
                        chart.ChartType = OfficeChartType.Pie;

                        //Sets a value indicates wherher to fill style is visible or not
                        chart.ChartArea.Fill.Visible = false;

                        IOfficeChartFrameFormat chartPlotArea = chart.PlotArea;
                        //Sets a value indicates wherher to fill style is visible or not
                        chartPlotArea.Fill.Visible = false;

                        //Specifies the chart title
                        chart.ChartTitle = "Sales details of the year " + array[0].Value.ToString();

                        //Sets the legend position
                        chart.Legend.Position = OfficeLegendPosition.Right;
                    }
                }
                rowIndex++;
                slideIndex++;
            }
            return(presentation);
        }
示例#14
0
        private void CreateChart(ISlide slide, DataTable dataTable, ViewData viewData)
        {
            IPresentationChart chart = slide.Charts.AddChart(100, 10, 700, 500);

            //Cleaning DataTable (Let's keep it common for all kinds)
            List <string> removeColumns = new List <string>();
            string        paName        = viewData.PrimaryAxis;

            foreach (DataColumn item in dataTable.Columns)
            {
                if (!(viewData.SerieList.Contains(item.ColumnName) || viewData.PrimaryAxis.Contains(item.ColumnName.Replace(" ", ""))))
                {
                    removeColumns.Add(item.ColumnName);
                }
                if (viewData.PrimaryAxis.Contains(item.ColumnName.Replace(" ", "")))
                {
                    paName = item.ColumnName;
                }
            }
            foreach (var columnName in removeColumns)
            {
                dataTable.Columns.Remove(columnName);
            }

            //Adding Data to Chart
            int nColumns = dataTable.Columns.Count;
            int nRows    = dataTable.Rows.Count;

            for (int i = 1; i <= nColumns; i++)
            {
                chart.ChartData.SetValue(1, i, dataTable.Columns[i - 1]);
            }
            for (int i = 1; i < nRows; i++)
            {
                for (int j = 1; j <= nColumns; j++)
                {
                    chart.ChartData.SetValue(i + 1, j, dataTable.Rows[i - 1].ItemArray[j - 1]);
                }
            }

            //Adding page elements
            //chart.ChartType = GetChartType(viewData.ChartType);
            chart.ChartTitle = dataTable.TableName;

            if (viewData.ChartType.Equals("TreeMap"))
            {
                chart.ChartType = GetChartType(viewData.ChartType);
                chart.DataRange = chart.ChartData[1, 1, nRows, nColumns];
            }
            else if (viewData.ChartType.Equals("LineAndBar"))
            {
                CreateLineAndBar(dataTable, viewData, chart, nRows);
            }
            else if (viewData.ChartType.Equals("LineAndScatter"))
            {
                CreateLineAndScatter(dataTable, viewData, chart, nRows);
            }
            else if (viewData.ChartType.Equals("BarAndScatter"))
            {
                CreateBarAndScatter(dataTable, viewData, chart, nRows);
            }
            else
            {
                AddDataToCommonCharts(dataTable, viewData, chart, paName, nRows);
            }
        }
示例#15
0
        /// <summary>
        /// Creates slides with chart.
        /// </summary>
        private static void CreateChart(IPresentation presentation)
        {
            //Adds a blank slide to the presentation.
            ISlide slide1 = presentation.Slides.Add(SlideLayoutType.Blank);
            //Adds a chart to the slide with position and size.
            IPresentationChart chart = slide1.Shapes.AddChart(1.93 * 72, 0.31 * 72, 9.48 * 72, 6.89 * 72);

            //Sets the data for chart– RowIndex, columnIndex and data.
            chart.ChartData.SetValue(1, 1, "Crescent City, CA");
            chart.ChartData.SetValue(3, 2, "Precipitation,in.");
            chart.ChartData.SetValue(3, 3, "Temperature,deg.F");

            chart.ChartData.SetValue(4, 1, "Jan");
            chart.ChartData.SetValue(5, 1, "Feb");
            chart.ChartData.SetValue(6, 1, "March");
            chart.ChartData.SetValue(7, 1, "Apr");
            chart.ChartData.SetValue(8, 1, "May");
            chart.ChartData.SetValue(9, 1, "June");
            chart.ChartData.SetValue(10, 1, "July");
            chart.ChartData.SetValue(11, 1, "Aug");
            chart.ChartData.SetValue(12, 1, "Sept");
            chart.ChartData.SetValue(13, 1, "Oct");
            chart.ChartData.SetValue(14, 1, "Nov");
            chart.ChartData.SetValue(15, 1, "Dec");

            chart.ChartData.SetValue(4, 2, 10.9);
            chart.ChartData.SetValue(5, 2, 8.9);
            chart.ChartData.SetValue(6, 2, 8.6);
            chart.ChartData.SetValue(7, 2, 4.8);
            chart.ChartData.SetValue(8, 2, 3.2);
            chart.ChartData.SetValue(9, 2, 1.4);
            chart.ChartData.SetValue(10, 2, 0.6);
            chart.ChartData.SetValue(11, 2, 0.7);
            chart.ChartData.SetValue(12, 2, 1.7);
            chart.ChartData.SetValue(13, 2, 5.4);
            chart.ChartData.SetValue(14, 2, 9.0);
            chart.ChartData.SetValue(15, 2, 10.4);

            chart.ChartData.SetValue(4, 3, 47.5);
            chart.ChartData.SetValue(5, 3, 48.7);
            chart.ChartData.SetValue(6, 3, 48.9);
            chart.ChartData.SetValue(7, 3, 50.2);
            chart.ChartData.SetValue(8, 3, 53.1);
            chart.ChartData.SetValue(9, 3, 56.3);
            chart.ChartData.SetValue(10, 3, 58.1);
            chart.ChartData.SetValue(11, 3, 59.0);
            chart.ChartData.SetValue(12, 3, 58.5);
            chart.ChartData.SetValue(13, 3, 55.4);
            chart.ChartData.SetValue(14, 3, 51.1);
            chart.ChartData.SetValue(15, 3, 47.8);
            //Sets the data range of chart series – start row, start column, end row, end column.
            chart.DataRange = chart.ChartData[3, 1, 15, 3];
            //Sets the chart title and axis title.
            chart.ChartTitle             = "Crescent City, CA";
            chart.PrimaryValueAxis.Title = "Precipitation,in.";
            chart.PrimaryValueAxis.TitleArea.TextRotationAngle = 90;
            chart.PrimaryValueAxis.MaximumValue = 14.0;
            chart.PrimaryValueAxis.NumberFormat = "0.0";

            #region Format Series
            //Formats the first serie.
            IOfficeChartSerie serieOne = chart.Series[0];
            serieOne.Name = "Precipitation,in.";
            serieOne.SerieFormat.Fill.FillType = OfficeFillType.Gradient;
            serieOne.SerieFormat.Fill.TwoColorGradient(OfficeGradientStyle.Vertical, OfficeGradientVariants.ShadingVariants_2);
            serieOne.SerieFormat.Fill.GradientColorType = OfficeGradientColor.TwoColor;
            serieOne.SerieFormat.Fill.ForeColor         = Color.Plum;

            //Shows value as data labels.
            serieOne.DataPoints.DefaultDataPoint.DataLabels.IsValue  = true;
            serieOne.DataPoints.DefaultDataPoint.DataLabels.Position = OfficeDataLabelPosition.Outside;

            //Formats the second serie.
            IOfficeChartSerie serieTwo = chart.Series[1];
            serieTwo.SerieType = OfficeChartType.Line_Markers;
            serieTwo.Name      = "Temperature,deg.F";

            //Formats marker.
            serieTwo.SerieFormat.MarkerStyle              = OfficeChartMarkerType.Diamond;
            serieTwo.SerieFormat.MarkerSize               = 8;
            serieTwo.SerieFormat.MarkerBackgroundColor    = Color.DarkGreen;
            serieTwo.SerieFormat.MarkerForegroundColor    = Color.DarkGreen;
            serieTwo.SerieFormat.LineProperties.LineColor = Color.DarkGreen;

            //Uses Secondary Axis.
            serieTwo.UsePrimaryAxis = false;
            #endregion

            #region Set the Secondary Axis for Second Serie.
            //Displays secondary axis for the series.
            chart.SecondaryCategoryAxis.IsMaxCross = true;
            chart.SecondaryValueAxis.IsMaxCross    = true;

            //Sets the title.
            chart.SecondaryValueAxis.Title = "Temperature,deg.F";
            chart.SecondaryValueAxis.TitleArea.TextRotationAngle = 90;

            //Hides the secondary category axis.
            chart.SecondaryCategoryAxis.Border.LineColor  = Color.Transparent;
            chart.SecondaryCategoryAxis.MajorTickMark     = OfficeTickMark.TickMark_None;
            chart.SecondaryCategoryAxis.TickLabelPosition = OfficeTickLabelPosition.TickLabelPosition_None;
            #endregion

            #region Legend setting
            chart.Legend.Position         = OfficeLegendPosition.Bottom;
            chart.Legend.IsVerticalLegend = false;
            #endregion
        }