void workbook_serializer::read_properties_core(const xml_document &xml) { auto &props = workbook_.get_properties(); auto root_node = xml.get_child("cp:coreProperties"); props.excel_base_date = calendar::windows_1900; if (root_node.has_child("dc:creator")) { props.creator = root_node.get_child("dc:creator").get_text(); } if (root_node.has_child("cp:lastModifiedBy")) { props.last_modified_by = root_node.get_child("cp:lastModifiedBy").get_text(); } if (root_node.has_child("dcterms:created")) { std::string created_string = root_node.get_child("dcterms:created").get_text(); props.created = w3cdtf_to_datetime(created_string); } if (root_node.has_child("dcterms:modified")) { std::string modified_string = root_node.get_child("dcterms:modified").get_text(); props.modified = w3cdtf_to_datetime(modified_string); } }
bool shared_strings_serializer::read_shared_strings(const xml_document &xml, std::vector<std::string> &strings) { strings.clear(); auto root_node = xml.get_child("sst"); auto unique_count = 0; if (root_node.has_attribute("uniqueCount")) { unique_count = std::stoull(root_node.get_attribute("uniqueCount")); } for (const auto &si_node : root_node.get_children()) { if (si_node.get_name() != "si") { continue; } if (si_node.has_child("t")) { strings.push_back(si_node.get_child("t").get_text()); } else if (si_node.has_child("r")) { strings.push_back(si_node.get_child("r").get_child("t").get_text()); } } if (unique_count != strings.size()) { throw std::runtime_error("counts don't match"); } return true; }