Udostępnij za pośrednictwem


OpenXmlPartContainer.AddNewPart Method

Definition

Overloads

AddNewPart<T>(String)

Adds a new part of type T.

AddNewPart<T>(String, String)

Adds a new part of type T.

AddNewPart<T>()

Adds a new part of type T.

AddNewPart<T>(String)

Adds a new part of type T.

public T AddNewPart<T> (string id) where T : DocumentFormat.OpenXml.Packaging.OpenXmlPart, DocumentFormat.OpenXml.Packaging.IFixedContentTypePart;
member this.AddNewPart : string -> 'T (requires 'T :> DocumentFormat.OpenXml.Packaging.OpenXmlPart and 'T :> DocumentFormat.OpenXml.Packaging.IFixedContentTypePart)
Public Function AddNewPart(Of T As {OpenXmlPart, IFixedContentTypePart}) (id As String) As T

Type Parameters

T

The class of the part.

Parameters

id
String

The relationship id.

Returns

T

The added part.

Exceptions

When the part is not allowed to be referenced by this part.

Applies to

AddNewPart<T>(String, String)

Adds a new part of type T.

public virtual T AddNewPart<T> (string contentType, string id) where T : DocumentFormat.OpenXml.Packaging.OpenXmlPart;
public virtual T AddNewPart<T> (string contentType, string? id = default) where T : DocumentFormat.OpenXml.Packaging.OpenXmlPart;
abstract member AddNewPart : string * string -> 'T (requires 'T :> DocumentFormat.OpenXml.Packaging.OpenXmlPart)
override this.AddNewPart : string * string -> 'T (requires 'T :> DocumentFormat.OpenXml.Packaging.OpenXmlPart)
Public Overridable Function AddNewPart(Of T As OpenXmlPart) (contentType As String, id As String) As T
Public Overridable Function AddNewPart(Of T As OpenXmlPart) (contentType As String, Optional id As String = Nothing) As T

Type Parameters

T

The class of the part.

Parameters

contentType
String

The content type of the part. Must match the defined content type if the part is fixed content type.

id
String

The relationship id. The id will be automatically generated if this param is null.

Returns

T

The added part.

Exceptions

When the part is not allowed to be referenced by this part.

When the part is fixed content type and the passed in contentType does not match the defined content type.

Thrown when "contentType" is null reference.

Remarks

Mainly used for adding not-fixed content type part - ImagePart, etc

Applies to

AddNewPart<T>()

Adds a new part of type T.

public T AddNewPart<T> () where T : DocumentFormat.OpenXml.Packaging.OpenXmlPart, DocumentFormat.OpenXml.Packaging.IFixedContentTypePart;
member this.AddNewPart : unit -> 'T (requires 'T :> DocumentFormat.OpenXml.Packaging.OpenXmlPart and 'T :> DocumentFormat.OpenXml.Packaging.IFixedContentTypePart)
Public Function AddNewPart(Of T As {OpenXmlPart, IFixedContentTypePart}) () As T

Type Parameters

T

The class of the part.

Returns

T

The added part.

Exceptions

When the part is not allowed to be referenced by this part.

Applies to