示例#1
0
 public void AddChartLegend(PPT.Chart chart, ChartLegend chartLegend)
 {
     chart.HasLegend             = true;
     chart.Legend.Font.Italic    = chartLegend.italic;
     chart.Legend.Font.Bold      = chartLegend.bold;
     chart.Legend.Font.Underline = chartLegend.underline;
     chart.Legend.Font.Size      = chartLegend.fontSize;
     chart.Refresh();
 }
示例#2
0
 public void AddChartTitle(PPT.Chart chart, ChartTitle chartTitle)
 {
     chart.HasTitle                  = true;
     chart.ChartTitle.Text           = chartTitle.titleText;
     chart.ChartTitle.Font.Italic    = chartTitle.italic;
     chart.ChartTitle.Font.Bold      = chartTitle.bold;
     chart.ChartTitle.Font.Underline = chartTitle.underline;
     chart.ChartTitle.Font.Size      = chartTitle.fontSize;
     chart.Refresh();
 }
示例#3
0
        public void AddSeriesToExistingChart(PPT.Chart chart, ChartSeries series)
        {
            var workbook = (EXCEL.Workbook)chart.ChartData.Workbook;

            workbook.Windows.Application.Visible = false;
            var cellNumber = 1;

            var dataSheet = (EXCEL.Worksheet)workbook.Worksheets[1];

            var sc          = (PPT.SeriesCollection)chart.SeriesCollection();
            var seriesCount = sc.Count;
            var letter      = IntToLetters((seriesCount + 2));

            foreach (var value in series.seriesData)
            {
                var cellPosition = letter + cellNumber.ToString();
                dataSheet.Cells.Range[cellPosition].Value2 = value;
                cellNumber++;
                chart.Refresh();
            }

            // we have to populate the sheet with new values, now we need to create a series for it!
            var columnsRange = dataSheet.UsedRange.Columns;
            var rowsRange    = dataSheet.UsedRange.Rows;

            var columnCount      = columnsRange.Columns.Count;
            var rowCount         = rowsRange.Rows.Count;
            var lastColumnLetter = IntToLetters(columnCount);

            var newSeries = sc.NewSeries();

            newSeries.Name      = series.name;
            newSeries.XValues   = "'Sheet1'!$A$1:$A$" + rowCount;
            newSeries.Values    = "'Sheet1'!$" + lastColumnLetter + "$1:$" + lastColumnLetter + "$" + rowCount;
            newSeries.ChartType = series.seriesType;

            chart.Refresh();
        }