• 大小: 4.55MB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2023-08-14
  • 语言: ASP
  • 标签: Slides  Cells  PowePoint  Table  

资源简介

运用Aspose.Cells.dll 和Aspose.Slides.dll替换powerpoint里面的chart、table的数据源,替换ppt里面的文字。

资源截图

代码片段和文件信息

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Aspose.Cells;
using Aspose.Slides;
using System.IO;
using Aspose.Cells.Charts;
using System.Drawing;

namespace Rap.Report.Slides
{
    static class ChartUtils
    {
        private static Random random = new Random(Environment.TickCount);

        /// 替换chart数据
        /// 
        /// 替换chart数据
        /// 

        /// tle“>chart标题
        /// 数据源
        /// 模板名称
        /// chart名
        /// ppt页码
        public static void GetChart(string charttitle IListject[]> list Slide slide string chartName)
        {
            Shape shape = slide.FindShape(chartName);
            Oleobjectframe ole = (Oleobjectframe)shape;
            if (ole != null)
            {
                Workbook wb = new Workbook();
                var ms = new MemoryStream(ole.objectData);
                wb.Open(ms);
                int chartindex = 0;
                int sheetidx = 1;
                Chart chart = null;
                if (wb.Worksheets[1].Charts.Count > 0)
                {
                    chartindex = 1;
                    sheetidx = 0;
                }
                chart = wb.Worksheets[chartindex].Charts[0];
                if (chart.Shapes.Count > 0)
                {
                    chart.Shapes.RemoveAt(0);
                }
                chart.title.Text = charttitle;
                Worksheet sheet = wb.Worksheets[sheetidx];
                ExcelUtils.SetChartData(sheet list);
                //设置chart取值范围
                for (int i = 0; i < chart.NSeries.Count; i++)
                {
                    chart.NSeries[i].XValues = string.Format(“{0}!{1}:{2}“ sheet.Name“A2“ “A“+list.Count.ToString());
                    chart.NSeries[i].Name = sheet.Cells[0 i + 1].Value.ToString();
                    chart.NSeries[i].Values = string.Format(“{0}!{1}:{2}“ sheet.Name ExcelUtils.COLUMNS[i + 1] + “2“
                        ExcelUtils.COLUMNS[i + 1] + list.Count.ToString());
                    chart.NSeries[i].IsColorVaried = true;
                    
                }
                SetChartstyle(chart);
                wb.CalculateFormula();
                ms = wb.SaveToStream();
                ole.objectData = ms.ToArray();
                Bitmap bitmap = chart.ToImage();
                Aspose.Slides.Picture pic = new Aspose.Slides.Picture(slide.Parent bitmap);
                ole.PictureId = slide.Parent.Pictures.Add(pic);
                //bitmap.Save(“..\\..\\PPTFiles\\Template\\“ + random.Next() + “.jpg“);
                //wb.Save(@“..\..\PPTFiles\“ + random.Next() + “.xls“ Aspose.Cells.SaveFormat.Excel97To2003);
            }
        }

        /// 设置chart样式
        /// 

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件       1582  2013-01-08 17:55  Rap.Report.Slides\.svn\all-wcprops

     文件       2082  2013-01-08 17:55  Rap.Report.Slides\.svn\entries

     文件        144  2013-01-08 17:55  Rap.Report.Slides\.svn\text-base\app.config.svn-base

     文件       3967  2013-01-08 17:55  Rap.Report.Slides\.svn\text-base\ChartUtils.cs.svn-base

     文件       2678  2013-01-08 17:55  Rap.Report.Slides\.svn\text-base\ExcelUtils.cs.svn-base

     文件       7803  2013-01-08 17:55  Rap.Report.Slides\.svn\text-base\Form1.cs.svn-base

     文件       5437  2013-01-08 17:55  Rap.Report.Slides\.svn\text-base\Form1.Designer.cs.svn-base

     文件       5817  2013-01-08 17:55  Rap.Report.Slides\.svn\text-base\Form1.resx.svn-base

     文件       3795  2013-01-08 17:55  Rap.Report.Slides\.svn\text-base\LineChartUtils.cs.svn-base

     文件        881  2013-01-08 17:55  Rap.Report.Slides\.svn\text-base\MessageUtils.cs.svn-base

     文件        513  2013-01-08 17:55  Rap.Report.Slides\.svn\text-base\Program.cs.svn-base

     文件       4825  2013-01-08 17:55  Rap.Report.Slides\.svn\text-base\Rap.Report.Slides.csproj.svn-base

     文件        227  2013-01-08 17:55  Rap.Report.Slides\.svn\text-base\Rap.Report.Slides.csproj.user.svn-base

     文件       3424  2013-01-08 17:55  Rap.Report.Slides\.svn\text-base\TableBuilder.cs.svn-base

     文件        144  2013-01-06 11:29  Rap.Report.Slides\app.config

     文件    7197528  2011-12-08 21:41  Rap.Report.Slides\bin\Debug\Aspose.Cells.dll

     文件     763076  2012-12-27 21:29  Rap.Report.Slides\bin\Debug\Aspose.Cells.tlb

     文件    3286528  2010-01-28 22:48  Rap.Report.Slides\bin\Debug\Aspose.Slides.dll

     文件      22528  2013-01-09 15:54  Rap.Report.Slides\bin\Debug\Rap.Report.Slides.exe

     文件        144  2013-01-06 11:29  Rap.Report.Slides\bin\Debug\Rap.Report.Slides.exe.config

     文件      48640  2013-01-09 15:54  Rap.Report.Slides\bin\Debug\Rap.Report.Slides.pdb

     文件      11600  2013-01-09 15:55  Rap.Report.Slides\bin\Debug\Rap.Report.Slides.vshost.exe

     文件        144  2013-01-06 11:29  Rap.Report.Slides\bin\Debug\Rap.Report.Slides.vshost.exe.config

     文件        490  2010-03-17 22:39  Rap.Report.Slides\bin\Debug\Rap.Report.Slides.vshost.exe.manifest

     文件       4260  2013-01-09 15:55  Rap.Report.Slides\ChartUtils.cs

     文件       2678  2013-01-06 16:02  Rap.Report.Slides\ExcelUtils.cs

     文件       7803  2013-01-08 14:33  Rap.Report.Slides\Form1.cs

     文件       5437  2013-01-08 14:33  Rap.Report.Slides\Form1.Designer.cs

     文件       5817  2013-01-08 14:33  Rap.Report.Slides\Form1.resx

     文件       3795  2013-01-08 16:47  Rap.Report.Slides\LineChartUtils.cs

............此处省略84个文件信息

评论

共有 条评论