mirror of
https://github.com/tfussell/xlnt.git
synced 2024-03-22 13:11:17 +08:00
30 lines
759 B
C++
30 lines
759 B
C++
#include <xlnt/reader/shared_strings_reader.hpp>
|
|
|
|
#include "detail/include_pugixml.hpp"
|
|
|
|
namespace xlnt {
|
|
|
|
std::vector<std::string> read_shared_strings(const std::string &xml_string)
|
|
{
|
|
std::vector<std::string> shared_strings;
|
|
pugi::xml_document doc;
|
|
doc.load(xml_string.c_str());
|
|
auto root_node = doc.child("sst");
|
|
//int count = root_node.attribute("count").as_int();
|
|
int unique_count = root_node.attribute("uniqueCount").as_int();
|
|
|
|
for(auto si_node : root_node)
|
|
{
|
|
shared_strings.push_back(si_node.child("t").text().as_string());
|
|
}
|
|
|
|
if(unique_count != (int)shared_strings.size())
|
|
{
|
|
throw std::runtime_error("counts don't match");
|
|
}
|
|
|
|
return shared_strings;
|
|
}
|
|
|
|
} // namespace xlnt
|