9using NanoXLSX.Registry;
10using NanoXLSX.Registry.Attributes;
12using NanoXLSX.Utils.Xml;
20 [NanoXlsxPlugIn(PlugInUUID = PlugInUUID.MetadataCoreWriter)]
21 internal class MetadataCoreWriter : IPlugInWriter
23 private XmlElement properties;
29 public Workbook Workbook {
get;
set; }
34 public XmlElement XmlElement {
get => properties; }
41 internal MetadataCoreWriter()
51 public void Init(IBaseWriter baseWriter)
53 this.Workbook = baseWriter.Workbook;
61 properties = XmlElement.CreateElement(
"coreProperties",
"cp");
62 properties.AddNameSpaceAttribute(
"dc",
"xmlns",
"http://purl.org/dc/elements/1.1/");
63 properties.AddNameSpaceAttribute(
"cp",
"xmlns",
"http://schemas.openxmlformats.org/package/2006/metadata/core-properties");
64 properties.AddNameSpaceAttribute(
"dcterms",
"xmlns",
"http://purl.org/dc/terms/");
65 properties.AddNameSpaceAttribute(
"xsi",
"xmlns",
"http://www.w3.org/2001/XMLSchema-instance");
66 Metadata md = Workbook.WorkbookMetadata;
67 properties.AddChildElementWithValue(
"title", md.Title,
"dc");
68 properties.AddChildElementWithValue(
"subject", md.Subject,
"dc");
69 properties.AddChildElementWithValue(
"creator", md.Creator,
"dc");
70 properties.AddChildElementWithValue(
"lastModifiedBy", md.Creator,
"cp");
71 properties.AddChildElementWithValue(
"keywords", md.Keywords,
"cp");
72 properties.AddChildElementWithValue(
"description", md.Description,
"dc");
73 string time = DateTime.Now.ToString(
"yyyy-MM-ddThh:mm:ssZ", ParserUtils.InvariantCulture);
74 XmlElement child1 = properties.AddChildElementWithValue(
"created", time,
"dcterms");
75 child1.AddAttribute(
"type",
"dcterms:W3CDTF",
"xsi");
76 XmlElement child2 = properties.AddChildElementWithValue(
"modified", time,
"dcterms");
77 child2.AddAttribute(
"type",
"dcterms:W3CDTF",
"xsi");
78 properties.AddChildElementWithValue(
"category", md.Category,
"cp");
79 properties.AddChildElementWithValue(
"contentStatus", md.ContentStatus,
"cp");
81 WriterPlugInHandler.HandleInlineQueuePlugins(ref properties, Workbook, PlugInUUID.MetadataCoreInlineWriter);