mirror of
https://github.com/tfussell/xlnt.git
synced 2024-03-22 13:11:17 +08:00
document some things
This commit is contained in:
parent
9907f5a8c8
commit
e14e595b6a
|
@ -90,7 +90,7 @@ generate('doxyxml/', function(err, data) {
|
|||
console.log('###', _.last(class_.name.split('::')));
|
||||
for (var k = 0; k < class_.members.length; k++) {
|
||||
var member = class_.members[k];
|
||||
console.log('####', '```' + member.definition + '```');
|
||||
console.log('####', '```' + member.definition + member.argsstring + '```');
|
||||
if (member.briefdescription) {
|
||||
console.log(member.briefdescription);
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -67,7 +67,8 @@ struct cell_impl;
|
|||
} // namespace detail
|
||||
|
||||
/// <summary>
|
||||
/// Describes cell associated properties.
|
||||
/// Describes a unit of data in a worksheet at a specific coordinate and its
|
||||
/// associated properties.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Properties of interest include style, type, value, and address.
|
||||
|
@ -84,7 +85,7 @@ public:
|
|||
using type = cell_type;
|
||||
|
||||
/// <summary>
|
||||
/// Return a map of error strings such as \#DIV/0! and their associated indices.
|
||||
/// Returns a map of error strings such as \#DIV/0! and their associated indices.
|
||||
/// </summary>
|
||||
static const std::unordered_map<std::string, int> &error_codes();
|
||||
|
||||
|
@ -96,12 +97,12 @@ public:
|
|||
// value
|
||||
|
||||
/// <summary>
|
||||
/// Return true if value has been set and has not been cleared using cell::clear_value().
|
||||
/// Returns true if value has been set and has not been cleared using cell::clear_value().
|
||||
/// </summary>
|
||||
bool has_value() const;
|
||||
|
||||
/// <summary>
|
||||
/// Return the value of this cell as an instance of type T.
|
||||
/// Returns the value of this cell as an instance of type T.
|
||||
/// Overloads exist for most C++ fundamental types like bool, int, etc. as well
|
||||
/// as for std::string and xlnt datetime types: date, time, datetime, and timedelta.
|
||||
/// </summary>
|
||||
|
@ -109,13 +110,13 @@ public:
|
|||
T value() const;
|
||||
|
||||
/// <summary>
|
||||
/// Make this cell have a value of type null.
|
||||
/// Makes this cell have a value of type null.
|
||||
/// All other cell attributes are retained.
|
||||
/// </summary>
|
||||
void clear_value();
|
||||
|
||||
/// <summary>
|
||||
/// Set the value of this cell to the given value.
|
||||
/// Sets the value of this cell to the given value.
|
||||
/// Overloads exist for most C++ fundamental types like bool, int, etc. as well
|
||||
/// as for std::string and xlnt datetime types: date, time, datetime, and timedelta.
|
||||
/// </summary>
|
||||
|
@ -123,18 +124,19 @@ public:
|
|||
void value(T value);
|
||||
|
||||
/// <summary>
|
||||
/// Analyze string_value to determine its type, convert it to that type,
|
||||
/// Analyzes string_value to determine its type, convert it to that type,
|
||||
/// and set the value of this cell to that converted value.
|
||||
/// </summary>
|
||||
void value(const std::string &string_value, bool infer_type);
|
||||
|
||||
/// <summary>
|
||||
/// Return the type of this cell.
|
||||
/// Returns the type of this cell.
|
||||
/// </summary>
|
||||
type data_type() const;
|
||||
|
||||
/// <summary>
|
||||
/// Set the type of this cell.
|
||||
/// Sets the type of this cell. This should usually be done indirectly
|
||||
/// by setting the value of the cell to a value of that type.
|
||||
/// </summary>
|
||||
void data_type(type t);
|
||||
|
||||
|
@ -142,96 +144,108 @@ public:
|
|||
|
||||
/// <summary>
|
||||
/// There's no reason to keep a cell which has no value and is not a placeholder.
|
||||
/// Return true if this cell has no value, style, isn't merged, etc.
|
||||
/// Returns true if this cell has no value, style, isn't merged, etc.
|
||||
/// </summary>
|
||||
bool garbage_collectible() const;
|
||||
|
||||
/// <summary>
|
||||
/// Return true iff this cell's number format matches a date format.
|
||||
/// Returns true iff this cell's number format matches a date format.
|
||||
/// </summary>
|
||||
bool is_date() const;
|
||||
|
||||
// position
|
||||
|
||||
/// <summary>
|
||||
/// Return a cell_reference that points to the location of this cell.
|
||||
/// Returns a cell_reference that points to the location of this cell.
|
||||
/// </summary>
|
||||
cell_reference reference() const;
|
||||
|
||||
/// <summary>
|
||||
/// Return the column of this cell.
|
||||
/// Returns the column of this cell.
|
||||
/// </summary>
|
||||
column_t column() const;
|
||||
|
||||
/// <summary>
|
||||
/// Return the row of this cell.
|
||||
/// Returns the row of this cell.
|
||||
/// </summary>
|
||||
row_t row() const;
|
||||
|
||||
/// <summary>
|
||||
/// Return the location of this cell as an ordered pair.
|
||||
/// Returns the location of this cell as an ordered pair (left, top).
|
||||
/// </summary>
|
||||
std::pair<int, int> anchor() const;
|
||||
|
||||
// hyperlink
|
||||
|
||||
/// <summary>
|
||||
/// Return the URL of this cell's hyperlink.
|
||||
/// Returns the URL of this cell's hyperlink.
|
||||
/// </summary>
|
||||
std::string hyperlink() const;
|
||||
|
||||
/// <summary>
|
||||
/// Add a hyperlink to this cell pointing to the URI of the given value.
|
||||
/// Adds a hyperlink to this cell pointing to the URI of the given value.
|
||||
/// </summary>
|
||||
void hyperlink(const std::string &value);
|
||||
|
||||
/// <summary>
|
||||
/// Return true if this cell has a hyperlink set.
|
||||
/// Returns true if this cell has a hyperlink set.
|
||||
/// </summary>
|
||||
bool has_hyperlink() const;
|
||||
|
||||
// computed formatting
|
||||
|
||||
/// <summary>
|
||||
/// Returns the result of computed_format().alignment().
|
||||
/// Returns the alignment that should be used when displaying this cell
|
||||
/// graphically based on the workbook default, the cell-level format,
|
||||
/// and the named style applied to the cell in that order.
|
||||
/// </summary>
|
||||
class alignment computed_alignment() const;
|
||||
|
||||
/// <summary>
|
||||
/// Returns the result of computed_format().border().
|
||||
/// Returns the border that should be used when displaying this cell
|
||||
/// graphically based on the workbook default, the cell-level format,
|
||||
/// and the named style applied to the cell in that order.
|
||||
/// </summary>
|
||||
class border computed_border() const;
|
||||
|
||||
/// <summary>
|
||||
/// Returns the result of computed_format().fill().
|
||||
/// Returns the fill that should be used when displaying this cell
|
||||
/// graphically based on the workbook default, the cell-level format,
|
||||
/// and the named style applied to the cell in that order.
|
||||
/// </summary>
|
||||
class fill computed_fill() const;
|
||||
|
||||
/// <summary>
|
||||
/// Returns the result of computed_format().font().
|
||||
/// Returns the font that should be used when displaying this cell
|
||||
/// graphically based on the workbook default, the cell-level format,
|
||||
/// and the named style applied to the cell in that order.
|
||||
/// </summary>
|
||||
class font computed_font() const;
|
||||
|
||||
/// <summary>
|
||||
/// Returns the result of computed_format().number_format().
|
||||
/// Returns the number format that should be used when displaying this cell
|
||||
/// graphically based on the workbook default, the cell-level format,
|
||||
/// and the named style applied to the cell in that order.
|
||||
/// </summary>
|
||||
class number_format computed_number_format() const;
|
||||
|
||||
/// <summary>
|
||||
/// Returns the result of computed_format().protection().
|
||||
/// Returns the protection that should be used when displaying this cell
|
||||
/// graphically based on the workbook default, the cell-level format,
|
||||
/// and the named style applied to the cell in that order.
|
||||
/// </summary>
|
||||
class protection computed_protection() const;
|
||||
|
||||
// format
|
||||
|
||||
/// <summary>
|
||||
/// Return true if this cell has had a format applied to it.
|
||||
/// Returns true if this cell has had a format applied to it.
|
||||
/// </summary>
|
||||
bool has_format() const;
|
||||
|
||||
/// <summary>
|
||||
/// Return a reference to the format applied to this cell.
|
||||
/// If this cell has no format, an invalid_attribute exception will be thrown.
|
||||
/// Returns the format applied to this cell. If this cell has no
|
||||
/// format, an invalid_attribute exception will be thrown.
|
||||
/// </summary>
|
||||
const class format format() const;
|
||||
|
||||
|
@ -241,7 +255,7 @@ public:
|
|||
void format(const class format new_format);
|
||||
|
||||
/// <summary>
|
||||
/// Remove the cell-level formatting from this cell.
|
||||
/// Removes the cell-level formatting from this cell.
|
||||
/// This doesn't affect the style that may also be applied to the cell.
|
||||
/// Throws an invalid_attribute exception if no format is applied.
|
||||
/// </summary>
|
||||
|
@ -326,7 +340,8 @@ public:
|
|||
const class style style() const;
|
||||
|
||||
/// <summary>
|
||||
/// Equivalent to style(new_style.name())
|
||||
/// Sets the named style applied to this cell to a style named style_name.
|
||||
/// Equivalent to style(new_style.name()).
|
||||
/// </summary>
|
||||
void style(const class style &new_style);
|
||||
|
||||
|
@ -378,120 +393,130 @@ public:
|
|||
// merging
|
||||
|
||||
/// <summary>
|
||||
/// Return true iff this cell has been merged with one or more
|
||||
/// Returns true iff this cell has been merged with one or more
|
||||
/// surrounding cells.
|
||||
/// </summary>
|
||||
bool is_merged() const;
|
||||
|
||||
/// <summary>
|
||||
/// Make this a merged cell iff merged is true.
|
||||
/// Makes this a merged cell iff merged is true.
|
||||
/// Generally, this shouldn't be called directly. Instead,
|
||||
/// use worksheet::merge_cells on its parent worksheet.
|
||||
/// </summary>
|
||||
void merged(bool merged);
|
||||
|
||||
/// <summary>
|
||||
/// Return the error string that is stored in this cell.
|
||||
/// Returns the error string that is stored in this cell.
|
||||
/// </summary>
|
||||
std::string error() const;
|
||||
|
||||
/// <summary>
|
||||
/// Directly assign the value of this cell to be the given error.
|
||||
/// Directly assigns the value of this cell to be the given error.
|
||||
/// </summary>
|
||||
void error(const std::string &error);
|
||||
|
||||
/// <summary>
|
||||
/// Return a cell from this cell's parent workbook at
|
||||
/// Returns a cell from this cell's parent workbook at
|
||||
/// a relative offset given by the parameters.
|
||||
/// </summary>
|
||||
cell offset(int column, int row);
|
||||
|
||||
/// <summary>
|
||||
/// Return the worksheet that owns this cell.
|
||||
/// Returns the worksheet that owns this cell.
|
||||
/// </summary>
|
||||
class worksheet worksheet();
|
||||
|
||||
/// <summary>
|
||||
/// Return the worksheet that owns this cell.
|
||||
/// Returns the worksheet that owns this cell.
|
||||
/// </summary>
|
||||
const class worksheet worksheet() const;
|
||||
|
||||
/// <summary>
|
||||
/// Return the workbook of the worksheet that owns this cell.
|
||||
/// Returns the workbook of the worksheet that owns this cell.
|
||||
/// </summary>
|
||||
class workbook &workbook();
|
||||
|
||||
/// <summary>
|
||||
/// Return the workbook of the worksheet that owns this cell.
|
||||
/// Returns the workbook of the worksheet that owns this cell.
|
||||
/// </summary>
|
||||
const class workbook &workbook() const;
|
||||
|
||||
/// <summary>
|
||||
/// Shortcut to return the base date of the parent workbook.
|
||||
/// Equivalent to workbook().properties().excel_base_date
|
||||
/// Returns the base date of the parent workbook.
|
||||
/// </summary>
|
||||
calendar base_date() const;
|
||||
|
||||
/// <summary>
|
||||
/// Return to_check after checking encoding, size, and illegal characters.
|
||||
/// Returns to_check after verifying and fixing encoding, size, and illegal characters.
|
||||
/// </summary>
|
||||
std::string check_string(const std::string &to_check);
|
||||
|
||||
// comment
|
||||
|
||||
/// <summary>
|
||||
/// Return true if this cell has a comment applied.
|
||||
/// Returns true if this cell has a comment applied.
|
||||
/// </summary>
|
||||
bool has_comment();
|
||||
|
||||
/// <summary>
|
||||
/// Delete the comment applied to this cell if it exists.
|
||||
/// Deletes the comment applied to this cell if it exists.
|
||||
/// </summary>
|
||||
void clear_comment();
|
||||
|
||||
/// <summary>
|
||||
/// Get the comment applied to this cell.
|
||||
/// Gets the comment applied to this cell.
|
||||
/// </summary>
|
||||
class comment comment();
|
||||
|
||||
/// <summary>
|
||||
/// Create a new comment with the given text and optional author and apply it to the cell.
|
||||
/// Creates a new comment with the given text and optional author and
|
||||
/// applies it to the cell.
|
||||
/// </summary>
|
||||
void comment(const std::string &text, const std::string &author = "Microsoft Office User");
|
||||
void comment(const std::string &text,
|
||||
const std::string &author = "Microsoft Office User");
|
||||
|
||||
/// <summary>
|
||||
/// Create a new comment with the given text, formatting, and optional author and apply it to the cell.
|
||||
/// Creates a new comment with the given text, formatting, and optional
|
||||
/// author and applies it to the cell.
|
||||
/// </summary>
|
||||
void comment(const std::string &comment_text, const class font &comment_font, const std::string &author = "Microsoft Office User");
|
||||
void comment(const std::string &comment_text,
|
||||
const class font &comment_font,
|
||||
const std::string &author = "Microsoft Office User");
|
||||
|
||||
/// <summary>
|
||||
/// Apply the comment provided as the only argument to the cell.
|
||||
/// </summary>
|
||||
void comment(const class comment &new_comment);
|
||||
|
||||
/// <summary>
|
||||
/// Returns the width of this cell in pixels.
|
||||
/// </summary>
|
||||
double width() const;
|
||||
|
||||
/// <summary>
|
||||
/// Returns the height of this cell in pixels.
|
||||
/// </summary>
|
||||
double height() const;
|
||||
|
||||
// operators
|
||||
|
||||
/// <summary>
|
||||
/// Make this cell point to rhs.
|
||||
/// The cell originally pointed to by this cell will be unchanged.
|
||||
/// Makes this cell interally point to rhs.
|
||||
/// The cell data originally pointed to by this cell will be unchanged.
|
||||
/// </summary>
|
||||
cell &operator=(const cell &rhs);
|
||||
|
||||
/// <summary>
|
||||
/// Return true if this cell the same cell as comparand (compare by reference).
|
||||
/// Returns true if this cell the same cell as comparand (compared by reference).
|
||||
/// </summary>
|
||||
bool operator==(const cell &comparand) const;
|
||||
|
||||
/// <summary>
|
||||
/// Return true if this cell is uninitialized.
|
||||
/// Returns true if this cell is uninitialized.
|
||||
/// </summary>
|
||||
bool operator==(std::nullptr_t) const;
|
||||
|
||||
private:
|
||||
// make these friends so they can use the private constructor
|
||||
friend class style;
|
||||
friend class worksheet;
|
||||
friend class detail::xlsx_consumer;
|
||||
|
@ -505,7 +530,7 @@ private:
|
|||
class format modifiable_format();
|
||||
|
||||
/// <summary>
|
||||
/// Delete default zero-argument constructor.
|
||||
/// Delete the default zero-argument constructor.
|
||||
/// </summary>
|
||||
cell() = delete;
|
||||
|
||||
|
@ -521,7 +546,7 @@ private:
|
|||
};
|
||||
|
||||
/// <summary>
|
||||
/// Return true if this cell is uninitialized.
|
||||
/// Returns true if this cell is uninitialized.
|
||||
/// </summary>
|
||||
XLNT_API bool operator==(std::nullptr_t, const cell &cell);
|
||||
|
||||
|
|
|
@ -26,6 +26,10 @@
|
|||
|
||||
#include <xlnt/xlnt_config.hpp>
|
||||
|
||||
/// <summary>
|
||||
/// Enumerates the possible types a cell can be determined by it's current value.
|
||||
/// </summary>
|
||||
|
||||
namespace xlnt {
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -31,6 +31,11 @@
|
|||
|
||||
namespace xlnt {
|
||||
|
||||
// TODO: make this a real object?
|
||||
|
||||
/// <summary>
|
||||
/// Typedef a rich_text_run as a pair of string and optional font.
|
||||
/// </summary>
|
||||
using rich_text_run = std::pair<std::string, optional<font>>;
|
||||
|
||||
} // namespace xlnt
|
||||
|
|
|
@ -38,29 +38,22 @@ class XLNT_API optional
|
|||
{
|
||||
public:
|
||||
/// <summary>
|
||||
///
|
||||
/// Default contructor. is_set() will be false initially.
|
||||
/// </summary>
|
||||
optional() : has_value_(false), value_(T())
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// Constructs this optional with a value.
|
||||
/// </summary>
|
||||
explicit optional(const T &value) : has_value_(true), value_(value)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
explicit operator bool() const
|
||||
{
|
||||
return is_set();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// Returns true if this object currently has a value set. This should
|
||||
/// be called before accessing the value with optional::get().
|
||||
/// </summary>
|
||||
bool is_set() const
|
||||
{
|
||||
|
@ -68,7 +61,7 @@ public:
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// Sets the value to value.
|
||||
/// </summary>
|
||||
void set(const T &value)
|
||||
{
|
||||
|
@ -77,7 +70,8 @@ public:
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// Gets the value. If no value has been initialized in this object,
|
||||
/// an xlnt::invalid_attribute exception will be thrown.
|
||||
/// </summary>
|
||||
T &get()
|
||||
{
|
||||
|
@ -90,7 +84,8 @@ public:
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// Gets the value. If no value has been initialized in this object,
|
||||
/// an xlnt::invalid_attribute exception will be thrown.
|
||||
/// </summary>
|
||||
const T &get() const
|
||||
{
|
||||
|
@ -103,7 +98,8 @@ public:
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// Resets the internal value using its default constructor. After this is
|
||||
/// called, is_set() will return false until a new value is provided.
|
||||
/// </summary>
|
||||
void clear()
|
||||
{
|
||||
|
@ -111,6 +107,9 @@ public:
|
|||
value_ = T();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Assignment operator. Equivalent to setting the value using optional::set.
|
||||
/// </summary>
|
||||
optional &operator=(const T &rhs)
|
||||
{
|
||||
has_value_ = true;
|
||||
|
@ -120,22 +119,18 @@ public:
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// Returns true if neither this nor other have a value
|
||||
/// or both have a value and those values are equal according to
|
||||
/// their equality operator.
|
||||
/// </summary>
|
||||
bool operator==(const optional<T> &other) const
|
||||
{
|
||||
return has_value_ == other.has_value_ && (!has_value_ || (has_value_ && value_ == other.value_));
|
||||
return has_value_ == other.has_value_
|
||||
&& (!has_value_ || (has_value_ && value_ == other.value_));
|
||||
}
|
||||
|
||||
private:
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
bool has_value_;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
T value_;
|
||||
};
|
||||
|
||||
|
|
|
@ -34,10 +34,13 @@ namespace xlnt {
|
|||
template<typename Enum>
|
||||
struct scoped_enum_hash
|
||||
{
|
||||
/// <summary>
|
||||
/// Cast the enumeration e to a std::size_t and hash that value using std::hash.
|
||||
/// </summary>
|
||||
std::size_t operator()(Enum e) const
|
||||
{
|
||||
static std::hash<std::size_t> hasher;
|
||||
return hasher(static_cast<std::size_t>(e));
|
||||
static std::hash<std::size_t> hasher;
|
||||
return hasher(static_cast<std::size_t>(e));
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -32,9 +32,17 @@ namespace xlnt {
|
|||
|
||||
struct datetime;
|
||||
|
||||
/// <summary>
|
||||
/// Represents an object that can have variable type.
|
||||
/// </summary>
|
||||
class XLNT_API variant
|
||||
{
|
||||
public:
|
||||
// TODO: implement remaining types?
|
||||
|
||||
/// <summary>
|
||||
/// The possible types a variant can hold.
|
||||
/// </summary>
|
||||
enum class type
|
||||
{
|
||||
vector,
|
||||
|
@ -56,7 +64,7 @@ public:
|
|||
//r4,
|
||||
//r8,
|
||||
//decimal,
|
||||
lpstr,
|
||||
lpstr, // TODO: how does this differ from lpwstr?
|
||||
//lpwstr,
|
||||
//bstr,
|
||||
date,
|
||||
|
@ -72,25 +80,86 @@ public:
|
|||
//clsid
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Default constructor. Creates a null-type variant.
|
||||
/// </summary>
|
||||
variant();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a string-type variant with the given value.
|
||||
/// </summary>
|
||||
variant(const std::string &value);
|
||||
|
||||
/// <summary>
|
||||
/// Creates a string-type variant with the given value.
|
||||
/// </summary>
|
||||
variant(const char *value);
|
||||
|
||||
/// <summary>
|
||||
/// Creates a i4-type variant with the given value.
|
||||
/// </summary>
|
||||
variant(int value);
|
||||
|
||||
/// <summary>
|
||||
/// Creates a bool-type variant with the given value.
|
||||
/// </summary>
|
||||
variant(bool value);
|
||||
|
||||
/// <summary>
|
||||
/// Creates a date-type variant with the given value.
|
||||
/// </summary>
|
||||
variant(const datetime &value);
|
||||
|
||||
/// <summary>
|
||||
/// Creates a vector_i4-type variant with the given value.
|
||||
/// </summary>
|
||||
variant(const std::initializer_list<int> &value);
|
||||
|
||||
/// <summary>
|
||||
/// Creates a vector_i4-type variant with the given value.
|
||||
/// </summary>
|
||||
variant(const std::vector<int> &value);
|
||||
|
||||
/// <summary>
|
||||
/// Creates a vector_string-type variant with the given value.
|
||||
/// </summary>
|
||||
variant(const std::initializer_list<const char *> &value);
|
||||
|
||||
/// <summary>
|
||||
/// Creates a vector_string-type variant with the given value.
|
||||
/// </summary>
|
||||
variant(const std::vector<const char *> &value);
|
||||
|
||||
/// <summary>
|
||||
/// Creates a vector_string-type variant with the given value.
|
||||
/// </summary>
|
||||
variant(const std::initializer_list<std::string> &value);
|
||||
|
||||
/// <summary>
|
||||
/// Creates a vector_string-type variant with the given value.
|
||||
/// </summary>
|
||||
variant(const std::vector<std::string> &value);
|
||||
|
||||
/// <summary>
|
||||
/// Creates a vector_variant-type variant with the given value.
|
||||
/// </summary>
|
||||
variant(const std::vector<variant> &value);
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if this variant is of type t.
|
||||
/// </summary>
|
||||
bool is(type t) const;
|
||||
|
||||
/// <summary>
|
||||
/// Returns the value of this variant as type T. An exception will
|
||||
/// be thrown if the types are not convertible.
|
||||
/// </summary>
|
||||
template<typename T>
|
||||
T get() const;
|
||||
|
||||
/// <summary>
|
||||
/// Returns the type of this variant.
|
||||
/// </summary>
|
||||
type value_type() const;
|
||||
|
||||
private:
|
||||
|
|
|
@ -33,7 +33,14 @@ namespace xlnt {
|
|||
class XLNT_API calculation_properties
|
||||
{
|
||||
public:
|
||||
/// <summary>
|
||||
/// Uniquely identifies these calculation properties.
|
||||
/// </summary>
|
||||
std::size_t calc_id;
|
||||
|
||||
/// <summary>
|
||||
/// If this is true, concurrent calculation is enabled.
|
||||
/// </summary>
|
||||
bool concurrent_calc;
|
||||
};
|
||||
|
||||
|
|
|
@ -34,6 +34,9 @@ namespace xlnt {
|
|||
class workbook;
|
||||
class worksheet;
|
||||
|
||||
/// <summary>
|
||||
/// Alias the parent class of this iterator to increase clarity.
|
||||
/// </summary>
|
||||
using c_ws_iter_type = std::iterator<std::bidirectional_iterator_tag,
|
||||
const worksheet, std::ptrdiff_t, const worksheet *, const worksheet>;
|
||||
|
||||
|
|
|
@ -27,6 +27,9 @@
|
|||
|
||||
namespace xlnt {
|
||||
|
||||
/// <summary>
|
||||
/// Every core property in a workbook must be one of these types.
|
||||
/// </summary>
|
||||
enum class core_property
|
||||
{
|
||||
category,
|
||||
|
@ -46,6 +49,9 @@ enum class core_property
|
|||
version
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Every extended property in a workbook must be one of these types.
|
||||
/// </summary>
|
||||
enum class extended_property
|
||||
{
|
||||
application,
|
||||
|
|
|
@ -90,149 +90,160 @@ class XLNT_API workbook
|
|||
{
|
||||
public:
|
||||
/// <summary>
|
||||
///
|
||||
/// typedef for the iterator used for iterating through this workbook
|
||||
/// (non-const) in a range-based for loop.
|
||||
/// </summary>
|
||||
using iterator = worksheet_iterator;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// typedef for the iterator used for iterating through this workbook
|
||||
/// (const) in a range-based for loop.
|
||||
/// </summary>
|
||||
using const_iterator = const_worksheet_iterator;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// 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.
|
||||
/// </summary>
|
||||
using reverse_iterator = std::reverse_iterator<iterator>;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// 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.
|
||||
/// </summary>
|
||||
using const_reverse_iterator = std::reverse_iterator<const_iterator>;
|
||||
|
||||
/// <summary>
|
||||
/// Swap the data held in workbooks "left" and "right".
|
||||
/// Swaps the data held in workbooks "left" and "right".
|
||||
/// </summary>
|
||||
friend void swap(workbook &left, workbook &right);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// Constructs and returns an empty workbook similar to a default.
|
||||
/// Excel workbook
|
||||
/// </summary>
|
||||
static workbook empty();
|
||||
|
||||
// constructors
|
||||
// Constructors
|
||||
|
||||
/// <summary>
|
||||
/// Create a workbook containing a single empty worksheet.
|
||||
/// Default constructor. Constructs a workbook containing a single empty
|
||||
/// worksheet using workbook::empty().
|
||||
/// </summary>
|
||||
workbook();
|
||||
|
||||
/// <summary>
|
||||
/// Move construct this workbook from existing workbook "other".
|
||||
/// Move constructor. Constructs a workbook from existing workbook, other.
|
||||
/// </summary>
|
||||
workbook(workbook &&other);
|
||||
|
||||
/// <summary>
|
||||
/// Copy construct this workbook from existing workbook "other".
|
||||
/// Copy constructor. Constructs this workbook from existing workbook, other.
|
||||
/// </summary>
|
||||
workbook(const workbook &other);
|
||||
|
||||
/// <summary>
|
||||
/// Destroy this workbook.
|
||||
/// 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.
|
||||
/// </summary>
|
||||
~workbook();
|
||||
|
||||
// add worksheets
|
||||
// Worksheets
|
||||
|
||||
/// <summary>
|
||||
/// Create a sheet after the last sheet in this workbook and return it.
|
||||
/// Creates and returns a sheet after the last sheet in this workbook.
|
||||
/// </summary>
|
||||
worksheet create_sheet();
|
||||
|
||||
/// <summary>
|
||||
/// Create a sheet at the specified index and return it.
|
||||
/// Creates and returns a sheet at the specified index.
|
||||
/// </summary>
|
||||
worksheet create_sheet(std::size_t index);
|
||||
|
||||
/// <summary>
|
||||
/// This should be private...
|
||||
/// TODO: This should be private...
|
||||
/// </summary>
|
||||
worksheet create_sheet_with_rel(const std::string &title, const relationship &rel);
|
||||
|
||||
/// <summary>
|
||||
/// Create a new sheet initializing it with all of the data from the provided worksheet.
|
||||
/// Creates and returns a new sheet after the last sheet initializing it
|
||||
/// with all of the data from the provided worksheet.
|
||||
/// </summary>
|
||||
void copy_sheet(worksheet worksheet);
|
||||
worksheet copy_sheet(worksheet worksheet);
|
||||
|
||||
/// <summary>
|
||||
/// Create a new sheet at the specified index initializing it with all of the data
|
||||
/// from the provided worksheet.
|
||||
void copy_sheet(worksheet worksheet, std::size_t index);
|
||||
|
||||
// get worksheets
|
||||
/// Creates and returns a new sheet at the specified index initializing it
|
||||
/// with all of the data from the provided worksheet.
|
||||
/// </summary>
|
||||
worksheet copy_sheet(worksheet worksheet, std::size_t index);
|
||||
|
||||
/// <summary>
|
||||
/// Returns the worksheet that was most recently accessed.
|
||||
/// This is also the sheet that will be shown when the workbook is opened
|
||||
/// in the spreadsheet editor program.
|
||||
/// Returns the worksheet that is determined to be active. An active
|
||||
/// sheet is that which is initially shown by the spreadsheet editor.
|
||||
/// </summary>
|
||||
worksheet active_sheet();
|
||||
|
||||
/// <summary>
|
||||
/// Return the worksheet with the given name.
|
||||
/// This may throw an exception if the sheet isn't found.
|
||||
/// Use workbook::contains(const std::string &) to make sure the sheet exists.
|
||||
/// Returns the worksheet with the given name. This may throw an exception
|
||||
/// if the sheet isn't found. Use workbook::contains(const std::string &)
|
||||
/// to make sure the sheet exists before calling this method.
|
||||
/// </summary>
|
||||
worksheet sheet_by_title(const std::string &sheet_name);
|
||||
worksheet sheet_by_title(const std::string &title);
|
||||
|
||||
/// <summary>
|
||||
/// Return the const worksheet with the given name.
|
||||
/// This may throw an exception if the sheet isn't found.
|
||||
/// Use workbook::contains(const std::string &) to make sure the sheet exists.
|
||||
/// Returns the worksheet with the given name. This may throw an exception
|
||||
/// if the sheet isn't found. Use workbook::contains(const std::string &)
|
||||
/// to make sure the sheet exists before calling this method.
|
||||
/// </summary>
|
||||
const worksheet sheet_by_title(const std::string &sheet_name) const;
|
||||
const worksheet sheet_by_title(const std::string &title) const;
|
||||
|
||||
/// <summary>
|
||||
/// Return the worksheet at the given index.
|
||||
/// Returns the worksheet at the given index. This will throw an exception
|
||||
/// if index is greater than or equal to the number of sheets in this workbook.
|
||||
/// </summary>
|
||||
worksheet sheet_by_index(std::size_t index);
|
||||
|
||||
/// <summary>
|
||||
/// Return the const worksheet at the given index.
|
||||
/// Returns the worksheet at the given index. This will throw an exception
|
||||
/// if index is greater than or equal to the number of sheets in this workbook.
|
||||
/// </summary>
|
||||
const worksheet sheet_by_index(std::size_t index) const;
|
||||
|
||||
/// <summary>
|
||||
/// Return the worksheet with a sheetId of id.
|
||||
/// Returns the worksheet with a sheetId of id. Sheet IDs are arbitrary numbers
|
||||
/// that uniquely identify a sheet. Most users won't need this.
|
||||
/// </summary>
|
||||
worksheet sheet_by_id(std::size_t id);
|
||||
|
||||
/// <summary>
|
||||
/// Return the const worksheet with a sheetId of id.
|
||||
/// Returns the worksheet with a sheetId of id. Sheet IDs are arbitrary numbers
|
||||
/// that uniquely identify a sheet. Most users won't need this.
|
||||
/// </summary>
|
||||
const worksheet sheet_by_id(std::size_t id) const;
|
||||
|
||||
/// <summary>
|
||||
/// Return true if this workbook contains a sheet with the given name.
|
||||
/// Returns true if this workbook contains a sheet with the given title.
|
||||
/// </summary>
|
||||
bool contains(const std::string &key) const;
|
||||
bool contains(const std::string &title) const;
|
||||
|
||||
/// <summary>
|
||||
/// Return the index of the given worksheet.
|
||||
/// The worksheet must be owned by this workbook.
|
||||
/// Returns the index of the given worksheet. The worksheet must be owned by this workbook.
|
||||
/// </summary>
|
||||
std::size_t index(worksheet worksheet);
|
||||
|
||||
// remove worksheets
|
||||
|
||||
/// <summary>
|
||||
/// Remove the given worksheet from this workbook.
|
||||
/// Removes the given worksheet from this workbook.
|
||||
/// </summary>
|
||||
void remove_sheet(worksheet worksheet);
|
||||
|
||||
/// <summary>
|
||||
/// Delete every cell in this worksheet. After this is called, the
|
||||
/// worksheet will be equivalent to a newly created sheet at the same
|
||||
/// index and with the same title.
|
||||
/// Sets the contents of this workbook to be equivalent to that of
|
||||
/// a workbook returned by workbook::empty().
|
||||
/// </summary>
|
||||
void clear();
|
||||
|
||||
|
@ -275,7 +286,7 @@ public:
|
|||
const_iterator cend() const;
|
||||
|
||||
/// <summary>
|
||||
/// Apply the function "f" to every non-empty cell in every worksheet in this workbook.
|
||||
/// Applies the function "f" to every non-empty cell in every worksheet in this workbook.
|
||||
/// </summary>
|
||||
void apply_to_cells(std::function<void(cell)> f);
|
||||
|
||||
|
@ -290,23 +301,26 @@ public:
|
|||
/// </summary>
|
||||
std::size_t sheet_count() const;
|
||||
|
||||
// Metadata Properties
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the workbook has the core property with the given name.
|
||||
/// </summary>
|
||||
bool has_core_property(xlnt::core_property type) const;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// Returns a vector of the type of each core property that is set to
|
||||
/// a particular value in this workbook.
|
||||
/// </summary>
|
||||
std::vector<xlnt::core_property> core_properties() const;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// Returns the value of the given core property.
|
||||
/// </summary>
|
||||
variant core_property(xlnt::core_property type) const;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// Sets the given core property to the provided value.
|
||||
/// </summary>
|
||||
void core_property(xlnt::core_property type, const variant &value);
|
||||
|
||||
|
@ -316,17 +330,18 @@ public:
|
|||
bool has_extended_property(xlnt::extended_property type) const;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// Returns a vector of the type of each extended property that is set to
|
||||
/// a particular value in this workbook.
|
||||
/// </summary>
|
||||
std::vector<xlnt::extended_property> extended_properties() const;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// Returns the value of the given extended property.
|
||||
/// </summary>
|
||||
variant extended_property(xlnt::extended_property type) const;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// Sets the given extended property to the provided value.
|
||||
/// </summary>
|
||||
void extended_property(xlnt::extended_property type, const variant &value);
|
||||
|
||||
|
@ -336,362 +351,402 @@ public:
|
|||
bool has_custom_property(const std::string &property_name) const;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// Returns a vector of the name of each custom property that is set to
|
||||
/// a particular value in this workbook.
|
||||
/// </summary>
|
||||
std::vector<std::string> custom_properties() const;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// Returns the value of the given custom property.
|
||||
/// </summary>
|
||||
variant custom_property(const std::string &property_name) const;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// Creates a new custom property in this workbook and sets it to the provided value.
|
||||
/// </summary>
|
||||
void custom_property(const std::string &property_name, const variant &value);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// 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)`.
|
||||
/// </summary>
|
||||
calendar base_date() const;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// Sets the base date style of this workbook. This is the date and time that
|
||||
/// a numeric value of 0 represents.
|
||||
/// </summary>
|
||||
void base_date(calendar base_date);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// Returns true if this workbook has had its title set.
|
||||
/// </summary>
|
||||
bool has_title() const;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// Returns the title of this workbook.
|
||||
/// </summary>
|
||||
std::string title() const;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// Sets the title of this workbook to title.
|
||||
/// </summary>
|
||||
void title(const std::string &title);
|
||||
|
||||
// named ranges
|
||||
// Named Ranges
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// Returns a vector of the named ranges in this workbook.
|
||||
/// </summary>
|
||||
std::vector<xlnt::named_range> named_ranges() const;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// Creates a new names range.
|
||||
/// </summary>
|
||||
void create_named_range(const std::string &name, worksheet worksheet, const range_reference &reference);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// Creates a new names range.
|
||||
/// </summary>
|
||||
void create_named_range(const std::string &name, worksheet worksheet, const std::string &reference_string);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// Returns true if a named range of the given name exists in the workbook.
|
||||
/// </summary>
|
||||
bool has_named_range(const std::string &name) const;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// Returns the named range with the given name.
|
||||
/// </summary>
|
||||
class range named_range(const std::string &name);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// Deletes the named range with the given name.
|
||||
/// </summary>
|
||||
void remove_named_range(const std::string &name);
|
||||
|
||||
// serialization
|
||||
// Serialization/Deserialization
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// Serializes the workbook into an XLSX file and saves the bytes into
|
||||
/// byte vector data.
|
||||
/// </summary>
|
||||
void save(std::vector<std::uint8_t> &data) const;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// Serializes the workbook into an XLSX file encrypted with the given password
|
||||
/// and saves the bytes into byte vector data.
|
||||
/// </summary>
|
||||
void save(std::vector<std::uint8_t> &data, const std::string &password) const;
|
||||
|
||||
/// <summary>
|
||||
/// Serializes the workbook into an XLSX file and saves the data into a file
|
||||
/// named filename.
|
||||
/// </summary>
|
||||
void save(const std::string &filename) const;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
void save(const xlnt::path &filename) const;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
void save(std::ostream &stream) const;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// Serializes the workbook into an XLSX file encrypted with the given password
|
||||
/// and loads the bytes into a file named filename.
|
||||
/// </summary>
|
||||
void save(const std::string &filename, const std::string &password);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
void save(const xlnt::path &filename, const std::string &password);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
void save(std::ostream &stream, const std::string &password);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
void save(const std::vector<std::uint8_t> &data, const std::string &password);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
void load(const std::vector<std::uint8_t> &data);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
void load(const std::string &filename);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
void load(const xlnt::path &filename);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
void load(std::istream &stream);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
void load(const std::string &filename, const std::string &password);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
void load(const xlnt::path &filename, const std::string &password);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
void load(std::istream &stream, const std::string &password);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
void load(const std::vector<std::uint8_t> &data, const std::string &password);
|
||||
|
||||
#ifdef _MSC_VER
|
||||
/// <summary>
|
||||
///
|
||||
/// Serializes the workbook into an XLSX file and saves the data into a file
|
||||
/// named filename.
|
||||
/// </summary>
|
||||
void save(const std::wstring &filename);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// Serializes the workbook into an XLSX file encrypted with the given password
|
||||
/// and loads the bytes into a file named filename.
|
||||
/// </summary>
|
||||
void save(const std::wstring &filename, const std::string &password);
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// Serializes the workbook into an XLSX file and saves the data into a file
|
||||
/// named filename.
|
||||
/// </summary>
|
||||
void save(const xlnt::path &filename) const;
|
||||
|
||||
/// <summary>
|
||||
/// Serializes the workbook into an XLSX file encrypted with the given password
|
||||
/// and loads the bytes into a file named filename.
|
||||
/// </summary>
|
||||
void save(const xlnt::path &filename, const std::string &password);
|
||||
|
||||
/// <summary>
|
||||
/// Serializes the workbook into an XLSX file and saves the data into stream.
|
||||
/// </summary>
|
||||
void save(std::ostream &stream) const;
|
||||
|
||||
/// <summary>
|
||||
/// Serializes the workbook into an XLSX file encrypted with the given password
|
||||
/// and loads the bytes into the given stream.
|
||||
/// </summary>
|
||||
void save(std::ostream &stream, const std::string &password);
|
||||
|
||||
/// <summary>
|
||||
/// Interprets byte vector data as an XLSX file and sets the content of this
|
||||
/// workbook to match that file.
|
||||
/// </summary>
|
||||
void load(const std::vector<std::uint8_t> &data);
|
||||
|
||||
/// <summary>
|
||||
/// Interprets byte vector data as an XLSX file encrypted with the
|
||||
/// given password and sets the content of this workbook to match that file.
|
||||
/// </summary>
|
||||
void load(const std::vector<std::uint8_t> &data, const std::string &password);
|
||||
|
||||
/// <summary>
|
||||
/// Interprets file with the given filename as an XLSX file and sets
|
||||
/// the content of this workbook to match that file.
|
||||
/// </summary>
|
||||
void load(const std::string &filename);
|
||||
|
||||
/// <summary>
|
||||
/// 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.
|
||||
/// </summary>
|
||||
void load(const std::string &filename, const std::string &password);
|
||||
|
||||
#ifdef _MSC_VER
|
||||
/// <summary>
|
||||
/// Interprets file with the given filename as an XLSX file and sets
|
||||
/// the content of this workbook to match that file.
|
||||
/// </summary>
|
||||
void load(const std::wstring &filename);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// 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.
|
||||
/// </summary>
|
||||
void load(const std::wstring &filename, const std::string &password);
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// Interprets file with the given filename as an XLSX file and sets the
|
||||
/// content of this workbook to match that file.
|
||||
/// </summary>
|
||||
void load(const xlnt::path &filename);
|
||||
|
||||
/// <summary>
|
||||
/// 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.
|
||||
/// </summary>
|
||||
void load(const xlnt::path &filename, const std::string &password);
|
||||
|
||||
/// <summary>
|
||||
/// Interprets data in stream as an XLSX file and sets the content of this
|
||||
/// workbook to match that file.
|
||||
/// </summary>
|
||||
void load(std::istream &stream);
|
||||
|
||||
/// <summary>
|
||||
/// Interprets data in stream as an XLSX file encrypted with the given password
|
||||
/// and sets the content of this workbook to match that file.
|
||||
/// </summary>
|
||||
void load(std::istream &stream, const std::string &password);
|
||||
|
||||
// View
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if this workbook has a view.
|
||||
/// </summary>
|
||||
bool has_view() const;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// Returns the view.
|
||||
/// </summary>
|
||||
workbook_view view() const;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// Sets the view to view.
|
||||
/// </summary>
|
||||
void view(const workbook_view &view);
|
||||
|
||||
// Properties
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// Returns true if a code name has been set for this workbook.
|
||||
/// </summary>
|
||||
bool has_code_name() const;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// Returns the code name that was set for this workbook.
|
||||
/// </summary>
|
||||
std::string code_name() const;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// Sets the code name of this workbook to code_name.
|
||||
/// </summary>
|
||||
void code_name(const std::string &code_name);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// Returns true if this workbook has a file version.
|
||||
/// </summary>
|
||||
bool has_file_version() const;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// Returns the AppName workbook file property.
|
||||
/// </summary>
|
||||
std::string app_name() const;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// Returns the LastEdited workbook file property.
|
||||
/// </summary>
|
||||
std::size_t last_edited() const;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// Returns the LowestEdited workbook file property.
|
||||
/// </summary>
|
||||
std::size_t lowest_edited() const;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// Returns the RupBuild workbook file property.
|
||||
/// </summary>
|
||||
std::size_t rup_build() const;
|
||||
|
||||
// theme
|
||||
// Theme
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// Returns true if this workbook has a theme defined.
|
||||
/// </summary>
|
||||
bool has_theme() const;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// Returns a const reference to this workbook's theme.
|
||||
/// </summary>
|
||||
const xlnt::theme &theme() const;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// Sets the theme to value.
|
||||
/// </summary>
|
||||
void theme(const class theme &value);
|
||||
|
||||
// formats
|
||||
// Formats
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// Returns the cell format at the given index. The index is the position of
|
||||
/// the format in xl/styles.xml.
|
||||
/// </summary>
|
||||
xlnt::format format(std::size_t format_index);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// Returns the cell format at the given index. The index is the position of
|
||||
/// the format in xl/styles.xml.
|
||||
/// </summary>
|
||||
const xlnt::format format(std::size_t format_index) const;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// Creates a new format and returns it.
|
||||
/// </summary>
|
||||
xlnt::format create_format(bool default_format = false);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// Clear all cell-level formatting and formats from the styelsheet. This leaves
|
||||
/// all other styling in place (e.g. named styles).
|
||||
/// </summary>
|
||||
void clear_formats();
|
||||
|
||||
// styles
|
||||
// Styles
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// Returns true if this workbook has a style with a name of name.
|
||||
/// </summary>
|
||||
bool has_style(const std::string &name) const;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// Returns the named style with the given name.
|
||||
/// </summary>
|
||||
class style style(const std::string &name);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// Returns the named style with the given name.
|
||||
/// </summary>
|
||||
const class style style(const std::string &name) const;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// Creates a new style and returns it.
|
||||
/// </summary>
|
||||
class style create_style(const std::string &name);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// 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).
|
||||
/// </summary>
|
||||
void clear_styles();
|
||||
|
||||
// manifest
|
||||
// Manifest
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// Returns a reference to the workbook's internal manifest.
|
||||
/// </summary>
|
||||
class manifest &manifest();
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// Returns a reference to the workbook's internal manifest.
|
||||
/// </summary>
|
||||
const class manifest &manifest() const;
|
||||
|
||||
// shared strings
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// 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.
|
||||
/// </summary>
|
||||
void add_shared_string(const rich_text &shared, bool allow_duplicates = false);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// Returns a reference to the shared strings being used by cells
|
||||
/// in this workbook.
|
||||
/// </summary>
|
||||
std::vector<rich_text> &shared_strings();
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// Returns a reference to the shared strings being used by cells
|
||||
/// in this workbook.
|
||||
/// </summary>
|
||||
const std::vector<rich_text> &shared_strings() const;
|
||||
|
||||
// thumbnail
|
||||
// Thumbnail
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// 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).
|
||||
/// </summary>
|
||||
void thumbnail(const std::vector<std::uint8_t> &thumbnail,
|
||||
const std::string &extension, const std::string &content_type);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// Returns a vector of bytes representing the workbook's thumbnail.
|
||||
/// </summary>
|
||||
const std::vector<std::uint8_t> &thumbnail() const;
|
||||
|
||||
// calculation properties
|
||||
// Calculation properties
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// Returns true if this workbook has any calculation properties set.
|
||||
/// </summary>
|
||||
bool has_calculation_properties() const;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// Returns the calculation properties used in this workbook.
|
||||
/// </summary>
|
||||
class calculation_properties calculation_properties() const;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// Sets the calculation properties of this workbook to props.
|
||||
/// </summary>
|
||||
void calculation_properties(const class calculation_properties &props);
|
||||
|
||||
// operators
|
||||
// Operators
|
||||
|
||||
/// <summary>
|
||||
/// Set the contents of this workbook to be equal to those of "other".
|
||||
|
@ -727,32 +782,43 @@ private:
|
|||
friend class detail::xlsx_producer;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// Private constructor. Constructs a workbook from an implementation pointer.
|
||||
/// Used by static constructor to resolve circular construction dependency.
|
||||
/// </summary>
|
||||
workbook(detail::workbook_impl *impl);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// Returns a reference to the workbook implementation structure. Provides
|
||||
/// a nicer interface than constantly dereferencing workbook::d_.
|
||||
/// </summary>
|
||||
detail::workbook_impl &impl();
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// Returns a reference to the workbook implementation structure. Provides
|
||||
/// a nicer interface than constantly dereferencing workbook::d_.
|
||||
/// </summary>
|
||||
const detail::workbook_impl &impl() const;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// Adds a package-level part of the given type to the manifest if it doesn't
|
||||
/// already exist. The part will have a path and content type of the default
|
||||
/// for that particular relationship type.
|
||||
/// </summary>
|
||||
void register_package_part(relationship_type type);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// Adds a workbook-level part of the given type to the manifest if it doesn't
|
||||
/// already exist. The part will have a path and content type of the default
|
||||
/// for that particular relationship type. It will be a relationship target
|
||||
/// of this workbook.
|
||||
/// </summary>
|
||||
void register_workbook_part(relationship_type type);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// Adds a worksheet-level part of the given type to the manifest if it doesn't
|
||||
/// already exist. The part will have a path and content type of the default
|
||||
/// for that particular relationship type. It will be a relationship target
|
||||
/// of the given worksheet, ws.
|
||||
/// </summary>
|
||||
void register_worksheet_part(worksheet ws, relationship_type type);
|
||||
|
||||
|
|
|
@ -33,6 +33,9 @@ namespace xlnt {
|
|||
class workbook;
|
||||
class worksheet;
|
||||
|
||||
/// <summary>
|
||||
/// Alias the parent class of this iterator to increase clarity.
|
||||
/// </summary>
|
||||
using ws_iter_type = std::iterator<std::bidirectional_iterator_tag,
|
||||
worksheet, std::ptrdiff_t, worksheet *, worksheet>;
|
||||
|
||||
|
|
|
@ -40,6 +40,9 @@ class cell;
|
|||
class cell_reference;
|
||||
class range_reference;
|
||||
|
||||
/// <summary>
|
||||
/// Alias the parent class of this iterator to increase clarity.
|
||||
/// </summary>
|
||||
using c_iter_type = std::iterator<std::bidirectional_iterator_tag,
|
||||
cell, std::ptrdiff_t, cell *, cell>;
|
||||
|
||||
|
|
|
@ -40,6 +40,9 @@ class cell;
|
|||
class cell_reference;
|
||||
class range_reference;
|
||||
|
||||
/// <summary>
|
||||
/// Alias the parent class of this iterator to increase clarity.
|
||||
/// </summary>
|
||||
using cc_iter_type = std::iterator<std::bidirectional_iterator_tag,
|
||||
const cell, std::ptrdiff_t, const cell *, const cell>;
|
||||
|
||||
|
|
|
@ -38,6 +38,9 @@ namespace detail {
|
|||
struct worksheet_impl;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Alias the parent class of this iterator to increase clarity.
|
||||
/// </summary>
|
||||
using cr_iter_type = std::iterator<std::bidirectional_iterator_tag,
|
||||
const cell_vector, std::ptrdiff_t, const cell_vector *, const cell_vector>;
|
||||
|
||||
|
|
|
@ -34,9 +34,15 @@
|
|||
|
||||
namespace xlnt {
|
||||
|
||||
/// <summary>
|
||||
/// Represents the header and footer of a sheet in a workbook.
|
||||
/// </summary>
|
||||
class XLNT_API header_footer
|
||||
{
|
||||
public:
|
||||
/// <summary>
|
||||
/// Enumerates the three possible locations of a header or footer.
|
||||
/// </summary>
|
||||
enum class location
|
||||
{
|
||||
left,
|
||||
|
@ -155,7 +161,6 @@ public:
|
|||
/// </summary>
|
||||
rich_text first_page_header(location where) const;
|
||||
|
||||
|
||||
// Odd/Even Header
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -81,6 +81,10 @@ struct XLNT_API pane
|
|||
/// </summary>
|
||||
column_t x_split = 1;
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if this pane is equal to rhs based on its top-left cell, state,
|
||||
/// active pane, and x/y split location.
|
||||
/// </summary>
|
||||
bool operator==(const pane &rhs) const
|
||||
{
|
||||
return top_left_cell == rhs.top_left_cell && state == rhs.state && active_pane == rhs.active_pane
|
||||
|
|
|
@ -35,6 +35,9 @@ namespace xlnt {
|
|||
|
||||
class cell_vector;
|
||||
|
||||
/// <summary>
|
||||
/// Alias the parent class of this iterator to increase clarity.
|
||||
/// </summary>
|
||||
using r_iter_type = std::iterator<std::bidirectional_iterator_tag,
|
||||
cell_vector, std::ptrdiff_t, cell_vector *, cell_vector>;
|
||||
|
||||
|
|
|
@ -84,9 +84,14 @@ public:
|
|||
pane_ = corner;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if this selection is equal to rhs based on its active cell,
|
||||
/// sqref, and pane.
|
||||
/// </summary>
|
||||
bool operator==(const selection &rhs) const
|
||||
{
|
||||
return active_cell_ == rhs.active_cell_ && sqref_ == rhs.sqref_ && pane_ == rhs.pane_;
|
||||
return active_cell_ == rhs.active_cell_
|
||||
&& sqref_ == rhs.sqref_ && pane_ == rhs.pane_;
|
||||
}
|
||||
|
||||
private:
|
||||
|
|
|
@ -176,16 +176,26 @@ public:
|
|||
return default_grid_color_;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the type of this view.
|
||||
/// </summary>
|
||||
void type(sheet_view_type new_type)
|
||||
{
|
||||
type_ = new_type;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the type of this view.
|
||||
/// </summary>
|
||||
sheet_view_type type() const
|
||||
{
|
||||
return type_;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if this view is requal to rhs based on its id, grid lines setting,
|
||||
/// default grid color, pane, and selections.
|
||||
/// </summary>
|
||||
bool operator==(const sheet_view &rhs) const
|
||||
{
|
||||
return id_ == rhs.id_ && show_grid_lines_ == rhs.show_grid_lines_
|
||||
|
|
|
@ -867,7 +867,7 @@ bool cell::has_style() const
|
|||
|
||||
format cell::modifiable_format()
|
||||
{
|
||||
if (!d_->format_)
|
||||
if (!d_->format_.is_set())
|
||||
{
|
||||
throw invalid_attribute();
|
||||
}
|
||||
|
@ -877,7 +877,7 @@ format cell::modifiable_format()
|
|||
|
||||
const format cell::format() const
|
||||
{
|
||||
if (!d_->format_)
|
||||
if (!d_->format_.is_set())
|
||||
{
|
||||
throw invalid_attribute();
|
||||
}
|
||||
|
|
|
@ -1006,14 +1006,14 @@ void xlsx_producer::write_styles(const relationship & /*rel*/)
|
|||
write_start_element(xmlns, "patternFill");
|
||||
write_attribute("patternType", pattern.type());
|
||||
|
||||
if (pattern.foreground())
|
||||
if (pattern.foreground().is_set())
|
||||
{
|
||||
write_start_element(xmlns, "fgColor");
|
||||
write_color(pattern.foreground().get());
|
||||
write_end_element(xmlns, "fgColor");
|
||||
}
|
||||
|
||||
if (pattern.background())
|
||||
if (pattern.background().is_set())
|
||||
{
|
||||
write_start_element(xmlns, "bgColor");
|
||||
write_color(pattern.background().get());
|
||||
|
@ -1086,7 +1086,7 @@ void xlsx_producer::write_styles(const relationship & /*rel*/)
|
|||
{
|
||||
write_start_element(xmlns, "border");
|
||||
|
||||
if (current_border.diagonal())
|
||||
if (current_border.diagonal().is_set())
|
||||
{
|
||||
auto up = current_border.diagonal().get() == diagonal_direction::both
|
||||
|| current_border.diagonal().get() == diagonal_direction::up;
|
||||
|
@ -1099,19 +1099,19 @@ void xlsx_producer::write_styles(const relationship & /*rel*/)
|
|||
|
||||
for (const auto &side : xlnt::border::all_sides())
|
||||
{
|
||||
if (current_border.side(side))
|
||||
if (current_border.side(side).is_set())
|
||||
{
|
||||
const auto current_side = current_border.side(side).get();
|
||||
|
||||
auto side_name = to_string(side);
|
||||
write_start_element(xmlns, side_name);
|
||||
|
||||
if (current_side.style())
|
||||
if (current_side.style().is_set())
|
||||
{
|
||||
write_attribute("style", current_side.style().get());
|
||||
}
|
||||
|
||||
if (current_side.color())
|
||||
if (current_side.color().is_set())
|
||||
{
|
||||
write_start_element(xmlns, "color");
|
||||
write_color(current_side.color().get());
|
||||
|
@ -1179,17 +1179,17 @@ void xlsx_producer::write_styles(const relationship & /*rel*/)
|
|||
|
||||
write_start_element(xmlns, "alignment");
|
||||
|
||||
if (current_alignment.vertical())
|
||||
if (current_alignment.vertical().is_set())
|
||||
{
|
||||
write_attribute("vertical", current_alignment.vertical().get());
|
||||
}
|
||||
|
||||
if (current_alignment.horizontal())
|
||||
if (current_alignment.horizontal().is_set())
|
||||
{
|
||||
write_attribute("horizontal", current_alignment.horizontal().get());
|
||||
}
|
||||
|
||||
if (current_alignment.rotation())
|
||||
if (current_alignment.rotation().is_set())
|
||||
{
|
||||
write_attribute("textRotation", current_alignment.rotation().get());
|
||||
}
|
||||
|
@ -1199,7 +1199,7 @@ void xlsx_producer::write_styles(const relationship & /*rel*/)
|
|||
write_attribute("wrapText", write_bool(current_alignment.wrap()));
|
||||
}
|
||||
|
||||
if (current_alignment.indent())
|
||||
if (current_alignment.indent().is_set())
|
||||
{
|
||||
write_attribute("indent", current_alignment.indent().get());
|
||||
}
|
||||
|
@ -1239,7 +1239,7 @@ void xlsx_producer::write_styles(const relationship & /*rel*/)
|
|||
write_attribute("numFmtId", current_format_impl.number_format_id.get());
|
||||
write_attribute("fontId", current_format_impl.font_id.get());
|
||||
|
||||
if (current_format_impl.style)
|
||||
if (current_format_impl.style.is_set())
|
||||
{
|
||||
write_attribute("fillId", stylesheet.style_impls.at(current_format_impl.style.get()).fill_id.get());
|
||||
}
|
||||
|
@ -1291,17 +1291,17 @@ void xlsx_producer::write_styles(const relationship & /*rel*/)
|
|||
|
||||
write_start_element(xmlns, "alignment");
|
||||
|
||||
if (current_alignment.vertical())
|
||||
if (current_alignment.vertical().is_set())
|
||||
{
|
||||
write_attribute("vertical", current_alignment.vertical().get());
|
||||
}
|
||||
|
||||
if (current_alignment.horizontal())
|
||||
if (current_alignment.horizontal().is_set())
|
||||
{
|
||||
write_attribute("horizontal", current_alignment.horizontal().get());
|
||||
}
|
||||
|
||||
if (current_alignment.rotation())
|
||||
if (current_alignment.rotation().is_set())
|
||||
{
|
||||
write_attribute("textRotation", current_alignment.rotation().get());
|
||||
}
|
||||
|
@ -1311,7 +1311,7 @@ void xlsx_producer::write_styles(const relationship & /*rel*/)
|
|||
write_attribute("wrapText", write_bool(current_alignment.wrap()));
|
||||
}
|
||||
|
||||
if (current_alignment.indent())
|
||||
if (current_alignment.indent().is_set())
|
||||
{
|
||||
write_attribute("indent", current_alignment.indent().get());
|
||||
}
|
||||
|
@ -1354,7 +1354,7 @@ void xlsx_producer::write_styles(const relationship & /*rel*/)
|
|||
write_attribute("name", current_style.name);
|
||||
write_attribute("xfId", style_index++);
|
||||
|
||||
if (current_style.builtin_id)
|
||||
if (current_style.builtin_id.is_set())
|
||||
{
|
||||
write_attribute("builtinId", current_style.builtin_id.get());
|
||||
}
|
||||
|
@ -1364,7 +1364,7 @@ void xlsx_producer::write_styles(const relationship & /*rel*/)
|
|||
write_attribute("hidden", write_bool(true));
|
||||
}
|
||||
|
||||
if (current_style.custom_builtin)
|
||||
if (current_style.custom_builtin.is_set())
|
||||
{
|
||||
write_attribute("customBuiltin", write_bool(current_style.custom_builtin.get()));
|
||||
}
|
||||
|
|
|
@ -54,7 +54,7 @@ pattern_fill &pattern_fill::foreground(const color &new_foreground)
|
|||
{
|
||||
foreground_ = new_foreground;
|
||||
|
||||
if (!background_)
|
||||
if (!background_.is_set())
|
||||
{
|
||||
background_.set(indexed_color(64));
|
||||
}
|
||||
|
|
|
@ -31,16 +31,18 @@ public:
|
|||
fill = xlnt::pattern_fill().type(xlnt::pattern_fill_type::solid);
|
||||
|
||||
fill = fill.pattern_fill().foreground(xlnt::color::black());
|
||||
TS_ASSERT(fill.pattern_fill().foreground());
|
||||
TS_ASSERT_EQUALS(fill.pattern_fill().foreground().get().rgb().hex_string(), xlnt::color::black().rgb().hex_string());
|
||||
TS_ASSERT(fill.pattern_fill().foreground().is_set());
|
||||
TS_ASSERT_EQUALS(fill.pattern_fill().foreground().get().rgb().hex_string(),
|
||||
xlnt::color::black().rgb().hex_string());
|
||||
|
||||
fill = fill.pattern_fill().background(xlnt::color::green());
|
||||
TS_ASSERT(fill.pattern_fill().background());
|
||||
TS_ASSERT_EQUALS(fill.pattern_fill().background().get().rgb().hex_string(), xlnt::color::green().rgb().hex_string());
|
||||
TS_ASSERT(fill.pattern_fill().background().is_set());
|
||||
TS_ASSERT_EQUALS(fill.pattern_fill().background().get().rgb().hex_string(),
|
||||
xlnt::color::green().rgb().hex_string());
|
||||
|
||||
const auto &const_fill = fill;
|
||||
TS_ASSERT(const_fill.pattern_fill().foreground());
|
||||
TS_ASSERT(const_fill.pattern_fill().background());
|
||||
TS_ASSERT(const_fill.pattern_fill().foreground().is_set());
|
||||
TS_ASSERT(const_fill.pattern_fill().background().is_set());
|
||||
}
|
||||
|
||||
void test_comparison()
|
||||
|
|
|
@ -692,7 +692,7 @@ worksheet workbook::create_sheet()
|
|||
return worksheet(&d_->worksheets_.back());
|
||||
}
|
||||
|
||||
void workbook::copy_sheet(worksheet to_copy)
|
||||
worksheet workbook::copy_sheet(worksheet to_copy)
|
||||
{
|
||||
if (to_copy.d_->parent_ != this) throw invalid_parameter();
|
||||
|
||||
|
@ -700,9 +700,11 @@ void workbook::copy_sheet(worksheet to_copy)
|
|||
auto new_sheet = create_sheet();
|
||||
impl.title_ = new_sheet.title();
|
||||
*new_sheet.d_ = impl;
|
||||
|
||||
return new_sheet;
|
||||
}
|
||||
|
||||
void workbook::copy_sheet(worksheet to_copy, std::size_t index)
|
||||
worksheet workbook::copy_sheet(worksheet to_copy, std::size_t index)
|
||||
{
|
||||
copy_sheet(to_copy);
|
||||
|
||||
|
@ -717,6 +719,8 @@ void workbook::copy_sheet(worksheet to_copy, std::size_t index)
|
|||
d_->worksheets_.insert(iter, d_->worksheets_.back());
|
||||
d_->worksheets_.pop_back();
|
||||
}
|
||||
|
||||
return sheet_by_index(index);
|
||||
}
|
||||
|
||||
std::size_t workbook::index(worksheet ws)
|
||||
|
|
Loading…
Reference in New Issue
Block a user