xlnt/include/xlnt/cell/cell.hpp

713 lines
20 KiB
C++
Raw Permalink Normal View History

// Copyright (c) 2014-2021 Thomas Fussell
// Copyright (c) 2010-2015 openpyxl
2014-06-06 04:19:31 +08:00
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2014-06-06 04:19:31 +08:00
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE
//
// @license: http://www.opensource.org/licenses/mit-license.php
// @author: see AUTHORS file
2016-11-20 14:01:32 +08:00
2014-05-21 22:20:30 +08:00
#pragma once
#include <memory>
#include <string>
2014-05-21 22:20:30 +08:00
#include <unordered_map>
2016-11-20 14:01:32 +08:00
#include <xlnt/xlnt_config.hpp>
#include <xlnt/cell/cell_type.hpp>
#include <xlnt/cell/index_types.hpp>
#include <xlnt/cell/rich_text.hpp>
2014-05-22 05:48:51 +08:00
2014-05-21 22:20:30 +08:00
namespace xlnt {
2015-10-19 03:30:46 +08:00
enum class calendar;
2015-10-30 01:46:56 +08:00
class alignment;
class base_format;
2015-10-30 01:46:56 +08:00
class border;
2014-05-21 22:20:30 +08:00
class cell_reference;
2014-07-26 04:39:25 +08:00
class comment;
2015-10-30 01:46:56 +08:00
class fill;
class font;
2016-05-15 01:57:07 +08:00
class format;
2015-10-30 01:46:56 +08:00
class number_format;
class protection;
class range;
class relationship;
2016-06-11 01:40:50 +08:00
class style;
2016-05-12 07:24:53 +08:00
class workbook;
2014-05-21 22:20:30 +08:00
class worksheet;
2016-08-05 13:52:05 +08:00
class xlsx_consumer;
class xlsx_producer;
class phonetic_pr;
2014-05-31 06:42:25 +08:00
2014-06-07 23:49:19 +08:00
struct date;
struct datetime;
struct time;
2014-07-20 04:59:05 +08:00
struct timedelta;
2014-06-07 23:49:19 +08:00
2016-12-04 20:29:10 +08:00
namespace detail {
2016-08-05 13:52:05 +08:00
class xlsx_consumer;
class xlsx_producer;
2016-11-20 14:01:32 +08:00
2016-12-04 20:29:10 +08:00
struct cell_impl;
2016-08-05 13:52:05 +08:00
} // namespace detail
2014-07-20 02:43:48 +08:00
2014-05-21 22:20:30 +08:00
/// <summary>
2017-01-27 08:57:19 +08:00
/// Describes a unit of data in a worksheet at a specific coordinate and its
/// associated properties.
2014-05-21 22:20:30 +08:00
/// </summary>
/// <remarks>
/// Properties of interest include style, type, value, and address.
/// The Cell class is required to know its value and type, display options,
/// and any other features of an Excel cell.Utilities for referencing
/// cells using Excel's 'A1' column/row nomenclature are also provided.
/// </remarks>
class XLNT_API cell
2014-05-21 22:20:30 +08:00
{
2015-11-04 07:26:33 +08:00
public:
2016-11-20 14:01:32 +08:00
/// <summary>
/// Alias xlnt::cell_type to xlnt::cell::type since it looks nicer.
/// </summary>
using type = cell_type;
2016-01-18 14:23:31 +08:00
2015-10-30 01:46:56 +08:00
/// <summary>
2017-01-27 08:57:19 +08:00
/// Returns a map of error strings such as \#DIV/0! and their associated indices.
2015-10-30 01:46:56 +08:00
/// </summary>
static const std::unordered_map<std::string, int> &error_codes();
2016-12-04 20:29:10 +08:00
2016-11-20 14:01:32 +08:00
/// <summary>
/// Default copy constructor.
/// </summary>
cell(const cell &) = default;
// value
2015-10-30 01:46:56 +08:00
/// <summary>
2017-01-27 08:57:19 +08:00
/// Returns true if value has been set and has not been cleared using cell::clear_value().
2015-10-30 01:46:56 +08:00
/// </summary>
bool has_value() const;
2015-11-04 07:26:33 +08:00
/// <summary>
2017-01-27 08:57:19 +08:00
/// Returns the value of this cell as an instance of type T.
2015-11-04 07:26:33 +08:00
/// 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.
2015-11-04 07:26:33 +08:00
/// </summary>
template <typename T>
T value() const;
2015-11-04 07:26:33 +08:00
/// <summary>
2017-01-27 08:57:19 +08:00
/// Makes this cell have a value of type null.
2015-11-04 07:26:33 +08:00
/// All other cell attributes are retained.
/// </summary>
void clear_value();
/// <summary>
/// Sets the type of this cell to null.
/// </summary>
void value(std::nullptr_t);
/// <summary>
/// Sets the value of this cell to the given boolean value.
/// </summary>
void value(bool boolean_value);
2015-11-04 07:26:33 +08:00
/// <summary>
2017-01-27 08:57:19 +08:00
/// Sets the value of this cell to the given value.
2016-12-04 20:29:10 +08:00
/// </summary>
void value(int int_value);
/// <summary>
/// Sets the value of this cell to the given value.
/// </summary>
void value(unsigned int int_value);
/// <summary>
/// Sets the value of this cell to the given value.
/// </summary>
void value(long long int int_value);
/// <summary>
/// Sets the value of this cell to the given value.
/// </summary>
void value(unsigned long long int int_value);
/// <summary>
/// Sets the value of this cell to the given value.
/// </summary>
void value(float float_value);
/// <summary>
/// Sets the value of this cell to the given value.
/// </summary>
void value(double float_value);
/// <summary>
/// Sets the value of this cell to the given value.
/// </summary>
void value(const date &date_value);
/// <summary>
/// Sets the value of this cell to the given value.
/// </summary>
void value(const time &time_value);
/// <summary>
/// Sets the value of this cell to the given value.
/// </summary>
void value(const datetime &datetime_value);
/// <summary>
/// Sets the value of this cell to the given value.
/// </summary>
void value(const timedelta &timedelta_value);
/// <summary>
/// Sets the value of this cell to the given value.
/// </summary>
void value(const std::string &string_value);
/// <summary>
/// Sets the value of this cell to the given value.
/// </summary>
void value(const char *string_value);
/// <summary>
/// Sets the value of this cell to the given value.
/// </summary>
void value(const rich_text &text_value);
/// <summary>
/// Sets the value and formatting of this cell to that of other_cell.
/// </summary>
void value(const cell other_cell);
/// <summary>
2017-01-27 08:57:19 +08:00
/// 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);
2015-11-04 07:26:33 +08:00
/// <summary>
2017-01-27 08:57:19 +08:00
/// Returns the type of this cell.
2015-11-04 07:26:33 +08:00
/// </summary>
type data_type() const;
2016-01-18 14:23:31 +08:00
2015-11-04 07:26:33 +08:00
/// <summary>
2017-01-27 08:57:19 +08:00
/// 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.
2015-11-04 07:26:33 +08:00
/// </summary>
void data_type(type t);
2015-10-30 01:46:56 +08:00
// properties
2015-10-30 01:46:56 +08:00
/// <summary>
/// There's no reason to keep a cell which has no value and is not a placeholder.
2017-01-27 08:57:19 +08:00
/// Returns true if this cell has no value, style, isn't merged, etc.
2015-10-30 01:46:56 +08:00
/// </summary>
bool garbage_collectible() const;
2015-10-30 01:46:56 +08:00
/// <summary>
2017-01-27 08:57:19 +08:00
/// Returns true iff this cell's number format matches a date format.
2015-10-30 01:46:56 +08:00
/// </summary>
bool is_date() const;
// position
2016-01-18 14:23:31 +08:00
2015-11-04 07:26:33 +08:00
/// <summary>
2017-01-27 08:57:19 +08:00
/// Returns a cell_reference that points to the location of this cell.
2015-11-04 07:26:33 +08:00
/// </summary>
cell_reference reference() const;
2016-01-18 14:23:31 +08:00
2015-11-04 07:26:33 +08:00
/// <summary>
2017-01-27 08:57:19 +08:00
/// Returns the column of this cell.
2015-11-04 07:26:33 +08:00
/// </summary>
column_t column() const;
2016-01-18 14:23:31 +08:00
2015-11-04 07:26:33 +08:00
/// <summary>
/// Returns the numeric index (A == 1) of the column of this cell.
/// </summary>
column_t::index_t column_index() const;
/// <summary>
2017-01-27 08:57:19 +08:00
/// Returns the row of this cell.
2015-11-04 07:26:33 +08:00
/// </summary>
row_t row() const;
2016-01-18 14:23:31 +08:00
2015-11-04 07:26:33 +08:00
/// <summary>
2017-01-27 08:57:19 +08:00
/// Returns the location of this cell as an ordered pair (left, top).
2015-11-04 07:26:33 +08:00
/// </summary>
std::pair<int, int> anchor() const;
// hyperlink
2016-01-18 14:23:31 +08:00
2015-11-04 07:26:33 +08:00
/// <summary>
/// Returns the relationship of this cell's hyperlink.
2015-11-04 07:26:33 +08:00
/// </summary>
class hyperlink hyperlink() const;
2016-01-18 14:23:31 +08:00
/// <summary>
/// Adds a hyperlink to this cell pointing to the URI of the given value and sets
/// the text value of the cell to the given parameter.
/// </summary>
void hyperlink(const std::string &url, const std::string &display = "");
/// <summary>
/// Adds an internal hyperlink to this cell pointing to the given cell.
/// </summary>
void hyperlink(xlnt::cell target, const std::string &display = "");
2016-01-18 14:23:31 +08:00
/// <summary>
/// Adds an internal hyperlink to this cell pointing to the given range.
/// </summary>
void hyperlink(xlnt::range target, const std::string &display = "");
2015-11-04 07:26:33 +08:00
/// <summary>
2017-01-27 08:57:19 +08:00
/// Returns true if this cell has a hyperlink set.
2015-11-04 07:26:33 +08:00
/// </summary>
2014-06-11 05:12:15 +08:00
bool has_hyperlink() const;
2016-12-03 23:05:35 +08:00
// computed formatting
2016-12-03 23:05:35 +08:00
/// <summary>
2017-01-27 08:57:19 +08:00
/// 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.
2016-12-03 23:05:35 +08:00
/// </summary>
class alignment computed_alignment() const;
2016-01-18 14:23:31 +08:00
2016-12-03 23:05:35 +08:00
/// <summary>
2017-01-27 08:57:19 +08:00
/// 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.
2016-12-03 23:05:35 +08:00
/// </summary>
class border computed_border() const;
2016-08-05 13:52:05 +08:00
2016-12-03 23:05:35 +08:00
/// <summary>
2017-01-27 08:57:19 +08:00
/// 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.
2016-12-03 23:05:35 +08:00
/// </summary>
class fill computed_fill() const;
2016-12-03 23:05:35 +08:00
/// <summary>
2017-01-27 08:57:19 +08:00
/// 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.
2016-12-03 23:05:35 +08:00
/// </summary>
class font computed_font() const;
2016-12-03 23:05:35 +08:00
/// <summary>
2017-01-27 08:57:19 +08:00
/// 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.
2016-12-03 23:05:35 +08:00
/// </summary>
class number_format computed_number_format() const;
2016-12-03 23:05:35 +08:00
/// <summary>
2017-01-27 08:57:19 +08:00
/// 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.
2016-12-03 23:05:35 +08:00
/// </summary>
class protection computed_protection() const;
// format
2016-06-11 01:40:50 +08:00
/// <summary>
2017-01-27 08:57:19 +08:00
/// Returns true if this cell has had a format applied to it.
2016-06-11 01:40:50 +08:00
/// </summary>
bool has_format() const;
2016-06-11 01:40:50 +08:00
/// <summary>
2017-01-27 08:57:19 +08:00
/// Returns the format applied to this cell. If this cell has no
/// format, an invalid_attribute exception will be thrown.
2016-06-11 01:40:50 +08:00
/// </summary>
const class format format() const;
2016-12-04 20:29:10 +08:00
/// <summary>
/// Applies the cell-level formatting of new_format to this cell.
/// </summary>
void format(const class format new_format);
2016-12-04 20:29:10 +08:00
/// <summary>
2017-01-27 08:57:19 +08:00
/// Removes the cell-level formatting from this cell.
2016-12-04 20:29:10 +08:00
/// 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>
void clear_format();
2016-01-18 14:23:31 +08:00
2015-11-04 07:26:33 +08:00
/// <summary>
/// Returns the number format of this cell.
2015-11-04 07:26:33 +08:00
/// </summary>
2016-12-03 23:05:35 +08:00
class number_format number_format() const;
2016-12-04 20:29:10 +08:00
/// <summary>
/// Creates a new format in the workbook, sets its number_format
/// to the given format, and applies the format to this cell.
/// </summary>
void number_format(const class number_format &format);
2016-01-18 14:23:31 +08:00
2015-11-04 07:26:33 +08:00
/// <summary>
/// Returns the font applied to the text in this cell.
2015-11-04 07:26:33 +08:00
/// </summary>
2016-12-03 23:05:35 +08:00
class font font() const;
2016-01-18 14:23:31 +08:00
2016-12-04 20:29:10 +08:00
/// <summary>
/// Creates a new format in the workbook, sets its font
/// to the given font, and applies the format to this cell.
/// </summary>
void font(const class font &font_);
2016-01-18 14:23:31 +08:00
2015-11-04 07:26:33 +08:00
/// <summary>
/// Returns the fill applied to this cell.
2015-11-04 07:26:33 +08:00
/// </summary>
2016-12-03 23:05:35 +08:00
class fill fill() const;
2016-01-18 14:23:31 +08:00
2016-12-04 20:29:10 +08:00
/// <summary>
/// Creates a new format in the workbook, sets its fill
/// to the given fill, and applies the format to this cell.
/// </summary>
void fill(const class fill &fill_);
2016-01-18 14:23:31 +08:00
2015-11-04 07:26:33 +08:00
/// <summary>
/// Returns the border of this cell.
2015-11-04 07:26:33 +08:00
/// </summary>
2016-12-03 23:05:35 +08:00
class border border() const;
2016-01-18 14:23:31 +08:00
2016-12-04 20:29:10 +08:00
/// <summary>
/// Creates a new format in the workbook, sets its border
/// to the given border, and applies the format to this cell.
/// </summary>
void border(const class border &border_);
2016-01-18 14:23:31 +08:00
2015-11-04 07:26:33 +08:00
/// <summary>
/// Returns the alignment of the text in this cell.
2015-11-04 07:26:33 +08:00
/// </summary>
2016-12-03 23:05:35 +08:00
class alignment alignment() const;
2016-01-18 14:23:31 +08:00
2016-12-04 20:29:10 +08:00
/// <summary>
/// Creates a new format in the workbook, sets its alignment
/// to the given alignment, and applies the format to this cell.
/// </summary>
void alignment(const class alignment &alignment_);
2016-01-18 14:23:31 +08:00
2015-11-04 07:26:33 +08:00
/// <summary>
/// Returns the protection of this cell.
2015-11-04 07:26:33 +08:00
/// </summary>
2016-12-03 23:05:35 +08:00
class protection protection() const;
2016-01-18 14:23:31 +08:00
2016-12-03 23:05:35 +08:00
/// <summary>
/// Creates a new format in the workbook, sets its protection
/// to the given protection, and applies the format to this cell.
/// </summary>
void protection(const class protection &protection_);
2016-01-18 14:23:31 +08:00
2016-12-04 20:29:10 +08:00
// style
/// <summary>
/// Returns true if this cell has had a style applied to it.
/// </summary>
bool has_style() const;
/// <summary>
/// Returns a wrapper pointing to the named style applied to this cell.
/// </summary>
class style style();
/// <summary>
/// Returns a wrapper pointing to the named style applied to this cell.
/// </summary>
const class style style() const;
2016-12-04 20:29:10 +08:00
/// <summary>
2017-01-27 08:57:19 +08:00
/// Sets the named style applied to this cell to a style named style_name.
/// Equivalent to style(new_style.name()).
2016-12-04 20:29:10 +08:00
/// </summary>
void style(const class style &new_style);
/// <summary>
/// Sets the named style applied to this cell to a style named style_name.
/// If this style has not been previously created in the workbook, a
/// key_not_found exception will be thrown.
/// </summary>
void style(const std::string &style_name);
/// <summary>
/// Removes the named style from this cell.
/// An invalid_attribute exception will be thrown if this cell has no style.
/// This will not affect the cell format of the cell.
/// </summary>
void clear_style();
// formula
2016-12-04 20:29:10 +08:00
/// <summary>
/// Returns the string representation of the formula applied to this cell.
/// </summary>
std::string formula() const;
2016-12-04 20:29:10 +08:00
/// <summary>
/// Sets the formula of this cell to the given value.
/// This formula string should begin with '='.
/// </summary>
void formula(const std::string &formula);
2016-12-04 20:29:10 +08:00
/// <summary>
/// Removes the formula from this cell. After this is called, has_formula() will return false.
/// </summary>
2014-07-25 05:31:46 +08:00
void clear_formula();
2016-12-04 20:29:10 +08:00
/// <summary>
/// Returns true if this cell has had a formula applied to it.
/// </summary>
2014-07-25 05:31:46 +08:00
bool has_formula() const;
2014-05-31 06:42:25 +08:00
// printing
2015-10-17 06:35:11 +08:00
/// <summary>
/// Returns a string representing the value of this cell. If the data type is not a string,
/// it will be converted according to the number format.
/// </summary>
std::string to_string() const;
// merging
2016-01-18 14:23:31 +08:00
2015-11-04 07:26:33 +08:00
/// <summary>
2017-01-27 08:57:19 +08:00
/// Returns true iff this cell has been merged with one or more
2015-11-04 07:26:33 +08:00
/// surrounding cells.
/// </summary>
bool is_merged() const;
2016-01-18 14:23:31 +08:00
2015-11-04 07:26:33 +08:00
/// <summary>
2017-01-27 08:57:19 +08:00
/// Makes this a merged cell iff merged is true.
2015-11-04 07:26:33 +08:00
/// Generally, this shouldn't be called directly. Instead,
/// use worksheet::merge_cells on its parent worksheet.
/// </summary>
void merged(bool merged);
// phonetics
/// <summary>
/// Returns true if this cell is set to show phonetic information.
/// </summary>
bool phonetics_visible() const;
/// <summary>
/// Enables the display of phonetic information on this cell.
/// </summary>
void show_phonetics(bool phonetics);
2015-11-04 07:26:33 +08:00
/// <summary>
2017-01-27 08:57:19 +08:00
/// Returns the error string that is stored in this cell.
2015-11-04 07:26:33 +08:00
/// </summary>
std::string error() const;
2016-01-18 14:23:31 +08:00
2015-11-04 07:26:33 +08:00
/// <summary>
2017-01-27 08:57:19 +08:00
/// Directly assigns the value of this cell to be the given error.
2015-11-04 07:26:33 +08:00
/// </summary>
void error(const std::string &error);
2015-11-04 07:26:33 +08:00
/// <summary>
2017-01-27 08:57:19 +08:00
/// Returns a cell from this cell's parent workbook at
2015-11-04 07:26:33 +08:00
/// a relative offset given by the parameters.
/// </summary>
cell offset(int column, int row);
2016-01-18 14:23:31 +08:00
2015-11-04 07:26:33 +08:00
/// <summary>
2017-01-27 08:57:19 +08:00
/// Returns the worksheet that owns this cell.
2015-11-04 07:26:33 +08:00
/// </summary>
class worksheet worksheet();
2016-01-18 14:23:31 +08:00
2015-11-04 07:26:33 +08:00
/// <summary>
2017-01-27 08:57:19 +08:00
/// Returns the worksheet that owns this cell.
2015-11-04 07:26:33 +08:00
/// </summary>
const class worksheet worksheet() const;
2016-05-12 07:24:53 +08:00
/// <summary>
2017-01-27 08:57:19 +08:00
/// Returns the workbook of the worksheet that owns this cell.
/// </summary>
class workbook &workbook();
2016-05-12 07:24:53 +08:00
/// <summary>
2017-01-27 08:57:19 +08:00
/// Returns the workbook of the worksheet that owns this cell.
/// </summary>
const class workbook &workbook() const;
2015-11-04 07:26:33 +08:00
/// <summary>
2017-01-27 08:57:19 +08:00
/// Returns the base date of the parent workbook.
2015-11-04 07:26:33 +08:00
/// </summary>
calendar base_date() const;
2015-11-23 01:41:27 +08:00
/// <summary>
2017-01-27 08:57:19 +08:00
/// Returns to_check after verifying and fixing encoding, size, and illegal characters.
2015-11-23 01:41:27 +08:00
/// </summary>
std::string check_string(const std::string &to_check);
2016-10-29 22:23:04 +08:00
// comment
/// <summary>
2017-01-27 08:57:19 +08:00
/// Returns true if this cell has a comment applied.
2016-10-29 22:23:04 +08:00
/// </summary>
bool has_comment();
/// <summary>
2017-01-27 08:57:19 +08:00
/// Deletes the comment applied to this cell if it exists.
2016-10-29 22:23:04 +08:00
/// </summary>
void clear_comment();
/// <summary>
2017-01-27 08:57:19 +08:00
/// Gets the comment applied to this cell.
2016-10-29 22:23:04 +08:00
/// </summary>
2016-10-29 22:36:46 +08:00
class comment comment();
2016-10-29 22:23:04 +08:00
/// <summary>
2017-01-27 08:57:19 +08:00
/// Creates a new comment with the given text and optional author and
/// applies it to the cell.
/// </summary>
2017-01-27 08:57:19 +08:00
void comment(const std::string &text,
const std::string &author = "Microsoft Office User");
/// <summary>
2017-01-27 08:57:19 +08:00
/// Creates a new comment with the given text, formatting, and optional
/// author and applies it to the cell.
/// </summary>
2017-01-27 08:57:19 +08:00
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.
2016-10-29 22:23:04 +08:00
/// </summary>
void comment(const class comment &new_comment);
2017-01-27 08:57:19 +08:00
/// <summary>
/// Returns the width of this cell in pixels.
/// </summary>
double width() const;
2017-01-27 08:57:19 +08:00
/// <summary>
/// Returns the height of this cell in pixels.
/// </summary>
double height() const;
// operators
2016-01-18 14:23:31 +08:00
2015-11-04 07:26:33 +08:00
/// <summary>
2017-01-27 08:57:19 +08:00
/// Makes this cell interally point to rhs.
/// The cell data originally pointed to by this cell will be unchanged.
2015-11-04 07:26:33 +08:00
/// </summary>
2014-05-21 22:20:30 +08:00
cell &operator=(const cell &rhs);
2015-11-04 07:26:33 +08:00
/// <summary>
2017-01-27 08:57:19 +08:00
/// Returns true if this cell the same cell as comparand (compared by reference).
2015-11-04 07:26:33 +08:00
/// </summary>
2014-06-14 03:05:24 +08:00
bool operator==(const cell &comparand) const;
2016-01-18 14:23:31 +08:00
2015-11-04 07:26:33 +08:00
/// <summary>
/// Returns false if this cell the same cell as comparand (compared by reference).
2015-11-04 07:26:33 +08:00
/// </summary>
bool operator!=(const cell &comparand) const;
2014-05-31 06:42:25 +08:00
2015-11-04 07:26:33 +08:00
private:
friend class style;
friend class worksheet;
2016-12-04 20:29:10 +08:00
friend class detail::xlsx_consumer;
friend class detail::xlsx_producer;
2015-10-19 03:30:46 +08:00
friend struct detail::cell_impl;
2016-12-04 20:29:10 +08:00
/// <summary>
/// Returns a non-const reference to the format of this cell.
/// This is for internal use only.
/// </summary>
class format modifiable_format();
2016-11-20 14:01:32 +08:00
/// <summary>
2017-01-27 08:57:19 +08:00
/// Delete the default zero-argument constructor.
2016-11-20 14:01:32 +08:00
/// </summary>
cell() = delete;
2015-11-04 07:26:33 +08:00
/// <summary>
/// Private constructor to create a cell from its implementation.
/// </summary>
2014-05-31 06:42:25 +08:00
cell(detail::cell_impl *d);
2016-01-18 14:23:31 +08:00
2015-11-04 07:26:33 +08:00
/// <summary>
/// A pointer to this cell's implementation.
/// </summary>
2014-05-31 06:42:25 +08:00
detail::cell_impl *d_;
2014-05-21 22:20:30 +08:00
};
/// <summary>
2017-01-27 08:57:19 +08:00
/// Returns true if this cell is uninitialized.
/// </summary>
XLNT_API bool operator==(std::nullptr_t, const cell &cell);
/// <summary>
/// Returns true if this cell is uninitialized.
/// </summary>
XLNT_API bool operator==(const cell &cell, std::nullptr_t);
/// <summary>
/// Convenience function for writing cell to an ostream.
/// Uses cell::to_string() internally.
/// </summary>
XLNT_API std::ostream &operator<<(std::ostream &stream, const xlnt::cell &cell);
template <>
2017-04-23 23:53:52 +08:00
bool cell::value<bool>() const;
template <>
2017-04-23 23:53:52 +08:00
int cell::value<int>() const;
template <>
2017-04-23 23:53:52 +08:00
unsigned int cell::value<unsigned int>() const;
template <>
2017-04-23 23:53:52 +08:00
long long int cell::value<long long int>() const;
template <>
2017-04-23 23:53:52 +08:00
unsigned long long cell::value<unsigned long long int>() const;
template <>
2017-04-23 23:53:52 +08:00
float cell::value<float>() const;
template <>
2017-04-23 23:53:52 +08:00
double cell::value<double>() const;
template <>
2017-04-23 23:53:52 +08:00
date cell::value<date>() const;
template <>
2017-04-23 23:53:52 +08:00
time cell::value<time>() const;
template <>
2017-04-23 23:53:52 +08:00
datetime cell::value<datetime>() const;
template <>
2017-04-23 23:53:52 +08:00
timedelta cell::value<timedelta>() const;
template <>
2017-04-23 23:53:52 +08:00
std::string cell::value<std::string>() const;
template <>
2017-04-23 23:53:52 +08:00
rich_text cell::value<rich_text>() const;
2014-05-21 22:20:30 +08:00
} // namespace xlnt