mirror of
https://github.com/tfussell/xlnt.git
synced 2024-03-22 13:11:17 +08:00
clean up cell deserialization for #103
This commit is contained in:
parent
7de0b05480
commit
760f95e2df
|
@ -2049,7 +2049,7 @@ void xlsx_consumer::read_worksheet(const std::string &rel_id)
|
||||||
auto cell = ws.cell(cell_reference(parser().attribute("r")));
|
auto cell = ws.cell(cell_reference(parser().attribute("r")));
|
||||||
|
|
||||||
auto has_type = parser().attribute_present("t");
|
auto has_type = parser().attribute_present("t");
|
||||||
auto type = has_type ? parser().attribute("t") : "";
|
auto type = has_type ? parser().attribute("t") : "n";
|
||||||
|
|
||||||
auto has_format = parser().attribute_present("s");
|
auto has_format = parser().attribute_present("s");
|
||||||
auto format_id = static_cast<std::size_t>(has_format ? std::stoull(parser().attribute("s")) : 0LL);
|
auto format_id = static_cast<std::size_t>(has_format ? std::stoull(parser().attribute("s")) : 0LL);
|
||||||
|
@ -2105,30 +2105,30 @@ void xlsx_consumer::read_worksheet(const std::string &rel_id)
|
||||||
cell.formula(formula_value_string);
|
cell.formula(formula_value_string);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (has_type && (type == "inlineStr" || type == "str"))
|
if (has_value)
|
||||||
{
|
{
|
||||||
cell.value(value_string);
|
if (type == "inlineStr" || type == "str")
|
||||||
}
|
|
||||||
else if (has_type && type == "s" && !has_formula)
|
|
||||||
{
|
|
||||||
auto shared_string_index = static_cast<std::size_t>(std::stoull(value_string));
|
|
||||||
auto shared_string = shared_strings.at(shared_string_index);
|
|
||||||
cell.value(shared_string);
|
|
||||||
}
|
|
||||||
else if (has_type && type == "b") // boolean
|
|
||||||
{
|
|
||||||
cell.value(value_string != "0");
|
|
||||||
}
|
|
||||||
else if (has_value && !value_string.empty())
|
|
||||||
{
|
|
||||||
if (!value_string.empty() && value_string[0] == '#')
|
|
||||||
{
|
{
|
||||||
cell.error(value_string);
|
cell.value(value_string);
|
||||||
}
|
}
|
||||||
else
|
else if (type == "s" && !has_formula)
|
||||||
|
{
|
||||||
|
auto shared_string_index = static_cast<std::size_t>(std::stoull(value_string));
|
||||||
|
auto shared_string = shared_strings.at(shared_string_index);
|
||||||
|
cell.value(shared_string);
|
||||||
|
}
|
||||||
|
else if (type == "b") // boolean
|
||||||
|
{
|
||||||
|
cell.value(is_true(value_string));
|
||||||
|
}
|
||||||
|
else if (type == "n") // numeric
|
||||||
{
|
{
|
||||||
cell.value(std::stold(value_string));
|
cell.value(std::stold(value_string));
|
||||||
}
|
}
|
||||||
|
else if (!value_string.empty() && value_string[0] == '#')
|
||||||
|
{
|
||||||
|
cell.error(value_string);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (has_format)
|
if (has_format)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user