[英]Can't access SlideMasterPart in PowerPoint using OpenXml
我正在嘗試使用此OpenXml教程動態創建一個pptx文件。
我收到錯誤消息:
'System.Collections.Generic.IEnumerable'不包含'First'的定義,並且找不到擴展方法'First'接受類型為'System.Collections.Generic.IEnumerable'的第一個參數(是否缺少using指令?或裝配參考?)
在以下行中:
var slideMasterPart = presentationPart.SlideMasterParts.First();
有解決方法嗎?
添加對using System.Linq;
的引用using System.Linq;
作為解釋, First()
方法是一種擴展方法,位於System.Linq
命名空間中,並且適用於從IEnumerable
繼承的任何內容。 有關更多信息,請參見MSDN文檔Enumerable.First方法和System.Linq命名空間 。
您需要輸入將返回的類型名稱:
var slideMasterPart = presentationPart.SlideMasterParts.First<**NameOfType**>();
干杯-
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.