xlnt
Public Member Functions | Static Public Member Functions | List of all members
xlnt::number_format Class Reference

Describes the number formatting applied to text and numbers within a certain cell. More...

#include <number_format.hpp>

Public Member Functions

 number_format ()
 Constructs a default number_format equivalent to "General" More...
 
 number_format (std::size_t builtin_id)
 Constructs a number format equivalent to that returned from number_format::from_builtin_id(builtin_id). More...
 
 number_format (const std::string &code)
 Constructs a number format from a code string. If the string matches a builtin ID, its ID will also be set to match the builtin ID. More...
 
 number_format (const std::string &code, std::size_t custom_id)
 Constructs a number format from a code string and custom ID. Custom ID should generally be >= 164. More...
 
void format_string (const std::string &format_code)
 Sets the format code of this number format to format_code. More...
 
void format_string (const std::string &format_code, std::size_t custom_id)
 Sets the format code of this number format to format_code and the ID to custom_id. More...
 
std::string format_string () const
 Returns the format code this number format uses. More...
 
bool has_id () const
 Returns true if this number format has an ID. More...
 
void id (std::size_t id)
 Sets the ID of this number format to id. More...
 
std::size_t id () const
 Returns the ID of this format. More...
 
std::string format (const std::string &text) const
 Returns text formatted according to this number format's format code. More...
 
std::string format (double number, calendar base_date) const
 Returns number formatted according to this number format's format code with the given base date. More...
 
bool is_date_format () const
 Returns true if this format code returns a number formatted as a date. More...
 
bool operator== (const number_format &other) const
 Returns true if this format is equivalent to other. More...
 
bool operator!= (const number_format &other) const
 Returns true if this format is not equivalent to other. More...
 

Static Public Member Functions

static const number_format general ()
 Number format "General" More...
 
static const number_format text ()
 Number format "@" More...
 
static const number_format number ()
 Number format "0" More...
 
static const number_format number_00 ()
 Number format "00" More...
 
static const number_format number_comma_separated1 ()
 Number format "#,##0.00" More...
 
static const number_format percentage ()
 Number format "0%" More...
 
static const number_format percentage_00 ()
 Number format "0.00%" More...
 
static const number_format date_yyyymmdd2 ()
 Number format "yyyy-mm-dd" More...
 
static const number_format date_yymmdd ()
 Number format "yy-mm-dd" More...
 
static const number_format date_ddmmyyyy ()
 Number format "dd/mm/yy" More...
 
static const number_format date_dmyslash ()
 Number format "d/m/yy" More...
 
static const number_format date_dmyminus ()
 Number format "d-m-yy" More...
 
static const number_format date_dmminus ()
 Number format "d-m" More...
 
static const number_format date_myminus ()
 Number format "m-yy" More...
 
static const number_format date_xlsx14 ()
 Number format "mm-dd-yy" More...
 
static const number_format date_xlsx15 ()
 Number format "d-mmm-yy" More...
 
static const number_format date_xlsx16 ()
 Number format "d-mmm" More...
 
static const number_format date_xlsx17 ()
 Number format "mmm-yy" More...
 
static const number_format date_xlsx22 ()
 Number format "m/d/yy h:mm" More...
 
static const number_format date_datetime ()
 Number format "yyyy-mm-dd h:mm:ss" More...
 
static const number_format date_time1 ()
 Number format "h:mm AM/PM" More...
 
static const number_format date_time2 ()
 Number format "h:mm:ss AM/PM" More...
 
static const number_format date_time3 ()
 Number format "h:mm" More...
 
static const number_format date_time4 ()
 Number format "h:mm:ss" More...
 
static const number_format date_time5 ()
 Number format "mm:ss" More...
 
static const number_format date_time6 ()
 Number format "h:mm:ss" More...
 
static bool is_builtin_format (std::size_t builtin_id)
 Returns true if the given format ID corresponds to a known builtin format. More...
 
static const number_formatfrom_builtin_id (std::size_t builtin_id)
 Returns the format with the given ID. Thows an invalid_parameter exception if builtin_id is not a valid ID. More...
 

Detailed Description

Describes the number formatting applied to text and numbers within a certain cell.

Constructor & Destructor Documentation

◆ number_format() [1/4]

xlnt::number_format::number_format ( )

Constructs a default number_format equivalent to "General"

◆ number_format() [2/4]

xlnt::number_format::number_format ( std::size_t  builtin_id)

Constructs a number format equivalent to that returned from number_format::from_builtin_id(builtin_id).

◆ number_format() [3/4]

xlnt::number_format::number_format ( const std::string &  code)

Constructs a number format from a code string. If the string matches a builtin ID, its ID will also be set to match the builtin ID.

◆ number_format() [4/4]

xlnt::number_format::number_format ( const std::string &  code,
std::size_t  custom_id 
)

Constructs a number format from a code string and custom ID. Custom ID should generally be >= 164.

Member Function Documentation

◆ date_datetime()

static const number_format xlnt::number_format::date_datetime ( )
static

Number format "yyyy-mm-dd h:mm:ss"

◆ date_ddmmyyyy()

static const number_format xlnt::number_format::date_ddmmyyyy ( )
static

Number format "dd/mm/yy"

◆ date_dmminus()

static const number_format xlnt::number_format::date_dmminus ( )
static

Number format "d-m"

◆ date_dmyminus()

static const number_format xlnt::number_format::date_dmyminus ( )
static

Number format "d-m-yy"

◆ date_dmyslash()

static const number_format xlnt::number_format::date_dmyslash ( )
static

Number format "d/m/yy"

◆ date_myminus()

static const number_format xlnt::number_format::date_myminus ( )
static

Number format "m-yy"

◆ date_time1()

static const number_format xlnt::number_format::date_time1 ( )
static

Number format "h:mm AM/PM"

◆ date_time2()

static const number_format xlnt::number_format::date_time2 ( )
static

Number format "h:mm:ss AM/PM"

◆ date_time3()

static const number_format xlnt::number_format::date_time3 ( )
static

Number format "h:mm"

◆ date_time4()

static const number_format xlnt::number_format::date_time4 ( )
static

Number format "h:mm:ss"

◆ date_time5()

static const number_format xlnt::number_format::date_time5 ( )
static

Number format "mm:ss"

◆ date_time6()

static const number_format xlnt::number_format::date_time6 ( )
static

Number format "h:mm:ss"

◆ date_xlsx14()

static const number_format xlnt::number_format::date_xlsx14 ( )
static

Number format "mm-dd-yy"

◆ date_xlsx15()

static const number_format xlnt::number_format::date_xlsx15 ( )
static

Number format "d-mmm-yy"

◆ date_xlsx16()

static const number_format xlnt::number_format::date_xlsx16 ( )
static

Number format "d-mmm"

◆ date_xlsx17()

static const number_format xlnt::number_format::date_xlsx17 ( )
static

Number format "mmm-yy"

◆ date_xlsx22()

static const number_format xlnt::number_format::date_xlsx22 ( )
static

Number format "m/d/yy h:mm"

◆ date_yymmdd()

static const number_format xlnt::number_format::date_yymmdd ( )
static

Number format "yy-mm-dd"

◆ date_yyyymmdd2()

static const number_format xlnt::number_format::date_yyyymmdd2 ( )
static

Number format "yyyy-mm-dd"

◆ format() [1/2]

std::string xlnt::number_format::format ( const std::string &  text) const

Returns text formatted according to this number format's format code.

◆ format() [2/2]

std::string xlnt::number_format::format ( double  number,
calendar  base_date 
) const

Returns number formatted according to this number format's format code with the given base date.

◆ format_string() [1/3]

void xlnt::number_format::format_string ( const std::string &  format_code)

Sets the format code of this number format to format_code.

◆ format_string() [2/3]

void xlnt::number_format::format_string ( const std::string &  format_code,
std::size_t  custom_id 
)

Sets the format code of this number format to format_code and the ID to custom_id.

◆ format_string() [3/3]

std::string xlnt::number_format::format_string ( ) const

Returns the format code this number format uses.

◆ from_builtin_id()

static const number_format& xlnt::number_format::from_builtin_id ( std::size_t  builtin_id)
static

Returns the format with the given ID. Thows an invalid_parameter exception if builtin_id is not a valid ID.

◆ general()

static const number_format xlnt::number_format::general ( )
static

Number format "General"

◆ has_id()

bool xlnt::number_format::has_id ( ) const

Returns true if this number format has an ID.

◆ id() [1/2]

void xlnt::number_format::id ( std::size_t  id)

Sets the ID of this number format to id.

◆ id() [2/2]

std::size_t xlnt::number_format::id ( ) const

Returns the ID of this format.

◆ is_builtin_format()

static bool xlnt::number_format::is_builtin_format ( std::size_t  builtin_id)
static

Returns true if the given format ID corresponds to a known builtin format.

◆ is_date_format()

bool xlnt::number_format::is_date_format ( ) const

Returns true if this format code returns a number formatted as a date.

◆ number()

static const number_format xlnt::number_format::number ( )
static

Number format "0"

◆ number_00()

static const number_format xlnt::number_format::number_00 ( )
static

Number format "00"

◆ number_comma_separated1()

static const number_format xlnt::number_format::number_comma_separated1 ( )
static

Number format "#,##0.00"

◆ operator!=()

bool xlnt::number_format::operator!= ( const number_format other) const

Returns true if this format is not equivalent to other.

◆ operator==()

bool xlnt::number_format::operator== ( const number_format other) const

Returns true if this format is equivalent to other.

◆ percentage()

static const number_format xlnt::number_format::percentage ( )
static

Number format "0%"

◆ percentage_00()

static const number_format xlnt::number_format::percentage_00 ( )
static

Number format "0.00%"

◆ text()

static const number_format xlnt::number_format::text ( )
static

Number format "@"


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