xlnt - community edition
Public Member Functions | Friends | List of all members
xlnt::format Class Reference

Describes the formatting of a particular cell. More...

#include <format.hpp>

Public Member Functions

class alignment alignment () const
 Returns a copy of the alignment of this format. If no alignment has been set (has_alignment() returns false), a default-constructed alignment will be returned. More...
 
formatalignment (const xlnt::alignment &new_alignment, xlnt::optional< bool > applied={})
 Sets the alignment of this format to new_alignment. Applied, which defaults to true, determines whether the alignment should be enabled for cells using this format. Returns a wrapper pointing to this format. More...
 
bool has_alignment () const
 Returns true if an alignment has been set for this format. More...
 
bool alignment_applied () const
 Returns true if the alignment of this format should be applied to cells using it. More...
 
class border border () const
 Returns a copy of the border of this format. If no border has been set (has_border() returns false), a default-constructed border will be returned. More...
 
formatborder (const xlnt::border &new_border, xlnt::optional< bool > applied={})
 Sets the border of this format to new_border. Applied, which defaults to true, determines whether the border should be enabled for cells using this format. Returns a wrapper pointing to this format. More...
 
bool has_border () const
 Returns true if a border has been set for this format. More...
 
bool border_applied () const
 Returns true if the border set for this format should be applied to cells using the format. More...
 
class fill fill () const
 Returns a copy of the fill of this format. If no fill has been set (has_fill() returns false), a default-constructed fill will be returned. More...
 
formatfill (const xlnt::fill &new_fill, xlnt::optional< bool > applied={})
 Sets the fill of this format to new_fill. Applied, which defaults to true, determines whether the border should be enabled for cells using this format. Returns a wrapper pointing to this format. More...
 
bool has_fill () const
 Returns true if a fill has been set for this format. More...
 
bool fill_applied () const
 Returns true if the fill set for this format should be applied to cells using the format. More...
 
class font font () const
 Returns a copy of the font of this format. If no font has been set (has_font() returns false), a default-constructed font will be returned. More...
 
formatfont (const xlnt::font &new_font, xlnt::optional< bool > applied={})
 Sets the font of this format to new_font. Applied, which defaults to true, determines whether the font should be enabled for cells using this format. Returns a wrapper pointing to this format. More...
 
bool has_font () const
 Returns true if a font has been set for this format. More...
 
bool font_applied () const
 Returns true if the font set for this format should be applied to cells using the format. More...
 
class number_format number_format () const
 Returns a copy of the number format of this format. If no number format has been set (has_number_format() returns false), a default-constructed number format will be returned. More...
 
formatnumber_format (const xlnt::number_format &new_number_format, xlnt::optional< bool > applied={})
 Sets the number format of this format to new_number_format. Applied, which defaults to true, determines whether the number format should be enabled for cells using this format. Returns a wrapper pointing to this format. More...
 
bool has_number_format () const
 Returns true if a number format has been set for this format. More...
 
bool number_format_applied () const
 Returns true if the number_format set for this format should be applied to cells using the format. More...
 
class protection protection () const
 Returns a copy of the protection of this format. If no protection has been set (has_protection() returns false), a default-constructed protection will be returned. More...
 
bool has_protection () const
 Returns true if protection has been set for this format. More...
 
bool protection_applied () const
 Returns true if the protection set for this format should be applied to cells using the format. More...
 
formatprotection (const xlnt::protection &new_protection, xlnt::optional< bool > applied={})
 Sets the protection of this format to new_protection. Applied, which defaults to true, determines whether the protection should be enabled for cells using this format. Returns a wrapper pointing to this format. More...
 
bool pivot_button () const
 Returns true if the pivot table interface is enabled for this format. More...
 
void pivot_button (bool show)
 If show is true, a pivot table interface will be displayed for cells using this format. More...
 
bool quote_prefix () const
 Returns true if this format should add a single-quote prefix for all text values. More...
 
void quote_prefix (bool quote)
 If quote is true, enables a single-quote prefix for all text values in cells using this format (e.g. "abc" will appear as "'abc"). The text will also not be stored in sharedStrings when this is enabled. More...
 
bool has_style () const
 Returns true if this format has a corresponding style applied. More...
 
void clear_style ()
 Removes the style from this format if it exists. More...
 
formatstyle (const std::string &name)
 Sets the style of this format to a style with the given name. Returns a wrapper pointing to this format. More...
 
formatstyle (const class style &new_style)
 Sets the style of this format to new_style. Returns a wrapper pointing to this format. More...
 
class style style ()
 Returns a wrapper pointing to the style of this format. Assumes that the style exists (please call has_style() to check). If this format has no style, an invalid_attribute exception will be thrown. More...
 
const class style style () const
 Returns a wrapper pointing to the style of this format. Assumes that the style exists (please call has_style() to check). If this format has no style, an invalid_attribute exception will be thrown. More...
 

Friends

struct detail::stylesheet
 
class detail::xlsx_producer
 
class detail::xlsx_consumer
 
class cell
 
class workbook
 

Detailed Description

Describes the formatting of a particular cell.

Member Function Documentation

◆ alignment() [1/2]

format& xlnt::format::alignment ( const xlnt::alignment new_alignment,
xlnt::optional< bool >  applied = {} 
)

Sets the alignment of this format to new_alignment. Applied, which defaults to true, determines whether the alignment should be enabled for cells using this format. Returns a wrapper pointing to this format.

◆ alignment() [2/2]

class alignment xlnt::format::alignment ( ) const

Returns a copy of the alignment of this format. If no alignment has been set (has_alignment() returns false), a default-constructed alignment will be returned.

◆ alignment_applied()

bool xlnt::format::alignment_applied ( ) const

Returns true if the alignment of this format should be applied to cells using it.

◆ border() [1/2]

class border xlnt::format::border ( ) const

Returns a copy of the border of this format. If no border has been set (has_border() returns false), a default-constructed border will be returned.

◆ border() [2/2]

format& xlnt::format::border ( const xlnt::border new_border,
xlnt::optional< bool >  applied = {} 
)

Sets the border of this format to new_border. Applied, which defaults to true, determines whether the border should be enabled for cells using this format. Returns a wrapper pointing to this format.

◆ border_applied()

bool xlnt::format::border_applied ( ) const

Returns true if the border set for this format should be applied to cells using the format.

◆ clear_style()

void xlnt::format::clear_style ( )

Removes the style from this format if it exists.

◆ fill() [1/2]

class fill xlnt::format::fill ( ) const

Returns a copy of the fill of this format. If no fill has been set (has_fill() returns false), a default-constructed fill will be returned.

◆ fill() [2/2]

format& xlnt::format::fill ( const xlnt::fill new_fill,
xlnt::optional< bool >  applied = {} 
)

Sets the fill of this format to new_fill. Applied, which defaults to true, determines whether the border should be enabled for cells using this format. Returns a wrapper pointing to this format.

◆ fill_applied()

bool xlnt::format::fill_applied ( ) const

Returns true if the fill set for this format should be applied to cells using the format.

◆ font() [1/2]

class font xlnt::format::font ( ) const

Returns a copy of the font of this format. If no font has been set (has_font() returns false), a default-constructed font will be returned.

◆ font() [2/2]

format& xlnt::format::font ( const xlnt::font new_font,
xlnt::optional< bool >  applied = {} 
)

Sets the font of this format to new_font. Applied, which defaults to true, determines whether the font should be enabled for cells using this format. Returns a wrapper pointing to this format.

◆ font_applied()

bool xlnt::format::font_applied ( ) const

Returns true if the font set for this format should be applied to cells using the format.

◆ has_alignment()

bool xlnt::format::has_alignment ( ) const

Returns true if an alignment has been set for this format.

◆ has_border()

bool xlnt::format::has_border ( ) const

Returns true if a border has been set for this format.

◆ has_fill()

bool xlnt::format::has_fill ( ) const

Returns true if a fill has been set for this format.

◆ has_font()

bool xlnt::format::has_font ( ) const

Returns true if a font has been set for this format.

◆ has_number_format()

bool xlnt::format::has_number_format ( ) const

Returns true if a number format has been set for this format.

◆ has_protection()

bool xlnt::format::has_protection ( ) const

Returns true if protection has been set for this format.

◆ has_style()

bool xlnt::format::has_style ( ) const

Returns true if this format has a corresponding style applied.

◆ number_format() [1/2]

class number_format xlnt::format::number_format ( ) const

Returns a copy of the number format of this format. If no number format has been set (has_number_format() returns false), a default-constructed number format will be returned.

◆ number_format() [2/2]

format& xlnt::format::number_format ( const xlnt::number_format new_number_format,
xlnt::optional< bool >  applied = {} 
)

Sets the number format of this format to new_number_format. Applied, which defaults to true, determines whether the number format should be enabled for cells using this format. Returns a wrapper pointing to this format.

◆ number_format_applied()

bool xlnt::format::number_format_applied ( ) const

Returns true if the number_format set for this format should be applied to cells using the format.

◆ pivot_button() [1/2]

bool xlnt::format::pivot_button ( ) const

Returns true if the pivot table interface is enabled for this format.

◆ pivot_button() [2/2]

void xlnt::format::pivot_button ( bool  show)

If show is true, a pivot table interface will be displayed for cells using this format.

◆ protection() [1/2]

class protection xlnt::format::protection ( ) const

Returns a copy of the protection of this format. If no protection has been set (has_protection() returns false), a default-constructed protection will be returned.

◆ protection() [2/2]

format& xlnt::format::protection ( const xlnt::protection new_protection,
xlnt::optional< bool >  applied = {} 
)

Sets the protection of this format to new_protection. Applied, which defaults to true, determines whether the protection should be enabled for cells using this format. Returns a wrapper pointing to this format.

◆ protection_applied()

bool xlnt::format::protection_applied ( ) const

Returns true if the protection set for this format should be applied to cells using the format.

◆ quote_prefix() [1/2]

bool xlnt::format::quote_prefix ( ) const

Returns true if this format should add a single-quote prefix for all text values.

◆ quote_prefix() [2/2]

void xlnt::format::quote_prefix ( bool  quote)

If quote is true, enables a single-quote prefix for all text values in cells using this format (e.g. "abc" will appear as "'abc"). The text will also not be stored in sharedStrings when this is enabled.

◆ style() [1/4]

format& xlnt::format::style ( const std::string &  name)

Sets the style of this format to a style with the given name. Returns a wrapper pointing to this format.

◆ style() [2/4]

format& xlnt::format::style ( const class style new_style)

Sets the style of this format to new_style. Returns a wrapper pointing to this format.

◆ style() [3/4]

class style xlnt::format::style ( )

Returns a wrapper pointing to the style of this format. Assumes that the style exists (please call has_style() to check). If this format has no style, an invalid_attribute exception will be thrown.

◆ style() [4/4]

const class style xlnt::format::style ( ) const

Returns a wrapper pointing to the style of this format. Assumes that the style exists (please call has_style() to check). If this format has no style, an invalid_attribute exception will be thrown.


The documentation for this class was generated from the following file: