簡體   English   中英

使用 C# 讀取 header 和 Power Point 幻燈片的幻燈片注釋的頁腳

[英]Reading header and footer of slide notes of Power point slide using C#

使用 C# 讀取 header 和 Power point 幻燈片的幻燈片注腳,我正在使用DocumentFormat.OpenXml.Packaging . 以下代碼包含NotesSlidePart部分,我需要在其中獲取 header 和注釋頁腳(不是 header 和幻燈片頁腳)。

using DocumentFormat.OpenXml.Packaging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace TRackChaePPTX
{
    public class pptx
    {
        private string fullFileName;
        private bool hasreviewcommentexist = false;
        private readonly object StyleTickmark;

       public bool GetCommentsFromPresentation(string fileName)
        {
            try
            {
                using (PresentationDocument pptDoc =PresentationDocument.Open(fileName, false))
                {
                    List<string> PPtCommentList = new List<string>();
                    List<string> lstNotes = new List<string>();

                   
                    foreach (SlidePart slide in pptDoc.PresentationPart.SlideParts)
                    {


                        SlideCommentsPart slideCommentsPart = slide.SlideCommentsPart;

                        if (slideCommentsPart != null && slide.SlideCommentsPart.CommentList != null)
                        {
                            if (slide.SlideCommentsPart.CommentList.Count() > 0)
                            {
                                hasreviewcommentexist = true;
                                break;
                            }
                        }
                        else if (slide.NotesSlidePart != null)
                        {
                            if (slide.NotesSlidePart.NotesSlide.Count() > 0 && slide.NotesSlidePart.NotesSlide.InnerText != "")
                            {

         // Console.writeLine(Header and footer text of slide note...)
                                if (slide.NotesSlidePart.NotesSlide.InnerText.Length > 1)
                                {
                                    hasreviewcommentexist = true;
                                    break;
                                }


                            }
                        }
                        else
                        {
                            hasreviewcommentexist = false;
                        }

                    }

                }
            }
            catch (Exception ex)
            {
                hasreviewcommentexist = false;
            }
            return hasreviewcommentexist;
        }

    }
}

在上面的代碼中使用了 DocumentFormat.OpenXml.Packaging。

默認情況下,每張幻燈片都有一個注釋部分,通過上面的代碼,我得到了幻燈片的注釋和 header 和幻燈片注釋的頁腳,我只需要幻燈片注釋或跳過 header 和頁腳內容。 謝謝

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM