Add "bestFit" column attribute serialisation

This commit is contained in:
Crzyrndm 2018-06-24 10:13:27 +12:00
parent 4cfb74443c
commit d81555dbae
3 changed files with 15 additions and 0 deletions

View File

@ -51,6 +51,12 @@ public:
/// </summary> /// </summary>
optional<std::size_t> style; optional<std::size_t> style;
/// <summary>
/// Is this column sized to fit its content as best it can
/// serialise if true
/// </summary>
bool best_fit = false;
/// <summary> /// <summary>
/// If true, this column will be hidden /// If true, this column will be hidden
/// </summary> /// </summary>

View File

@ -588,6 +588,9 @@ std::string xlsx_consumer::read_worksheet_begin(const std::string &rel_id)
? is_true(parser().attribute("customWidth")) : false; ? is_true(parser().attribute("customWidth")) : false;
auto hidden = parser().attribute_present("hidden") auto hidden = parser().attribute_present("hidden")
? is_true(parser().attribute("hidden")) : false; ? is_true(parser().attribute("hidden")) : false;
auto best_fit = parser().attribute_present("bestFit")
? is_true(parser().attribute("bestFit"))
: false;
expect_end_element(qn("spreadsheetml", "col")); expect_end_element(qn("spreadsheetml", "col"));
@ -607,6 +610,7 @@ std::string xlsx_consumer::read_worksheet_begin(const std::string &rel_id)
props.hidden = hidden; props.hidden = hidden;
props.custom_width = custom; props.custom_width = custom;
props.best_fit = best_fit;
ws.add_column_properties(column, props); ws.add_column_properties(column, props);
} }
} }

View File

@ -2362,6 +2362,11 @@ void xlsx_producer::write_worksheet(const relationship &rel)
write_attribute("width", (props.width.get() * 7 + 5) / 7); write_attribute("width", (props.width.get() * 7 + 5) / 7);
} }
if (props.best_fit)
{
write_attribute("bestFit", write_bool(true));
}
if (props.style.is_set()) if (props.style.is_set())
{ {
write_attribute("style", props.style.get()); write_attribute("style", props.style.get());