public EmbeddedControlPersistencePart AddEmbeddedControlPersistencePart(EmbeddedControlPersistencePartType partType) { var contentType = EmbeddedControlPersistencePartTypeInfo.GetContentType(partType); var partExtension = EmbeddedControlPersistencePartTypeInfo.GetTargetExtension(partType); OpenXmlPackage.PartExtensionProvider.MakeSurePartExtensionExist(contentType, partExtension); return(AddEmbeddedControlPersistencePart(contentType)); }
internal static string GetTargetExtension(EmbeddedControlPersistencePartType controlType) { switch (controlType) { case EmbeddedControlPersistencePartType.ActiveX: return(".xml"); case EmbeddedControlPersistencePartType.ActiveXBin: return(".bin"); default: return(".bin"); } }
internal static string GetContentType(EmbeddedControlPersistencePartType controlType) { switch (controlType) { case EmbeddedControlPersistencePartType.ActiveX: return("application/vnd.ms-office.activeX+xml"); case EmbeddedControlPersistencePartType.ActiveXBin: return("application/vnd.ms-office.activeX"); default: throw new ArgumentOutOfRangeException(nameof(controlType)); } }
/// <summary> /// Adds a EmbeddedControlPersistencePart to the WorksheetPart. /// </summary> /// <param name="partType">The part type of the EmbeddedControlPersistencePart.</param> /// <param name="id">The relationship id.</param> /// <returns>The newly added part.</returns> public EmbeddedControlPersistencePart AddEmbeddedControlPersistencePart(EmbeddedControlPersistencePartType partType, string id) { string contentType = EmbeddedControlPersistencePartTypeInfo.GetContentType(partType); string partExtension = EmbeddedControlPersistencePartTypeInfo.GetTargetExtension(partType); OpenXmlPackage.PartExtensionProvider.MakeSurePartExtensionExist(contentType, partExtension); return AddEmbeddedControlPersistencePart(contentType, id); }
internal static string GetContentType(EmbeddedControlPersistencePartType controlType) => controlType switch {
internal static string GetTargetExtension(EmbeddedControlPersistencePartType controlType) { switch (controlType) { case EmbeddedControlPersistencePartType.ActiveX: return ".xml"; case EmbeddedControlPersistencePartType.ActiveXBin: return ".bin"; default: return ".bin"; } }
internal static string GetContentType(EmbeddedControlPersistencePartType controlType) { switch (controlType) { case EmbeddedControlPersistencePartType.ActiveX: return "application/vnd.ms-office.activeX+xml"; case EmbeddedControlPersistencePartType.ActiveXBin: return "application/vnd.ms-office.activeX"; default: throw new ArgumentOutOfRangeException("controlType"); } }