public static void AddElementEventFeature(this OpenXmlPackage package) { if (package.Features.Get <IElementEventFeature>() is null) { package.AddPartRootEventsFeature(); var rootEvent = package.Features.GetRequired <IPartRootEventsFeature>(); package.Features.SetDisposable <IElementEventFeature>(new ElementEventFeature(rootEvent)); } }