diff --git a/source/cell/cell.cpp b/source/cell/cell.cpp index efe01500..0f1ba819 100644 --- a/source/cell/cell.cpp +++ b/source/cell/cell.cpp @@ -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)); } diff --git a/source/detail/implementations/stylesheet.hpp b/source/detail/implementations/stylesheet.hpp index 0ec45161..67ffa063 100644 --- a/source/detail/implementations/stylesheet.hpp +++ b/source/detail/implementations/stylesheet.hpp @@ -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); diff --git a/source/detail/serialization/xlsx_consumer.cpp b/source/detail/serialization/xlsx_consumer.cpp index 3ac9eb0b..9a05603f 100644 --- a/source/detail/serialization/xlsx_consumer.cpp +++ b/source/detail/serialization/xlsx_consumer.cpp @@ -2339,7 +2339,7 @@ void xlsx_consumer::read_stylesheet() } record.first.border_id = parser().attribute_present("borderId") ? parser().attribute("borderId") - : 0; + : optional(); if (parser().attribute_present("applyFill")) { @@ -2347,7 +2347,7 @@ void xlsx_consumer::read_stylesheet() } record.first.fill_id = parser().attribute_present("fillId") ? parser().attribute("fillId") - : 0; + : optional(); if (parser().attribute_present("applyFont")) { @@ -2355,7 +2355,7 @@ void xlsx_consumer::read_stylesheet() } record.first.font_id = parser().attribute_present("fontId") ? parser().attribute("fontId") - : 0; + : optional(); 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("numFmtId") - : 0; + : optional(); auto apply_alignment_present = parser().attribute_present("applyAlignment"); if (apply_alignment_present) diff --git a/tests/data/10_comments_hyperlinks_formulae.xlsx b/tests/data/10_comments_hyperlinks_formulae.xlsx index c989dc5f..142d3d0b 100644 Binary files a/tests/data/10_comments_hyperlinks_formulae.xlsx and b/tests/data/10_comments_hyperlinks_formulae.xlsx differ