SpreadsheetDocument.AddNewPart<T>(String, String) Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Adds a new part of type T
.
public override T AddNewPart<T> (string contentType, string id) where T : DocumentFormat.OpenXml.Packaging.OpenXmlPart;
public override T AddNewPart<T> (string contentType, string? id) where T : DocumentFormat.OpenXml.Packaging.OpenXmlPart;
override this.AddNewPart : string * string -> 'T (requires 'T :> DocumentFormat.OpenXml.Packaging.OpenXmlPart)
Public Overrides Function AddNewPart(Of T As OpenXmlPart) (contentType As String, id As String) 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
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.