如何使用OpenXML自动化功率点滑动持续时间

时间:2017-05-25 11:46:18

标签: c# asp.net-mvc powerpoint openxml openxml-sdk

我在一个文件夹中有一堆Power Point文件。我必须检查每张幻灯片上是否设置转换幻灯片持续时间,未设置转换幻灯片持续时间,然后添加转换幻灯片持续时间并将该文件存储在单独的位置。目前,我能够复制演示文稿和访问幻灯片部分,但是如何检查和添加转换幻灯片持续时间然后存储在分离位置?

这是我的代码

foreach(var serverpath in serverpathCollection)
{
    using (var templateFile = System.IO.File.Open(Server.MapPath(serverpath), FileMode.Open, FileAccess.Read)) //read our template
    {
        using (var stream = new MemoryStream())
        {
            templateFile.CopyTo(stream); //copy template
            using (var presentationDocument = PresentationDocument.Open(stream, true)) //open presentation document
            {
                // Get the presentation part from the presentation document.
                var presentationPart = presentationDocument.PresentationPart;
                // Get the presentation from the presentation part.
                var presentation = presentationPart.Presentation;

                var slideList = new List<SlidePart>();
                //get available slide list
                foreach (SlideId slideID in presentation.SlideIdList)
                {
                    var slide = (SlidePart)presentationPart.GetPartById(slideID.RelationshipId);
                    slideList.Add(slide);
                    //SlideDictionary.Add(slide, slideID);//add to dictionary to be used when needed
                }
                //presentationPart.Presentation.Save();
            }
            //?? store/create PPT file in a new location
        }
    }    
}

0 个答案:

没有答案