diff --git a/include/xlnt/styles/fill.hpp b/include/xlnt/styles/fill.hpp index be57b23d..e7af02da 100644 --- a/include/xlnt/styles/fill.hpp +++ b/include/xlnt/styles/fill.hpp @@ -163,6 +163,14 @@ enum class XLNT_API fill_type class XLNT_API fill : public hashable { public: + /// + /// Helper method for the most common use case, setting the fill color of a cell to a single solid color. + /// The foreground and background colors of a fill are not the same as the foreground and background colors + /// of a cell. When setting a fill color in Excel, a new fill is created with the given color as the fill's + /// fgColor and index color number 64 as the bgColor. This method creates a fill in the same way. + /// + static fill solid(const color &fill_color); + /// /// Constructs a fill initialized as a none-type pattern fill with no /// foreground or background colors. diff --git a/source/styles/fill.cpp b/source/styles/fill.cpp index f29ed653..4c6a8595 100644 --- a/source/styles/fill.cpp +++ b/source/styles/fill.cpp @@ -194,6 +194,14 @@ std::unordered_map gradient_fill::stops() const // fill +fill fill::solid(const color &fill_color) +{ + return fill(xlnt::pattern_fill() + .type(xlnt::pattern_fill_type::solid) + .foreground(fill_color) + .background(indexed_color(64))); +} + fill::fill() : type_(fill_type::pattern) { }