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

workbook is the container for all other parts of the document. More...

#include <workbook.hpp>

Public Types

enum  clone_method { deep_copy, shallow_copy }
 The method for cloning workbooks. More...
 
using iterator = worksheet_iterator
 typedef for the iterator used for iterating through this workbook (non-const) in a range-based for loop. More...
 
using const_iterator = const_worksheet_iterator
 typedef for the iterator used for iterating through this workbook (const) in a range-based for loop. More...
 
using reverse_iterator = std::reverse_iterator< iterator >
 typedef for the iterator used for iterating through this workbook (non-const) in a range-based for loop in reverse order using std::make_reverse_iterator. More...
 
using const_reverse_iterator = std::reverse_iterator< const_iterator >
 typedef for the iterator used for iterating through this workbook (const) in a range-based for loop in reverse order using std::make_reverse_iterator. More...
 

Public Member Functions

 workbook ()
 Default constructor. Constructs a workbook containing a single empty worksheet using workbook::empty(). More...
 
 workbook (const xlnt::path &file)
 load the xlsx file at path More...
 
 workbook (const xlnt::path &file, const std::string &password)
 load the encrpyted xlsx file at path More...
 
 workbook (std::istream &data)
 construct the workbook from any data stream where the data is the binary form of a workbook More...
 
 workbook (std::istream &data, const std::string &password)
 construct the workbook from any data stream where the data is the binary form of an encrypted workbook More...
 
 workbook (workbook &&other)=default
 Move constructor. Constructs a workbook from existing workbook, other. More...
 
 workbook (const workbook &other)=default
 Copy constructor. Constructs this workbook from existing workbook, other. Creates a shallow copy, copying the workbook's internal pointers. More...
 
 ~workbook ()=default
 Destroys this workbook, deallocating all internal storage space. Any pimpl wrapper classes (e.g. cell) pointing into this workbook will be invalid after this is executed. More...
 
workbook clone (clone_method method) const
 Creates a clone of this workbook. A shallow copy will copy the workbook's internal pointers, while a deep copy will copy all the internal structures and create a full clone of the workbook. More...
 
worksheet create_sheet ()
 Creates a sheet after the last sheet in this workbook and returns a wrapper pointing to it. More...
 
worksheet create_sheet (std::size_t index)
 Creates a sheet at the specified index and returns a wrapper pointing to it. More...
 
worksheet create_sheet_with_rel (const std::string &title, const relationship &rel)
 Creates a sheet wit the specified title and relationship and returns a wrapper pointing to it. TODO: This should be private... More...
 
worksheet copy_sheet (worksheet worksheet)
 Creates a new sheet after the last sheet initializing it with all of the data from the provided worksheet. Returns a wrapper pointing to the copied sheet. The worksheet to be copied needs to be part of the same workbook (have the same parent) as this workbook - otherwise, an invalid_parameter exception will be thrown. More...
 
worksheet copy_sheet (worksheet worksheet, std::size_t index)
 Creates a new sheet at the specified index initializing it with all of the data from the provided worksheet. Returns a wrapper pointing to the copied sheet. The worksheet to be copied needs to be part of the same workbook (have the same parent) as this workbook - otherwise, an invalid_parameter exception will be thrown. More...
 
worksheet active_sheet ()
 Returns a wrapper pointing to the worksheet that is determined to be active. An active sheet is that which is initially shown by the spreadsheet editor. More...
 
void active_sheet (std::size_t index)
 Sets the worksheet that is determined to be active. An active sheet is that which is initially shown by the spreadsheet editor. More...
 
worksheet sheet_by_title (const std::string &title)
 Returns a wrapper pointing to the worksheet with the given name. This will throw a key_not_found exception if the sheet isn't found. Use workbook::contains(const std::string &) to make sure the sheet exists before calling this method. More...
 
const worksheet sheet_by_title (const std::string &title) const
 Returns a wrapper pointing to the worksheet with the given name. This will throw a key_not_found exception if the sheet isn't found. Use workbook::contains(const std::string &) to make sure the sheet exists before calling this method. More...
 
worksheet sheet_by_index (std::size_t index)
 Returns a wrapper pointing to the worksheet at the given index. Assumes that the index is valid (please call sheet_count() to check). This method will throw an invalid_parameter exception if index is greater than or equal to the number of sheets in this workbook. More...
 
const worksheet sheet_by_index (std::size_t index) const
 Returns a wrapper pointing to the worksheet at the given index. Assumes that the index is valid (please call sheet_count() to check). This method will throw an invalid_parameter exception if index is greater than or equal to the number of sheets in this workbook. More...
 
bool has_sheet_id (std::size_t id) const
 Returns whether this workbook has a sheet with the specified ID. Most users won't need this. More...
 
worksheet sheet_by_id (std::size_t id)
 Returns a wrapper pointing to the worksheet with a sheetId of id. Sheet IDs are arbitrary numbers that uniquely identify a sheet. Assumes that the ID is valid (please call has_sheet_id() to check). If the ID is invalid, a key_not_found exception will be thrown. Most users won't need this. More...
 
const worksheet sheet_by_id (std::size_t id) const
 Returns a wrapper pointing to the worksheet with a sheetId of id. Sheet IDs are arbitrary numbers that uniquely identify a sheet. Assumes that the ID is valid (please call has_sheet_id() to check). If the ID is invalid, a key_not_found exception will be thrown. Most users won't need this. More...
 
bool sheet_hidden_by_index (std::size_t index) const
 Returns the hidden identifier of the worksheet at the given index. Assumes that the index is valid (please call sheet_count() to check). This will throw an invalid_parameter exception if index is greater than or equal to the number of sheets in this workbook. More...
 
bool contains (const std::string &title) const
 Returns true if this workbook contains a sheet with the given title. More...
 
std::size_t index (worksheet worksheet) const
 Returns the index of the given worksheet. The worksheet must be owned by this workbook. If the worksheet is not owned by this workbook, an invalid_parameter exception will be thrown. More...
 
void move_sheet (worksheet worksheet, std::size_t newIndex)
 Moves a sheet to a new position defined. The worksheet must be owned by this workbook. Assumes that the index is valid (please call sheet_count() to check). This method will throw an invalid_parameter exception if index is greater than or equal to the number of sheets in this workbook, or if the worksheet is not part of (not owned by) this workbook. More...
 
void remove_sheet (worksheet worksheet)
 Removes the given worksheet from this workbook. The worksheet must be owned by this workbook. If the worksheet is not part of (not owned by) this workbook, an invalid_parameter exception will be thrown. More...
 
void clear ()
 Sets the contents of this workbook to be equivalent to that of a workbook returned by workbook::empty(). More...
 
iterator begin ()
 Returns an iterator to the first worksheet in this workbook. More...
 
iterator end ()
 Returns an iterator to the worksheet following the last worksheet of the workbook. This worksheet acts as a placeholder; attempting to access it will cause an xlnt::invalid_parameter exception to be thrown. More...
 
const_iterator begin () const
 Returns a const iterator to the first worksheet in this workbook. More...
 
const_iterator end () const
 Returns a const iterator to the worksheet following the last worksheet of the workbook. This worksheet acts as a placeholder; attempting to access it will cause an xlnt::invalid_parameter exception to be thrown. More...
 
const_iterator cbegin () const
 Returns an iterator to the first worksheet in this workbook. More...
 
const_iterator cend () const
 Returns a const iterator to the worksheet following the last worksheet of the workbook. This worksheet acts as a placeholder; attempting to access it will cause an xlnt::invalid_parameter exception to be thrown. More...
 
void apply_to_cells (std::function< void(cell)> f)
 Applies the function "f" to every non-empty cell in every worksheet in this workbook. More...
 
std::vector< std::string > sheet_titles () const
 Returns a temporary vector containing the titles of each sheet in the order of the sheets in the workbook. More...
 
std::size_t sheet_count () const
 Returns the number of sheets in this workbook. More...
 
bool has_core_property (xlnt::core_property type) const
 Returns true if the workbook has the core property with the given name. More...
 
std::vector< xlnt::core_propertycore_properties () const
 Returns a vector of the type of each core property that is set to a particular value in this workbook. More...
 
variant core_property (xlnt::core_property type) const
 Returns a copy of the value of the given core property. Assumes that the specified core_property exists (please call has_core_property() to check). If the specified core_property does not exist, a null variant will be returned. More...
 
void core_property (xlnt::core_property type, const variant &value)
 Sets the given core property to the provided value. More...
 
bool has_extended_property (xlnt::extended_property type) const
 Returns true if the workbook has the extended property with the given name. More...
 
std::vector< xlnt::extended_propertyextended_properties () const
 Returns a vector of the type of each extended property that is set to a particular value in this workbook. More...
 
variant extended_property (xlnt::extended_property type) const
 Returns a copy of the value of the given extended property. Assumes that the specified extended_property exists (please call has_extended_property() to check). If the specified extended_property does not exist, a null variant will be returned. More...
 
void extended_property (xlnt::extended_property type, const variant &value)
 Sets the given extended property to the provided value. More...
 
bool has_custom_property (const std::string &property_name) const
 Returns true if the workbook has the custom property with the given name. More...
 
std::vector< std::string > custom_properties () const
 Returns a vector of the name of each custom property that is set to a particular value in this workbook. More...
 
variant custom_property (const std::string &property_name) const
 Returns a copy of the value of the given custom property. Assumes that the specified custom_property exists (please call has_custom_property() to check). If the specified custom_property does not exist, a null variant will be returned. More...
 
void custom_property (const std::string &property_name, const variant &value)
 Creates a new custom property in this workbook and sets it to the provided value. More...
 
calendar base_date () const
 Returns the base date used by this workbook. This will generally be windows_1900 except on Apple based systems when it will default to mac_1904 unless otherwise set via void workbook::base_date(calendar base_date). More...
 
void base_date (calendar base_date)
 Sets the base date style of this workbook. This is the date and time that a numeric value of 0 represents. More...
 
bool has_title () const
 Returns true if this workbook has had its title set. More...
 
std::string title () const
 Returns the title of this workbook. Assumes that this workbook has a title (please call has_title() to check). If this workbook has no title, an invalid_attribute exception will be thrown. More...
 
void title (const std::string &title)
 Sets the title of this workbook to title. More...
 
void abs_path (const std::string &path)
 Sets the absolute path of this workbook to path. More...
 
void arch_id_flags (const std::size_t flags)
 Sets the ArchID flags of this workbook to flags. More...
 
std::vector< xlnt::named_rangenamed_ranges () const
 Returns a vector of the named ranges in this workbook. More...
 
void create_named_range (const std::string &name, worksheet worksheet, const range_reference &reference)
 Creates a new names range. More...
 
void create_named_range (const std::string &name, worksheet worksheet, const std::string &reference_string)
 Creates a new named range. More...
 
bool has_named_range (const std::string &name) const
 Returns true if a named range of the given name exists in the workbook. More...
 
class range named_range (const std::string &name)
 Returns the named range with the given name. Assumes that the specified named_range exists (please call has_named_range() to check). If the specified named_range does not exist, an xlnt::key_not_found exception will be thrown. More...
 
void remove_named_range (const std::string &name)
 Deletes the named range with the given name. Assumes that the specified named_range exists (please call has_named_range() to check). If the specified named_range does not exist, an xlnt::key_not_found exception will be thrown. More...
 
void save (std::vector< std::uint8_t > &data) const
 Serializes the workbook into an XLSX file and saves the bytes into byte vector data. More...
 
void save (std::vector< std::uint8_t > &data, const std::string &password) const
 Serializes the workbook into an XLSX file encrypted with the given password and saves the bytes into byte vector data. More...
 
void save (const std::string &filename) const
 Serializes the workbook into an XLSX file and saves the data into a file named filename. More...
 
void save (const std::string &filename, const std::string &password) const
 Serializes the workbook into an XLSX file encrypted with the given password and loads the bytes into a file named filename. More...
 
void save (const xlnt::path &filename) const
 Serializes the workbook into an XLSX file and saves the data into a file named filename. More...
 
void save (const xlnt::path &filename, const std::string &password) const
 Serializes the workbook into an XLSX file encrypted with the given password and loads the bytes into a file named filename. More...
 
void save (std::ostream &stream) const
 Serializes the workbook into an XLSX file and saves the data into stream. More...
 
void save (std::ostream &stream, const std::string &password) const
 Serializes the workbook into an XLSX file encrypted with the given password and loads the bytes into the given stream. More...
 
void load (const std::vector< std::uint8_t > &data)
 Interprets byte vector data as an XLSX file and sets the content of this workbook to match that file. If the workbook requires a password (which is not provided), an xlnt::invalid_password will be thrown. If the file is empty/malformed, an xlnt::invalid_file exception will be thrown. If the file is valid but uses features not yet supported by XLNT which cannot be ignored/skipped, an xlnt::unsupported exception will be thrown. More...
 
void load (const std::vector< std::uint8_t > &data, const std::string &password)
 Interprets byte vector data as an XLSX file encrypted with the given password and sets the content of this workbook to match that file. If the specified password is invalid, an xlnt::invalid_password will be thrown. If the file is empty/malformed, an xlnt::invalid_file exception will be thrown. If the file is valid but uses features not yet supported by XLNT which cannot be ignored/skipped, an xlnt::unsupported exception will be thrown. More...
 
void load (const std::string &filename)
 Interprets file with the given filename as an XLSX file and sets the content of this workbook to match that file. If the file does not exist at the specified path, or is empty/malformed, an xlnt::invalid_file exception will be thrown. If the file is valid but uses features not yet supported by XLNT which cannot be ignored/skipped, an xlnt::unsupported exception will be thrown. If the workbook requires a password (which is not provided), an xlnt::invalid_password will be thrown. More...
 
void load (const std::string &filename, const std::string &password)
 Interprets file with the given filename as an XLSX file encrypted with the given password and sets the content of this workbook to match that file. If the file does not exist at the specified path, or is empty/malformed, an xlnt::invalid_file exception will be thrown. If the file is valid but uses features not yet supported by XLNT which cannot be ignored/skipped, an xlnt::unsupported exception will be thrown. If the specified password is invalid, an xlnt::invalid_password will be thrown. More...
 
void load (const xlnt::path &filename)
 Interprets file with the given filename as an XLSX file and sets the content of this workbook to match that file. If the file does not exist at the specified path, or is empty/malformed, an xlnt::invalid_file exception will be thrown. If the file is valid but uses features not yet supported by XLNT which cannot be ignored/skipped, an xlnt::unsupported exception will be thrown. If the workbook requires a password (which is not provided), an xlnt::invalid_password will be thrown. More...
 
void load (const xlnt::path &filename, const std::string &password)
 Interprets file with the given filename as an XLSX file encrypted with the given password and sets the content of this workbook to match that file. If the file does not exist at the specified path, or is empty/malformed, an xlnt::invalid_file exception will be thrown. If the file is valid but uses features not yet supported by XLNT which cannot be ignored/skipped, an xlnt::unsupported exception will be thrown. If the specified password is invalid, an xlnt::invalid_password will be thrown. More...
 
void load (std::istream &stream)
 Interprets data in stream as an XLSX file and sets the content of this workbook to match that file. If the workbook requires a password (which is not provided), an xlnt::invalid_password will be thrown. If the file is empty/malformed, an xlnt::invalid_file exception will be thrown. If the file is valid but uses features not yet supported by XLNT which cannot be ignored/skipped, an xlnt::unsupported exception will be thrown. More...
 
void load (std::istream &stream, const std::string &password)
 Interprets data in stream as an XLSX file encrypted with the given password and sets the content of this workbook to match that file. If the specified password is invalid, an xlnt::invalid_password will be thrown. If the file is empty/malformed, an xlnt::invalid_file exception will be thrown. If the file is valid but uses features not yet supported by XLNT which cannot be ignored/skipped, an xlnt::unsupported exception will be thrown. More...
 
bool has_view () const
 Returns true if this workbook has a view. More...
 
workbook_view view () const
 Returns a copy of the view. Assumes that the view exists (please call has_view() to check). If the view does not exist, an xlnt::invalid_attribute exception will be thrown. More...
 
void view (const workbook_view &view)
 Sets the view to view. More...
 
bool has_code_name () const
 Returns true if a code name has been set for this workbook. More...
 
std::string code_name () const
 Returns the code name that was set for this workbook. Assumes that the code_name exists (please call has_code_name() to check). If the code_name does not exist, an xlnt::invalid_attribute exception will be thrown. More...
 
void code_name (const std::string &code_name)
 Sets the code name of this workbook to code_name. More...
 
bool has_file_version () const
 Returns true if this workbook has a file version. More...
 
void clear_file_version ()
 Clears the information contained by the file version (e.g. AppName, LastEdited, LowestEdited, RupBuild). More...
 
bool has_app_name () const
 Returns true if this workbook has a non-empty AppName workbook file property. More...
 
const std::string & app_name () const
 Returns the AppName workbook file property. Assumes that this workbook has an AppName property (please call has_app_name() to check). If this workbook has no AppName property, an empty string will be returned. More...
 
void app_name (const std::string &app_name)
 Sets the AppName workbook file property. Creates the file version information if it does not exist yet. More...
 
bool has_last_edited () const
 Returns true if this workbook has a non-empty LastEdited workbook file property. More...
 
const std::string & last_edited_str () const
 Returns the LastEdited workbook file property, as a string. Assumes that this workbook has a LastEdited property (please call has_last_edited() to check). If this workbook has no LastEdited property, an empty string will be returned. More...
 
std::size_t last_edited () const
 Returns the LastEdited workbook file property, parsed from a string to a size_t. Assumes that this workbook has a LastEdited property (please call has_last_edited() to check). If this workbook has no LastEdited property, an invalid_attribute exception will be thrown. If the LastEdited property cannot be parsed as a size_t, an invalid_attribute exception will be thrown. More...
 
void last_edited (const std::string &last_edited)
 Sets the LastEdited workbook file property, as a string. Creates the file version information if it does not exist yet. More...
 
void last_edited (std::size_t last_edited)
 Sets the LastEdited workbook file property, as a number (internally converted to a string). Creates the file version information if it does not exist yet. More...
 
bool has_lowest_edited () const
 Returns true if this workbook has a non-empty LowestEdited workbook file property. More...
 
const std::string & lowest_edited_str () const
 Returns the LowestEdited workbook file property, as a string. Assumes that this workbook has a LowestEdited property (please call has_lowest_edited() to check). If this workbook has no LowestEdited property, an empty string will be returned. More...
 
std::size_t lowest_edited () const
 Returns the LowestEdited workbook file property, parsed from a string to size_t. Assumes that this workbook has a LowestEdited property (please call has_lowest_edited() to check). If this workbook has no LowestEdited property, an invalid_attribute exception will be thrown. If the LowestEdited property cannot be parsed as a size_t, an invalid_attribute exception will be thrown. More...
 
void lowest_edited (const std::string &lowest_edited)
 Sets the LowestEdited workbook file property, as a string. Creates the file version information if it does not exist yet. More...
 
void lowest_edited (std::size_t lowest_edited)
 Sets the LowestEdited workbook file property, as a number (internally converted to a string). Creates the file version information if it does not exist yet. More...
 
bool has_rup_build () const
 Returns true if this workbook has a non-empty RupBuild workbook file property. More...
 
const std::string & rup_build_str () const
 
std::size_t rup_build () const
 Returns the RupBuild workbook file property, parsed from a string to size_t. Assumes that this workbook has a RupBuild property (please call has_rup_build() to check). If this workbook has no RupBuild property, an invalid_attribute exception will be thrown. If the RupBuild property cannot be parsed as a size_t, an invalid_attribute exception will be thrown. More...
 
void rup_build (const std::string &rup_build)
 Sets the RupBuild workbook file property, as a string. Creates the file version information if it does not exist yet. More...
 
void rup_build (std::size_t rup_build)
 Sets the RupBuild workbook file property, as a number (internally converted to a string). Creates the file version information if it does not exist yet. More...
 
bool has_theme () const
 Returns true if this workbook has a theme defined. More...
 
const xlnt::themetheme () const
 Returns a const reference to this workbook's theme. Assumes that this workbook has a theme (please call has_theme() to check). If this workbook has no theme, an invalid_attribute exception will be thrown. More...
 
void theme (const class theme &value)
 Sets the theme to value. More...
 
xlnt::format format (std::size_t format_index)
 Returns a wrapper pointing to the cell format at the given index. The index is the position of the format in xl/styles.xml. More...
 
const xlnt::format format (std::size_t format_index) const
 Returns the cell format at the given index. The index is the position of the format in xl/styles.xml. More...
 
xlnt::format create_format (bool default_format=false)
 Creates a new format and returns a wrapper pointing to it. More...
 
void clear_formats ()
 Clear all cell-level formatting and formats from the styelsheet. This leaves all other styling in place (e.g. named styles). More...
 
std::size_t format_count () const
 Returns the number of formats in this workbook. More...
 
bool has_style (const std::string &name) const
 Returns true if this workbook has a style with the given name. More...
 
class style style (const std::string &name)
 Returns a wrapper pointing to the named style with the given name. Assumes that this workbook has a style with the given name (please call has_style() to check). If this workbook has no style with the given name, a key_not_found exception will be thrown. More...
 
const class style style (const std::string &name) const
 Returns a wrapper pointing to the named style with the given name. Assumes that this workbook has a style with the given name (please call has_style() to check). If this workbook has no style with the given name, a key_not_found exception will be thrown. More...
 
class style create_style (const std::string &name)
 Creates a new style and returns a wrapper pointing to it. More...
 
class style create_builtin_style (std::size_t builtin_id)
 Creates a new style and returns a wrapper pointing to it. Assumes that the builtin ID exists. If the builtin ID does not exist, an invalid_parameter exception will be thrown. More...
 
void clear_styles ()
 Clear all named styles from cells and remove the styles from from the styelsheet. This leaves all other styling in place (e.g. cell formats). More...
 
void default_slicer_style (const std::string &value)
 Sets the default slicer style to the given value. More...
 
std::string default_slicer_style () const
 Returns the default slicer style. More...
 
void enable_known_fonts ()
 Enables knownFonts in stylesheet. More...
 
void disable_known_fonts ()
 Disables knownFonts in stylesheet. More...
 
bool known_fonts_enabled () const
 Returns true if knownFonts are enabled in the stylesheet. More...
 
class manifestmanifest ()
 Returns a reference to the workbook's internal manifest. More...
 
const class manifestmanifest () const
 Returns a reference to the workbook's internal manifest. More...
 
std::size_t add_shared_string (const rich_text &shared, bool allow_duplicates=false)
 Append a shared string to the shared string collection in this workbook. This should not generally be called unless you know what you're doing. If allow_duplicates is false and the string is already in the collection, it will not be added. Returns the index of the added string. More...
 
const rich_textshared_strings (std::size_t index) const
 Returns a reference to the shared string related to the specified index More...
 
std::vector< rich_text > & shared_strings ()
 Returns a reference to the shared strings being used by cells in this workbook. More...
 
const std::vector< rich_text > & shared_strings () const
 Returns a reference to the shared strings being used by cells in this workbook. More...
 
void thumbnail (const std::vector< std::uint8_t > &thumbnail, const std::string &extension, const std::string &content_type)
 Sets the workbook's thumbnail to the given vector of bytes, thumbnail, with the given extension (e.g. jpg) and content_type (e.g. image/jpeg). More...
 
bool has_thumbnail () const
 Returns true if this workbook has a thumbnail. More...
 
const std::vector< std::uint8_t > & thumbnail () const
 Returns a vector of bytes representing the workbook's thumbnail. Assumes that this workbook has a thumbnail (please call has_thumbnail() to check). If the workbook has no thumbnail, an invalid_attribute exception will be thrown. More...
 
const std::unordered_map< std::string, std::vector< std::uint8_t > > & binaries () const
 Returns stored binary data. More...
 
bool has_calculation_properties () const
 Returns true if this workbook has any calculation properties set. More...
 
void clear_calculation_properties ()
 Clears the calculation properties of this workbook. More...
 
class calculation_properties calculation_properties () const
 Returns the a copy of the calculation properties used in this workbook. Assumes that this workbook has calculation properties (please call has_calculation_properties() to check). If this workbook has no calculation properties, a default-constructed calculation_properties object will be returned. More...
 
void calculation_properties (const class calculation_properties &props)
 Sets the calculation properties of this workbook to props. More...
 
bool compare (const workbook &other, bool compare_by_reference) const
 Returns true if this workbook is equal to other. If compare_by_reference is true, the comparison will only check that both workbook instances point to the same internal workbook. Otherwise, if compare_by_reference is false, all workbook properties except for the abs_path are compared. More...
 
workbookoperator= (const workbook &other)=default
 Set the contents of this workbook to be equal to those of "other". Creates a shallow copy, copying the workbook's internal pointers. More...
 
workbookoperator= (workbook &&other)=default
 Set the contents of this workbook to be equal to those of "other" by consuming (moving) the "other" instance. More...
 
worksheet operator[] (const std::string &name)
 Returns a wrapper pointing to the worksheet with a title of "name". This will throw a key_not_found exception if the sheet isn't found. Use workbook::contains(const std::string &) to make sure the sheet exists before calling this method. More...
 
worksheet operator[] (std::size_t index)
 Returns a wrapper pointing to the worksheet at "index". This method will throw an invalid_parameter exception if index is greater than or equal to the number of sheets in this workbook (call sheet_count() to check). More...
 
bool operator== (const workbook &rhs) const
 Return true if this workbook internal implementation points to the same memory as rhs's. More...
 
bool operator!= (const workbook &rhs) const
 Return true if this workbook internal implementation doesn't point to the same memory as rhs's. More...
 

Static Public Member Functions

static workbook empty ()
 Constructs and returns an empty workbook similar to a default. Excel workbook More...
 

Friends

class cell
 
class streaming_workbook_reader
 
class worksheet
 
class detail::xlsx_consumer
 
class detail::xlsx_producer
 
struct detail::worksheet_impl
 

Detailed Description

workbook is the container for all other parts of the document.

Member Typedef Documentation

◆ const_iterator

typedef for the iterator used for iterating through this workbook (const) in a range-based for loop.

◆ const_reverse_iterator

typedef for the iterator used for iterating through this workbook (const) in a range-based for loop in reverse order using std::make_reverse_iterator.

◆ iterator

typedef for the iterator used for iterating through this workbook (non-const) in a range-based for loop.

◆ reverse_iterator

using xlnt::workbook::reverse_iterator = std::reverse_iterator<iterator>

typedef for the iterator used for iterating through this workbook (non-const) in a range-based for loop in reverse order using std::make_reverse_iterator.

Member Enumeration Documentation

◆ clone_method

The method for cloning workbooks.

Constructor & Destructor Documentation

◆ workbook() [1/7]

xlnt::workbook::workbook ( )

Default constructor. Constructs a workbook containing a single empty worksheet using workbook::empty().

◆ workbook() [2/7]

xlnt::workbook::workbook ( const xlnt::path file)

load the xlsx file at path

◆ workbook() [3/7]

xlnt::workbook::workbook ( const xlnt::path file,
const std::string &  password 
)

load the encrpyted xlsx file at path

◆ workbook() [4/7]

xlnt::workbook::workbook ( std::istream &  data)

construct the workbook from any data stream where the data is the binary form of a workbook

◆ workbook() [5/7]

xlnt::workbook::workbook ( std::istream &  data,
const std::string &  password 
)

construct the workbook from any data stream where the data is the binary form of an encrypted workbook

◆ workbook() [6/7]

xlnt::workbook::workbook ( workbook &&  other)
default

Move constructor. Constructs a workbook from existing workbook, other.

◆ workbook() [7/7]

xlnt::workbook::workbook ( const workbook other)
default

Copy constructor. Constructs this workbook from existing workbook, other. Creates a shallow copy, copying the workbook's internal pointers.

◆ ~workbook()

xlnt::workbook::~workbook ( )
default

Destroys this workbook, deallocating all internal storage space. Any pimpl wrapper classes (e.g. cell) pointing into this workbook will be invalid after this is executed.

Member Function Documentation

◆ abs_path()

void xlnt::workbook::abs_path ( const std::string &  path)

Sets the absolute path of this workbook to path.

◆ active_sheet() [1/2]

worksheet xlnt::workbook::active_sheet ( )

Returns a wrapper pointing to the worksheet that is determined to be active. An active sheet is that which is initially shown by the spreadsheet editor.

◆ active_sheet() [2/2]

void xlnt::workbook::active_sheet ( std::size_t  index)

Sets the worksheet that is determined to be active. An active sheet is that which is initially shown by the spreadsheet editor.

◆ add_shared_string()

std::size_t xlnt::workbook::add_shared_string ( const rich_text shared,
bool  allow_duplicates = false 
)

Append a shared string to the shared string collection in this workbook. This should not generally be called unless you know what you're doing. If allow_duplicates is false and the string is already in the collection, it will not be added. Returns the index of the added string.

◆ app_name() [1/2]

const std::string& xlnt::workbook::app_name ( ) const

Returns the AppName workbook file property. Assumes that this workbook has an AppName property (please call has_app_name() to check). If this workbook has no AppName property, an empty string will be returned.

◆ app_name() [2/2]

void xlnt::workbook::app_name ( const std::string &  app_name)

Sets the AppName workbook file property. Creates the file version information if it does not exist yet.

◆ apply_to_cells()

void xlnt::workbook::apply_to_cells ( std::function< void(cell)>  f)

Applies the function "f" to every non-empty cell in every worksheet in this workbook.

◆ arch_id_flags()

void xlnt::workbook::arch_id_flags ( const std::size_t  flags)

Sets the ArchID flags of this workbook to flags.

◆ base_date() [1/2]

calendar xlnt::workbook::base_date ( ) const

Returns the base date used by this workbook. This will generally be windows_1900 except on Apple based systems when it will default to mac_1904 unless otherwise set via void workbook::base_date(calendar base_date).

◆ base_date() [2/2]

void xlnt::workbook::base_date ( calendar  base_date)

Sets the base date style of this workbook. This is the date and time that a numeric value of 0 represents.

◆ begin() [1/2]

iterator xlnt::workbook::begin ( )

Returns an iterator to the first worksheet in this workbook.

◆ begin() [2/2]

const_iterator xlnt::workbook::begin ( ) const

Returns a const iterator to the first worksheet in this workbook.

◆ binaries()

const std::unordered_map<std::string, std::vector<std::uint8_t> >& xlnt::workbook::binaries ( ) const

Returns stored binary data.

◆ calculation_properties() [1/2]

class calculation_properties xlnt::workbook::calculation_properties ( ) const

Returns the a copy of the calculation properties used in this workbook. Assumes that this workbook has calculation properties (please call has_calculation_properties() to check). If this workbook has no calculation properties, a default-constructed calculation_properties object will be returned.

◆ calculation_properties() [2/2]

void xlnt::workbook::calculation_properties ( const class calculation_properties props)

Sets the calculation properties of this workbook to props.

◆ cbegin()

const_iterator xlnt::workbook::cbegin ( ) const

Returns an iterator to the first worksheet in this workbook.

◆ cend()

const_iterator xlnt::workbook::cend ( ) const

Returns a const iterator to the worksheet following the last worksheet of the workbook. This worksheet acts as a placeholder; attempting to access it will cause an xlnt::invalid_parameter exception to be thrown.

◆ clear()

void xlnt::workbook::clear ( )

Sets the contents of this workbook to be equivalent to that of a workbook returned by workbook::empty().

◆ clear_calculation_properties()

void xlnt::workbook::clear_calculation_properties ( )

Clears the calculation properties of this workbook.

◆ clear_file_version()

void xlnt::workbook::clear_file_version ( )

Clears the information contained by the file version (e.g. AppName, LastEdited, LowestEdited, RupBuild).

◆ clear_formats()

void xlnt::workbook::clear_formats ( )

Clear all cell-level formatting and formats from the styelsheet. This leaves all other styling in place (e.g. named styles).

◆ clear_styles()

void xlnt::workbook::clear_styles ( )

Clear all named styles from cells and remove the styles from from the styelsheet. This leaves all other styling in place (e.g. cell formats).

◆ clone()

workbook xlnt::workbook::clone ( clone_method  method) const

Creates a clone of this workbook. A shallow copy will copy the workbook's internal pointers, while a deep copy will copy all the internal structures and create a full clone of the workbook.

◆ code_name() [1/2]

std::string xlnt::workbook::code_name ( ) const

Returns the code name that was set for this workbook. Assumes that the code_name exists (please call has_code_name() to check). If the code_name does not exist, an xlnt::invalid_attribute exception will be thrown.

◆ code_name() [2/2]

void xlnt::workbook::code_name ( const std::string &  code_name)

Sets the code name of this workbook to code_name.

◆ compare()

bool xlnt::workbook::compare ( const workbook other,
bool  compare_by_reference 
) const

Returns true if this workbook is equal to other. If compare_by_reference is true, the comparison will only check that both workbook instances point to the same internal workbook. Otherwise, if compare_by_reference is false, all workbook properties except for the abs_path are compared.

◆ contains()

bool xlnt::workbook::contains ( const std::string &  title) const

Returns true if this workbook contains a sheet with the given title.

◆ copy_sheet() [1/2]

worksheet xlnt::workbook::copy_sheet ( worksheet  worksheet)

Creates a new sheet after the last sheet initializing it with all of the data from the provided worksheet. Returns a wrapper pointing to the copied sheet. The worksheet to be copied needs to be part of the same workbook (have the same parent) as this workbook - otherwise, an invalid_parameter exception will be thrown.

◆ copy_sheet() [2/2]

worksheet xlnt::workbook::copy_sheet ( worksheet  worksheet,
std::size_t  index 
)

Creates a new sheet at the specified index initializing it with all of the data from the provided worksheet. Returns a wrapper pointing to the copied sheet. The worksheet to be copied needs to be part of the same workbook (have the same parent) as this workbook - otherwise, an invalid_parameter exception will be thrown.

◆ core_properties()

std::vector<xlnt::core_property> xlnt::workbook::core_properties ( ) const

Returns a vector of the type of each core property that is set to a particular value in this workbook.

◆ core_property() [1/2]

variant xlnt::workbook::core_property ( xlnt::core_property  type) const

Returns a copy of the value of the given core property. Assumes that the specified core_property exists (please call has_core_property() to check). If the specified core_property does not exist, a null variant will be returned.

◆ core_property() [2/2]

void xlnt::workbook::core_property ( xlnt::core_property  type,
const variant value 
)

Sets the given core property to the provided value.

◆ create_builtin_style()

class style xlnt::workbook::create_builtin_style ( std::size_t  builtin_id)

Creates a new style and returns a wrapper pointing to it. Assumes that the builtin ID exists. If the builtin ID does not exist, an invalid_parameter exception will be thrown.

◆ create_format()

xlnt::format xlnt::workbook::create_format ( bool  default_format = false)

Creates a new format and returns a wrapper pointing to it.

◆ create_named_range() [1/2]

void xlnt::workbook::create_named_range ( const std::string &  name,
worksheet  worksheet,
const range_reference reference 
)

Creates a new names range.

◆ create_named_range() [2/2]

void xlnt::workbook::create_named_range ( const std::string &  name,
worksheet  worksheet,
const std::string &  reference_string 
)

Creates a new named range.

◆ create_sheet() [1/2]

worksheet xlnt::workbook::create_sheet ( )

Creates a sheet after the last sheet in this workbook and returns a wrapper pointing to it.

◆ create_sheet() [2/2]

worksheet xlnt::workbook::create_sheet ( std::size_t  index)

Creates a sheet at the specified index and returns a wrapper pointing to it.

◆ create_sheet_with_rel()

worksheet xlnt::workbook::create_sheet_with_rel ( const std::string &  title,
const relationship rel 
)

Creates a sheet wit the specified title and relationship and returns a wrapper pointing to it. TODO: This should be private...

◆ create_style()

class style xlnt::workbook::create_style ( const std::string &  name)

Creates a new style and returns a wrapper pointing to it.

◆ custom_properties()

std::vector<std::string> xlnt::workbook::custom_properties ( ) const

Returns a vector of the name of each custom property that is set to a particular value in this workbook.

◆ custom_property() [1/2]

variant xlnt::workbook::custom_property ( const std::string &  property_name) const

Returns a copy of the value of the given custom property. Assumes that the specified custom_property exists (please call has_custom_property() to check). If the specified custom_property does not exist, a null variant will be returned.

◆ custom_property() [2/2]

void xlnt::workbook::custom_property ( const std::string &  property_name,
const variant value 
)

Creates a new custom property in this workbook and sets it to the provided value.

◆ default_slicer_style() [1/2]

void xlnt::workbook::default_slicer_style ( const std::string &  value)

Sets the default slicer style to the given value.

◆ default_slicer_style() [2/2]

std::string xlnt::workbook::default_slicer_style ( ) const

Returns the default slicer style.

◆ disable_known_fonts()

void xlnt::workbook::disable_known_fonts ( )

Disables knownFonts in stylesheet.

◆ empty()

static workbook xlnt::workbook::empty ( )
static

Constructs and returns an empty workbook similar to a default. Excel workbook

◆ enable_known_fonts()

void xlnt::workbook::enable_known_fonts ( )

Enables knownFonts in stylesheet.

◆ end() [1/2]

iterator xlnt::workbook::end ( )

Returns an iterator to the worksheet following the last worksheet of the workbook. This worksheet acts as a placeholder; attempting to access it will cause an xlnt::invalid_parameter exception to be thrown.

◆ end() [2/2]

const_iterator xlnt::workbook::end ( ) const

Returns a const iterator to the worksheet following the last worksheet of the workbook. This worksheet acts as a placeholder; attempting to access it will cause an xlnt::invalid_parameter exception to be thrown.

◆ extended_properties()

std::vector<xlnt::extended_property> xlnt::workbook::extended_properties ( ) const

Returns a vector of the type of each extended property that is set to a particular value in this workbook.

◆ extended_property() [1/2]

variant xlnt::workbook::extended_property ( xlnt::extended_property  type) const

Returns a copy of the value of the given extended property. Assumes that the specified extended_property exists (please call has_extended_property() to check). If the specified extended_property does not exist, a null variant will be returned.

◆ extended_property() [2/2]

void xlnt::workbook::extended_property ( xlnt::extended_property  type,
const variant value 
)

Sets the given extended property to the provided value.

◆ format() [1/2]

xlnt::format xlnt::workbook::format ( std::size_t  format_index)

Returns a wrapper pointing to the cell format at the given index. The index is the position of the format in xl/styles.xml.

◆ format() [2/2]

const xlnt::format xlnt::workbook::format ( std::size_t  format_index) const

Returns the cell format at the given index. The index is the position of the format in xl/styles.xml.

◆ format_count()

std::size_t xlnt::workbook::format_count ( ) const

Returns the number of formats in this workbook.

◆ has_app_name()

bool xlnt::workbook::has_app_name ( ) const

Returns true if this workbook has a non-empty AppName workbook file property.

◆ has_calculation_properties()

bool xlnt::workbook::has_calculation_properties ( ) const

Returns true if this workbook has any calculation properties set.

◆ has_code_name()

bool xlnt::workbook::has_code_name ( ) const

Returns true if a code name has been set for this workbook.

◆ has_core_property()

bool xlnt::workbook::has_core_property ( xlnt::core_property  type) const

Returns true if the workbook has the core property with the given name.

◆ has_custom_property()

bool xlnt::workbook::has_custom_property ( const std::string &  property_name) const

Returns true if the workbook has the custom property with the given name.

◆ has_extended_property()

bool xlnt::workbook::has_extended_property ( xlnt::extended_property  type) const

Returns true if the workbook has the extended property with the given name.

◆ has_file_version()

bool xlnt::workbook::has_file_version ( ) const

Returns true if this workbook has a file version.

◆ has_last_edited()

bool xlnt::workbook::has_last_edited ( ) const

Returns true if this workbook has a non-empty LastEdited workbook file property.

◆ has_lowest_edited()

bool xlnt::workbook::has_lowest_edited ( ) const

Returns true if this workbook has a non-empty LowestEdited workbook file property.

◆ has_named_range()

bool xlnt::workbook::has_named_range ( const std::string &  name) const

Returns true if a named range of the given name exists in the workbook.

◆ has_rup_build()

bool xlnt::workbook::has_rup_build ( ) const

Returns true if this workbook has a non-empty RupBuild workbook file property.

◆ has_sheet_id()

bool xlnt::workbook::has_sheet_id ( std::size_t  id) const

Returns whether this workbook has a sheet with the specified ID. Most users won't need this.

◆ has_style()

bool xlnt::workbook::has_style ( const std::string &  name) const

Returns true if this workbook has a style with the given name.

◆ has_theme()

bool xlnt::workbook::has_theme ( ) const

Returns true if this workbook has a theme defined.

◆ has_thumbnail()

bool xlnt::workbook::has_thumbnail ( ) const

Returns true if this workbook has a thumbnail.

◆ has_title()

bool xlnt::workbook::has_title ( ) const

Returns true if this workbook has had its title set.

◆ has_view()

bool xlnt::workbook::has_view ( ) const

Returns true if this workbook has a view.

◆ index()

std::size_t xlnt::workbook::index ( worksheet  worksheet) const

Returns the index of the given worksheet. The worksheet must be owned by this workbook. If the worksheet is not owned by this workbook, an invalid_parameter exception will be thrown.

◆ known_fonts_enabled()

bool xlnt::workbook::known_fonts_enabled ( ) const

Returns true if knownFonts are enabled in the stylesheet.

◆ last_edited() [1/3]

std::size_t xlnt::workbook::last_edited ( ) const

Returns the LastEdited workbook file property, parsed from a string to a size_t. Assumes that this workbook has a LastEdited property (please call has_last_edited() to check). If this workbook has no LastEdited property, an invalid_attribute exception will be thrown. If the LastEdited property cannot be parsed as a size_t, an invalid_attribute exception will be thrown.

◆ last_edited() [2/3]

void xlnt::workbook::last_edited ( const std::string &  last_edited)

Sets the LastEdited workbook file property, as a string. Creates the file version information if it does not exist yet.

◆ last_edited() [3/3]

void xlnt::workbook::last_edited ( std::size_t  last_edited)

Sets the LastEdited workbook file property, as a number (internally converted to a string). Creates the file version information if it does not exist yet.

◆ last_edited_str()

const std::string& xlnt::workbook::last_edited_str ( ) const

Returns the LastEdited workbook file property, as a string. Assumes that this workbook has a LastEdited property (please call has_last_edited() to check). If this workbook has no LastEdited property, an empty string will be returned.

◆ load() [1/8]

void xlnt::workbook::load ( const std::vector< std::uint8_t > &  data)

Interprets byte vector data as an XLSX file and sets the content of this workbook to match that file. If the workbook requires a password (which is not provided), an xlnt::invalid_password will be thrown. If the file is empty/malformed, an xlnt::invalid_file exception will be thrown. If the file is valid but uses features not yet supported by XLNT which cannot be ignored/skipped, an xlnt::unsupported exception will be thrown.

◆ load() [2/8]

void xlnt::workbook::load ( const std::vector< std::uint8_t > &  data,
const std::string &  password 
)

Interprets byte vector data as an XLSX file encrypted with the given password and sets the content of this workbook to match that file. If the specified password is invalid, an xlnt::invalid_password will be thrown. If the file is empty/malformed, an xlnt::invalid_file exception will be thrown. If the file is valid but uses features not yet supported by XLNT which cannot be ignored/skipped, an xlnt::unsupported exception will be thrown.

◆ load() [3/8]

void xlnt::workbook::load ( const std::string &  filename)

Interprets file with the given filename as an XLSX file and sets the content of this workbook to match that file. If the file does not exist at the specified path, or is empty/malformed, an xlnt::invalid_file exception will be thrown. If the file is valid but uses features not yet supported by XLNT which cannot be ignored/skipped, an xlnt::unsupported exception will be thrown. If the workbook requires a password (which is not provided), an xlnt::invalid_password will be thrown.

◆ load() [4/8]

void xlnt::workbook::load ( const std::string &  filename,
const std::string &  password 
)

Interprets file with the given filename as an XLSX file encrypted with the given password and sets the content of this workbook to match that file. If the file does not exist at the specified path, or is empty/malformed, an xlnt::invalid_file exception will be thrown. If the file is valid but uses features not yet supported by XLNT which cannot be ignored/skipped, an xlnt::unsupported exception will be thrown. If the specified password is invalid, an xlnt::invalid_password will be thrown.

◆ load() [5/8]

void xlnt::workbook::load ( const xlnt::path filename)

Interprets file with the given filename as an XLSX file and sets the content of this workbook to match that file. If the file does not exist at the specified path, or is empty/malformed, an xlnt::invalid_file exception will be thrown. If the file is valid but uses features not yet supported by XLNT which cannot be ignored/skipped, an xlnt::unsupported exception will be thrown. If the workbook requires a password (which is not provided), an xlnt::invalid_password will be thrown.

◆ load() [6/8]

void xlnt::workbook::load ( const xlnt::path filename,
const std::string &  password 
)

Interprets file with the given filename as an XLSX file encrypted with the given password and sets the content of this workbook to match that file. If the file does not exist at the specified path, or is empty/malformed, an xlnt::invalid_file exception will be thrown. If the file is valid but uses features not yet supported by XLNT which cannot be ignored/skipped, an xlnt::unsupported exception will be thrown. If the specified password is invalid, an xlnt::invalid_password will be thrown.

◆ load() [7/8]

void xlnt::workbook::load ( std::istream &  stream)

Interprets data in stream as an XLSX file and sets the content of this workbook to match that file. If the workbook requires a password (which is not provided), an xlnt::invalid_password will be thrown. If the file is empty/malformed, an xlnt::invalid_file exception will be thrown. If the file is valid but uses features not yet supported by XLNT which cannot be ignored/skipped, an xlnt::unsupported exception will be thrown.

◆ load() [8/8]

void xlnt::workbook::load ( std::istream &  stream,
const std::string &  password 
)

Interprets data in stream as an XLSX file encrypted with the given password and sets the content of this workbook to match that file. If the specified password is invalid, an xlnt::invalid_password will be thrown. If the file is empty/malformed, an xlnt::invalid_file exception will be thrown. If the file is valid but uses features not yet supported by XLNT which cannot be ignored/skipped, an xlnt::unsupported exception will be thrown.

◆ lowest_edited() [1/3]

std::size_t xlnt::workbook::lowest_edited ( ) const

Returns the LowestEdited workbook file property, parsed from a string to size_t. Assumes that this workbook has a LowestEdited property (please call has_lowest_edited() to check). If this workbook has no LowestEdited property, an invalid_attribute exception will be thrown. If the LowestEdited property cannot be parsed as a size_t, an invalid_attribute exception will be thrown.

◆ lowest_edited() [2/3]

void xlnt::workbook::lowest_edited ( const std::string &  lowest_edited)

Sets the LowestEdited workbook file property, as a string. Creates the file version information if it does not exist yet.

◆ lowest_edited() [3/3]

void xlnt::workbook::lowest_edited ( std::size_t  lowest_edited)

Sets the LowestEdited workbook file property, as a number (internally converted to a string). Creates the file version information if it does not exist yet.

◆ lowest_edited_str()

const std::string& xlnt::workbook::lowest_edited_str ( ) const

Returns the LowestEdited workbook file property, as a string. Assumes that this workbook has a LowestEdited property (please call has_lowest_edited() to check). If this workbook has no LowestEdited property, an empty string will be returned.

◆ manifest() [1/2]

class manifest& xlnt::workbook::manifest ( )

Returns a reference to the workbook's internal manifest.

◆ manifest() [2/2]

const class manifest& xlnt::workbook::manifest ( ) const

Returns a reference to the workbook's internal manifest.

◆ move_sheet()

void xlnt::workbook::move_sheet ( worksheet  worksheet,
std::size_t  newIndex 
)

Moves a sheet to a new position defined. The worksheet must be owned by this workbook. Assumes that the index is valid (please call sheet_count() to check). This method will throw an invalid_parameter exception if index is greater than or equal to the number of sheets in this workbook, or if the worksheet is not part of (not owned by) this workbook.

◆ named_range()

class range xlnt::workbook::named_range ( const std::string &  name)

Returns the named range with the given name. Assumes that the specified named_range exists (please call has_named_range() to check). If the specified named_range does not exist, an xlnt::key_not_found exception will be thrown.

◆ named_ranges()

std::vector<xlnt::named_range> xlnt::workbook::named_ranges ( ) const

Returns a vector of the named ranges in this workbook.

◆ operator!=()

bool xlnt::workbook::operator!= ( const workbook rhs) const

Return true if this workbook internal implementation doesn't point to the same memory as rhs's.

◆ operator=() [1/2]

workbook& xlnt::workbook::operator= ( const workbook other)
default

Set the contents of this workbook to be equal to those of "other". Creates a shallow copy, copying the workbook's internal pointers.

◆ operator=() [2/2]

workbook& xlnt::workbook::operator= ( workbook &&  other)
default

Set the contents of this workbook to be equal to those of "other" by consuming (moving) the "other" instance.

◆ operator==()

bool xlnt::workbook::operator== ( const workbook rhs) const

Return true if this workbook internal implementation points to the same memory as rhs's.

◆ operator[]() [1/2]

worksheet xlnt::workbook::operator[] ( const std::string &  name)

Returns a wrapper pointing to the worksheet with a title of "name". This will throw a key_not_found exception if the sheet isn't found. Use workbook::contains(const std::string &) to make sure the sheet exists before calling this method.

◆ operator[]() [2/2]

worksheet xlnt::workbook::operator[] ( std::size_t  index)

Returns a wrapper pointing to the worksheet at "index". This method will throw an invalid_parameter exception if index is greater than or equal to the number of sheets in this workbook (call sheet_count() to check).

◆ remove_named_range()

void xlnt::workbook::remove_named_range ( const std::string &  name)

Deletes the named range with the given name. Assumes that the specified named_range exists (please call has_named_range() to check). If the specified named_range does not exist, an xlnt::key_not_found exception will be thrown.

◆ remove_sheet()

void xlnt::workbook::remove_sheet ( worksheet  worksheet)

Removes the given worksheet from this workbook. The worksheet must be owned by this workbook. If the worksheet is not part of (not owned by) this workbook, an invalid_parameter exception will be thrown.

◆ rup_build() [1/3]

std::size_t xlnt::workbook::rup_build ( ) const

Returns the RupBuild workbook file property, parsed from a string to size_t. Assumes that this workbook has a RupBuild property (please call has_rup_build() to check). If this workbook has no RupBuild property, an invalid_attribute exception will be thrown. If the RupBuild property cannot be parsed as a size_t, an invalid_attribute exception will be thrown.

◆ rup_build() [2/3]

void xlnt::workbook::rup_build ( const std::string &  rup_build)

Sets the RupBuild workbook file property, as a string. Creates the file version information if it does not exist yet.

◆ rup_build() [3/3]

void xlnt::workbook::rup_build ( std::size_t  rup_build)

Sets the RupBuild workbook file property, as a number (internally converted to a string). Creates the file version information if it does not exist yet.

◆ rup_build_str()

const std::string& xlnt::workbook::rup_build_str ( ) const

Returns the RupBuild workbook file property, as a string. Assumes that this workbook has a RupBuild property (please call has_rup_build() to check). If this workbook has no RupBuild property, an empty string will be returned.

◆ save() [1/8]

void xlnt::workbook::save ( std::vector< std::uint8_t > &  data) const

Serializes the workbook into an XLSX file and saves the bytes into byte vector data.

◆ save() [2/8]

void xlnt::workbook::save ( std::vector< std::uint8_t > &  data,
const std::string &  password 
) const

Serializes the workbook into an XLSX file encrypted with the given password and saves the bytes into byte vector data.

◆ save() [3/8]

void xlnt::workbook::save ( const std::string &  filename) const

Serializes the workbook into an XLSX file and saves the data into a file named filename.

◆ save() [4/8]

void xlnt::workbook::save ( const std::string &  filename,
const std::string &  password 
) const

Serializes the workbook into an XLSX file encrypted with the given password and loads the bytes into a file named filename.

◆ save() [5/8]

void xlnt::workbook::save ( const xlnt::path filename) const

Serializes the workbook into an XLSX file and saves the data into a file named filename.

◆ save() [6/8]

void xlnt::workbook::save ( const xlnt::path filename,
const std::string &  password 
) const

Serializes the workbook into an XLSX file encrypted with the given password and loads the bytes into a file named filename.

◆ save() [7/8]

void xlnt::workbook::save ( std::ostream &  stream) const

Serializes the workbook into an XLSX file and saves the data into stream.

◆ save() [8/8]

void xlnt::workbook::save ( std::ostream &  stream,
const std::string &  password 
) const

Serializes the workbook into an XLSX file encrypted with the given password and loads the bytes into the given stream.

◆ shared_strings() [1/3]

const rich_text& xlnt::workbook::shared_strings ( std::size_t  index) const

Returns a reference to the shared string related to the specified index

◆ shared_strings() [2/3]

std::vector<rich_text>& xlnt::workbook::shared_strings ( )

Returns a reference to the shared strings being used by cells in this workbook.

◆ shared_strings() [3/3]

const std::vector<rich_text>& xlnt::workbook::shared_strings ( ) const

Returns a reference to the shared strings being used by cells in this workbook.

◆ sheet_by_id() [1/2]

worksheet xlnt::workbook::sheet_by_id ( std::size_t  id)

Returns a wrapper pointing to the worksheet with a sheetId of id. Sheet IDs are arbitrary numbers that uniquely identify a sheet. Assumes that the ID is valid (please call has_sheet_id() to check). If the ID is invalid, a key_not_found exception will be thrown. Most users won't need this.

◆ sheet_by_id() [2/2]

const worksheet xlnt::workbook::sheet_by_id ( std::size_t  id) const

Returns a wrapper pointing to the worksheet with a sheetId of id. Sheet IDs are arbitrary numbers that uniquely identify a sheet. Assumes that the ID is valid (please call has_sheet_id() to check). If the ID is invalid, a key_not_found exception will be thrown. Most users won't need this.

◆ sheet_by_index() [1/2]

worksheet xlnt::workbook::sheet_by_index ( std::size_t  index)

Returns a wrapper pointing to the worksheet at the given index. Assumes that the index is valid (please call sheet_count() to check). This method will throw an invalid_parameter exception if index is greater than or equal to the number of sheets in this workbook.

◆ sheet_by_index() [2/2]

const worksheet xlnt::workbook::sheet_by_index ( std::size_t  index) const

Returns a wrapper pointing to the worksheet at the given index. Assumes that the index is valid (please call sheet_count() to check). This method will throw an invalid_parameter exception if index is greater than or equal to the number of sheets in this workbook.

◆ sheet_by_title() [1/2]

worksheet xlnt::workbook::sheet_by_title ( const std::string &  title)

Returns a wrapper pointing to the worksheet with the given name. This will throw a key_not_found exception if the sheet isn't found. Use workbook::contains(const std::string &) to make sure the sheet exists before calling this method.

◆ sheet_by_title() [2/2]

const worksheet xlnt::workbook::sheet_by_title ( const std::string &  title) const

Returns a wrapper pointing to the worksheet with the given name. This will throw a key_not_found exception if the sheet isn't found. Use workbook::contains(const std::string &) to make sure the sheet exists before calling this method.

◆ sheet_count()

std::size_t xlnt::workbook::sheet_count ( ) const

Returns the number of sheets in this workbook.

◆ sheet_hidden_by_index()

bool xlnt::workbook::sheet_hidden_by_index ( std::size_t  index) const

Returns the hidden identifier of the worksheet at the given index. Assumes that the index is valid (please call sheet_count() to check). This will throw an invalid_parameter exception if index is greater than or equal to the number of sheets in this workbook.

◆ sheet_titles()

std::vector<std::string> xlnt::workbook::sheet_titles ( ) const

Returns a temporary vector containing the titles of each sheet in the order of the sheets in the workbook.

◆ style() [1/2]

class style xlnt::workbook::style ( const std::string &  name)

Returns a wrapper pointing to the named style with the given name. Assumes that this workbook has a style with the given name (please call has_style() to check). If this workbook has no style with the given name, a key_not_found exception will be thrown.

◆ style() [2/2]

const class style xlnt::workbook::style ( const std::string &  name) const

Returns a wrapper pointing to the named style with the given name. Assumes that this workbook has a style with the given name (please call has_style() to check). If this workbook has no style with the given name, a key_not_found exception will be thrown.

◆ theme() [1/2]

const xlnt::theme& xlnt::workbook::theme ( ) const

Returns a const reference to this workbook's theme. Assumes that this workbook has a theme (please call has_theme() to check). If this workbook has no theme, an invalid_attribute exception will be thrown.

◆ theme() [2/2]

void xlnt::workbook::theme ( const class theme value)

Sets the theme to value.

◆ thumbnail() [1/2]

void xlnt::workbook::thumbnail ( const std::vector< std::uint8_t > &  thumbnail,
const std::string &  extension,
const std::string &  content_type 
)

Sets the workbook's thumbnail to the given vector of bytes, thumbnail, with the given extension (e.g. jpg) and content_type (e.g. image/jpeg).

◆ thumbnail() [2/2]

const std::vector<std::uint8_t>& xlnt::workbook::thumbnail ( ) const

Returns a vector of bytes representing the workbook's thumbnail. Assumes that this workbook has a thumbnail (please call has_thumbnail() to check). If the workbook has no thumbnail, an invalid_attribute exception will be thrown.

◆ title() [1/2]

std::string xlnt::workbook::title ( ) const

Returns the title of this workbook. Assumes that this workbook has a title (please call has_title() to check). If this workbook has no title, an invalid_attribute exception will be thrown.

◆ title() [2/2]

void xlnt::workbook::title ( const std::string &  title)

Sets the title of this workbook to title.

◆ view() [1/2]

workbook_view xlnt::workbook::view ( ) const

Returns a copy of the view. Assumes that the view exists (please call has_view() to check). If the view does not exist, an xlnt::invalid_attribute exception will be thrown.

◆ view() [2/2]

void xlnt::workbook::view ( const workbook_view view)

Sets the view to view.


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