Merge pull request #382 from kostasdizas/issue374-format

Update the format elements when setting the cell style
This commit is contained in:
Thomas Fussell 2019-06-22 10:43:41 -04:00 committed by GitHub
commit b1a2f6d0bf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 11 additions and 10 deletions

View File

@ -846,6 +846,12 @@ void cell::clear_style()
void cell::style(const class style &new_style)
{
auto new_format = has_format() ? format() : workbook().create_format();
new_format.border(new_style.border());
new_format.fill(new_style.fill());
new_format.font(new_style.font());
new_format.number_format(new_style.number_format());
format(new_format.style(new_style));
}

View File

@ -51,12 +51,7 @@ struct stylesheet
impl.parent = this;
impl.id = format_impls.size() - 1;
impl.border_id = 0;
impl.fill_id = 0;
impl.font_id = 0;
impl.number_format_id = 0;
impl.references = default_format ? 1 : 0;
return xlnt::format(&impl);

View File

@ -2339,7 +2339,7 @@ void xlsx_consumer::read_stylesheet()
}
record.first.border_id = parser().attribute_present("borderId")
? parser().attribute<std::size_t>("borderId")
: 0;
: optional<std::size_t>();
if (parser().attribute_present("applyFill"))
{
@ -2347,7 +2347,7 @@ void xlsx_consumer::read_stylesheet()
}
record.first.fill_id = parser().attribute_present("fillId")
? parser().attribute<std::size_t>("fillId")
: 0;
: optional<std::size_t>();
if (parser().attribute_present("applyFont"))
{
@ -2355,7 +2355,7 @@ void xlsx_consumer::read_stylesheet()
}
record.first.font_id = parser().attribute_present("fontId")
? parser().attribute<std::size_t>("fontId")
: 0;
: optional<std::size_t>();
if (parser().attribute_present("applyNumberFormat"))
{
@ -2363,7 +2363,7 @@ void xlsx_consumer::read_stylesheet()
}
record.first.number_format_id = parser().attribute_present("numFmtId")
? parser().attribute<std::size_t>("numFmtId")
: 0;
: optional<std::size_t>();
auto apply_alignment_present = parser().attribute_present("applyAlignment");
if (apply_alignment_present)