Ste
Ste

Reputation: 1136

Can't access SlideMasterPart in PowerPoint using OpenXml

I am trying to create a pptx file on the fly using this OpenXml tutorial.

I am getting the error:

'System.Collections.Generic.IEnumerable' does not contain a definition for 'First' and no extension method 'First' accepting a first argument of type 'System.Collections.Generic.IEnumerable' could be found (are you missing a using directive or an assembly reference?)

on the following line:

var slideMasterPart = presentationPart.SlideMasterParts.First();

Is there a workaround?

Upvotes: 0

Views: 180

Answers (2)

Aquila Sands
Aquila Sands

Reputation: 1471

Add the reference to using System.Linq;

By way of explanation, the First() method is an extension method that lives in the System.Linq namespace and is applied to anything that inherits from IEnumerable. See the MSDN docs Enumerable.First Method and System.Linq Namespace for more info.

Upvotes: 1

simon at rcl
simon at rcl

Reputation: 7344

You need to put in the type name that will be returned:

var slideMasterPart = presentationPart.SlideMasterParts.First<**NameOfType**>();

Cheers -

Upvotes: 0

Related Questions