C# 如何使用OpenXML自动化power point幻灯片持续时间

C# 如何使用OpenXML自动化power point幻灯片持续时间,c#,asp.net-mvc,powerpoint,openxml,openxml-sdk,C#,Asp.net Mvc,Powerpoint,Openxml,Openxml Sdk,我在一个文件夹里有一堆Power Point文件。我必须检查每张幻灯片上是否设置了过渡幻灯片持续时间,如果未设置过渡幻灯片持续时间,则添加过渡幻灯片持续时间并将该文件存储在单独的位置。目前,我可以复制演示文档并访问幻灯片部分,但如何检查和添加过渡幻灯片持续时间,然后将其存储在分离位置? 这是我的密码 foreach(var serverpath in serverpathCollection) { using (var templateFile = System.IO.File.Open

我在一个文件夹里有一堆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
        }
    }    
}
foreach(serverpathCollection中的var serverpath)
{
使用(var templateFile=System.IO.File.Open(Server.MapPath(serverpath)、FileMode.Open、FileAccess.Read))//读取我们的模板
{
使用(var stream=new MemoryStream())
{
templateFile.CopyTo(流);//复制模板
使用(var presentationDocument=presentationDocument.Open(stream,true))//打开演示文档
{
//从演示文稿文档中获取演示文稿部分。
var presentationPart=presentationDocument.presentationPart;
//从演示文稿部分获取演示文稿。
var presentation=presentationPart.presentation;
var slideList=新列表();
//获取可用的幻灯片列表
foreach(演示文稿中的SlideId.slidedlist)
{
var slide=(SlidePart)presentationPart.GetPartById(slideID.RelationshipId);
幻灯片列表。添加(幻灯片);
//SlideDictionary.Add(slide,slideID);//添加到字典,以便在需要时使用
}
//presentationPart.Presentation.Save();
}
//?在新位置存储/创建PPT文件
}
}    
}