2022-03-03 08:35:39 +00:00
|
|
|
function parse_xlmeta_xml(data, name, opts) {
|
2022-03-14 06:51:33 +00:00
|
|
|
var out = { Types: [], Cell: [], Value: [] };
|
2022-03-03 08:35:39 +00:00
|
|
|
if (!data)
|
|
|
|
return out;
|
|
|
|
var pass = false;
|
2022-03-14 06:51:33 +00:00
|
|
|
var metatype = "";
|
2022-03-03 08:35:39 +00:00
|
|
|
data.replace(tagregex, function(x, idx) {
|
|
|
|
var y = parsexmltag(x);
|
|
|
|
switch (strip_ns(y[0])) {
|
|
|
|
case "<?xml":
|
|
|
|
break;
|
|
|
|
case "<metadata":
|
|
|
|
case "</metadata>":
|
|
|
|
break;
|
|
|
|
case "<metadataTypes":
|
|
|
|
case "</metadataTypes>":
|
|
|
|
break;
|
|
|
|
case "<metadataType":
|
|
|
|
out.Types.push({ name: y.name });
|
|
|
|
break;
|
2022-03-14 06:51:33 +00:00
|
|
|
case "</metadataType>":
|
|
|
|
break;
|
2022-03-03 08:35:39 +00:00
|
|
|
case "<futureMetadata":
|
|
|
|
break;
|
|
|
|
case "</futureMetadata>":
|
|
|
|
break;
|
|
|
|
case "<bk>":
|
|
|
|
break;
|
|
|
|
case "</bk>":
|
|
|
|
break;
|
|
|
|
case "<rc":
|
2022-03-14 06:51:33 +00:00
|
|
|
if (metatype == "cell")
|
|
|
|
out.Cell.push({ type: out.Types[y.t - 1].name, index: +y.v });
|
|
|
|
else if (metatype == "value")
|
|
|
|
out.Value.push({ type: out.Types[y.t - 1].name, index: +y.v });
|
2022-03-03 08:35:39 +00:00
|
|
|
break;
|
|
|
|
case "</rc>":
|
|
|
|
break;
|
|
|
|
case "<cellMetadata":
|
2022-03-14 06:51:33 +00:00
|
|
|
metatype = "cell";
|
|
|
|
break;
|
2022-03-03 08:35:39 +00:00
|
|
|
case "</cellMetadata>":
|
2022-03-14 06:51:33 +00:00
|
|
|
metatype = "";
|
2022-03-03 08:35:39 +00:00
|
|
|
break;
|
|
|
|
case "<valueMetadata":
|
2022-03-14 06:51:33 +00:00
|
|
|
metatype = "value";
|
2022-03-03 08:35:39 +00:00
|
|
|
break;
|
|
|
|
case "</valueMetadata>":
|
2022-03-14 06:51:33 +00:00
|
|
|
metatype = "";
|
2022-03-03 08:35:39 +00:00
|
|
|
break;
|
|
|
|
case "<extLst":
|
|
|
|
case "<extLst>":
|
|
|
|
case "</extLst>":
|
|
|
|
case "<extLst/>":
|
|
|
|
break;
|
|
|
|
case "<ext":
|
|
|
|
pass = true;
|
|
|
|
break;
|
|
|
|
case "</ext>":
|
|
|
|
pass = false;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
if (!pass && opts.WTF)
|
|
|
|
throw new Error("unrecognized " + y[0] + " in metadata");
|
|
|
|
}
|
|
|
|
return x;
|
|
|
|
});
|
|
|
|
return out;
|
|
|
|
}
|
|
|
|
function write_xlmeta_xml() {
|
|
|
|
var o = [XML_HEADER];
|
|
|
|
o.push('<metadata xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:xlrd="http://schemas.microsoft.com/office/spreadsheetml/2017/richdata" xmlns:xda="http://schemas.microsoft.com/office/spreadsheetml/2017/dynamicarray">\n <metadataTypes count="1">\n <metadataType name="XLDAPR" minSupportedVersion="120000" copy="1" pasteAll="1" pasteValues="1" merge="1" splitFirst="1" rowColShift="1" clearFormats="1" clearComments="1" assign="1" coerce="1" cellMeta="1"/>\n </metadataTypes>\n <futureMetadata name="XLDAPR" count="1">\n <bk>\n <extLst>\n <ext uri="{bdbb8cdc-fa1e-496e-a857-3c3f30c029c3}">\n <xda:dynamicArrayProperties fDynamic="1" fCollapsed="0"/>\n </ext>\n </extLst>\n </bk>\n </futureMetadata>\n <cellMetadata count="1">\n <bk>\n <rc t="1" v="0"/>\n </bk>\n </cellMetadata>\n</metadata>');
|
|
|
|
return o.join("");
|
|
|
|
}
|