mirror of
https://github.com/tfussell/xlnt.git
synced 2024-03-22 13:11:17 +08:00
not done yet. I can't beleive how complicated this is
This commit is contained in:
parent
720edc143f
commit
9bd6e92297
|
@ -38,6 +38,7 @@ enum class calendar;
|
|||
class alignment;
|
||||
class border;
|
||||
class cell_reference;
|
||||
class cell_style;
|
||||
class comment;
|
||||
class fill;
|
||||
class font;
|
||||
|
@ -194,21 +195,20 @@ public:
|
|||
bool has_style() const;
|
||||
|
||||
/// <summary>
|
||||
/// Return the index of this cell's style in its parent workbook.
|
||||
/// This is also the index of the style in the stylesheet XML, xl/styles.xml.
|
||||
/// Return a reference to the style applied to this cell.
|
||||
/// </summary>
|
||||
std::size_t get_style_id() const;
|
||||
cell_style &get_style();
|
||||
|
||||
/// <summary>
|
||||
/// Set the style index of this cell. This should be an existing style in
|
||||
/// the parent workbook.
|
||||
/// Return a reference to the style applied to this cell.
|
||||
/// </summary>
|
||||
void set_style_id(std::size_t style_id);
|
||||
const cell_style &get_style() const;
|
||||
|
||||
/// <summary>
|
||||
/// Return the number format of this cell.
|
||||
/// </summary>
|
||||
const number_format &get_number_format() const;
|
||||
|
||||
void set_number_format(const number_format &format);
|
||||
|
||||
/// <summary>
|
||||
|
@ -246,20 +246,6 @@ public:
|
|||
|
||||
void set_protection(const protection &protection_);
|
||||
|
||||
void set_pivot_button(bool b);
|
||||
|
||||
/// <summary>
|
||||
/// Return true iff pivot button?
|
||||
/// </summary>
|
||||
bool pivot_button() const;
|
||||
|
||||
void set_quote_prefix(bool b);
|
||||
|
||||
/// <summary>
|
||||
/// Return true iff quote prefix?
|
||||
/// </summary>
|
||||
bool quote_prefix() const;
|
||||
|
||||
// comment
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -34,6 +34,7 @@ namespace xlnt {
|
|||
|
||||
class alignment;
|
||||
class border;
|
||||
class cell_style;
|
||||
class color;
|
||||
class conditional_format;
|
||||
class fill;
|
||||
|
@ -43,7 +44,6 @@ class named_style;
|
|||
class number_format;
|
||||
class protection;
|
||||
class side;
|
||||
class style;
|
||||
class xml_document;
|
||||
class xml_node;
|
||||
|
||||
|
@ -71,7 +71,7 @@ public:
|
|||
/// Populate parameter xml with an XML tree representing the styles contained in the workbook
|
||||
/// given in the constructor.
|
||||
/// </summary>
|
||||
xml_document write_stylesheet() const;
|
||||
xml_document write_stylesheet();
|
||||
|
||||
// TODO: These need to be public for unit tests. Could also make test class a friend?
|
||||
// private:
|
||||
|
@ -131,59 +131,29 @@ public:
|
|||
static conditional_format read_conditional_format(const xml_node &conditional_formats_node);
|
||||
|
||||
/// <summary>
|
||||
/// Read and return a pair containing a name and corresponding style from named_style_node.
|
||||
/// Read a single format from the given node. In styles.xml, this is an "xf" element.
|
||||
/// A format has an optional border id, fill id, font id, and number format id where
|
||||
/// each id is an index in the corresponding list of borders, etc. A style also has
|
||||
/// optional alignment and protection children. A style also defines whether each of
|
||||
/// these is "applied". For example, a style with a defined font id, font=# but with
|
||||
/// "applyFont=0" will not use the font in formatting.
|
||||
/// </summary>
|
||||
static std::pair<std::string, style> read_named_style(const xml_node &named_style_node);
|
||||
|
||||
//
|
||||
// Static element writers (i.e. writers that don't use internal state)
|
||||
//
|
||||
cell_style read_cell_style(const xml_node &style_node);
|
||||
|
||||
/// <summary>
|
||||
/// Build and return an xml tree representing alignment_.
|
||||
/// Read a single named style from the given named_style_node. In styles.xml, this is a
|
||||
/// (confusingly named) "cellStyle" element. This node defines the name, whether it is
|
||||
/// built-in and an xfId which is the index of an element in cellStyleXfs which should
|
||||
/// be provided as the style_node parameter (cellStyleXfs itself, not the child xf node).
|
||||
/// </summary>
|
||||
static xml_node write_alignment(const alignment &alignment_);
|
||||
|
||||
/// <summary>
|
||||
/// Build and return an xml tree representing border_.
|
||||
/// </summary>
|
||||
static xml_node write_border(const border &border_);
|
||||
|
||||
/// <summary>
|
||||
/// Build and return an xml tree representing conditional_format_.
|
||||
/// </summary>
|
||||
static xml_node write_conditional_format(const conditional_format &conditional_format_);
|
||||
|
||||
/// <summary>
|
||||
/// Build and return an xml tree representing fill_.
|
||||
/// </summary>
|
||||
static xml_node write_fill(const fill &fill_);
|
||||
|
||||
/// <summary>
|
||||
/// Build and return an xml tree representing font_.
|
||||
/// </summary>
|
||||
static xml_node write_font(const font &font_);
|
||||
|
||||
/// <summary>
|
||||
/// Build and return two xml trees, first=cell style and second=named style, representing named_style_.
|
||||
/// </summary>
|
||||
static std::pair<xml_node, xml_node> write_named_style(const named_style &named_style_);
|
||||
|
||||
/// <summary>
|
||||
/// Build an xml tree representing all named styles in workbook into named_styles_node and cell_styles_node.
|
||||
/// Returns true on success.
|
||||
/// </summary>
|
||||
static std::pair<xml_node, xml_node> write_named_styles();
|
||||
|
||||
/// <summary>
|
||||
/// Build and return an xml tree representing number_format_.
|
||||
/// </summary>
|
||||
static xml_node write_number_format(const number_format &number_format_);
|
||||
named_style read_named_style(const xml_node &named_style_node, const xml_node &style_parent_node);
|
||||
|
||||
//
|
||||
// Non-static element readers (i.e. readers that modify internal state)
|
||||
//
|
||||
|
||||
bool read_number_formats(const xml_node &number_formats_node);
|
||||
|
||||
/// <summary>
|
||||
/// Read all borders from borders_node and add them to workbook.
|
||||
/// Return true on success.
|
||||
|
@ -208,37 +178,23 @@ public:
|
|||
/// </summary>
|
||||
bool read_colors(const xml_node &colors_node);
|
||||
|
||||
/// <summary>
|
||||
/// Read all cell styles from cell_styles_node and add them to workbook.
|
||||
/// Return true on success.
|
||||
/// </summary>
|
||||
bool read_cell_styles(const xml_node &cell_styles_node);
|
||||
|
||||
/// <summary>
|
||||
/// Read all named styles from named_style_node and cell_styles_node and add them to workbook.
|
||||
/// Return true on success.
|
||||
/// </summary>
|
||||
bool read_named_styles(const xml_node &named_styles_node);
|
||||
bool read_named_styles(const xml_node &named_styles_node, const xml_node &cell_styles_node);
|
||||
|
||||
/// <summary>
|
||||
/// Read all borders from number_formats_node and add them to workbook.
|
||||
/// Return true on success.
|
||||
/// </summary>
|
||||
bool read_number_formats(const xml_node &number_formats_node);
|
||||
|
||||
/// <summary>
|
||||
/// Read a single format from the given node. In styles.xml, this is an "xf" element.
|
||||
/// A format has an optional border id, fill id, font id, and number format id where
|
||||
/// each id is an index in the corresponding list of borders, etc. A style also has
|
||||
/// optional alignment and protection children. A style also defines whether each of
|
||||
/// these is "applied". For example, a style with a defined font id, font=# but with
|
||||
/// "applyFont=0" will not use the font in formatting.
|
||||
/// </summary>
|
||||
format read_format(const xml_node &format_node);
|
||||
|
||||
/// <summary>
|
||||
/// Read a single style from the given node. In styles.xml, this is an "xf" element.
|
||||
/// A style has an optional border id, fill id, font id, and number format id where
|
||||
/// each id is an index in the corresponding list of borders, etc. A style also has
|
||||
/// optional alignment and protection children. A style also defines whether each of
|
||||
/// these is "applied". For example, a style with a defined font id, font=# but with
|
||||
/// "applyFont=0" will not use the font in formatting.
|
||||
/// </summary>
|
||||
style read_style(const xml_node &style_node);
|
||||
bool read_stylesheet(const xml_node &number_formats_node);
|
||||
|
||||
//
|
||||
// Non-static element writers (i.e. writers that modify internal workbook)
|
||||
|
@ -272,19 +228,47 @@ public:
|
|||
/// Build an xml tree representing all number formats in workbook into number_formats_node.
|
||||
/// Returns true on success.
|
||||
/// </summary>
|
||||
bool write_number_formats(xml_node fonts_node) const;
|
||||
bool write_number_formats(xml_node &number_formats_node) const;
|
||||
|
||||
bool write_style_common(const alignment &style_alignment, const border &style_border, const fill &style_fill, const font &style_font, const number_format &style_number_format, const protection &style_protection, xml_node xf_node) const;
|
||||
|
||||
/// <summary>
|
||||
/// Build an xml tree representing the given style into style_node.
|
||||
/// Returns true on success.
|
||||
/// </summary>
|
||||
bool write_style(const style &style_, xml_node &style_node) const;
|
||||
bool write_cell_style(const cell_style &style, xml_node &style_node) const;
|
||||
|
||||
/// <summary>
|
||||
/// Build an xml tree representing the given style into style_node.
|
||||
/// Returns true on success.
|
||||
/// </summary>
|
||||
bool write_cell_styles(xml_node &styles_node) const;
|
||||
|
||||
/// <summary>
|
||||
/// Build an xml tree representing the given style into cell_styles_node and styles_node.
|
||||
/// Returns true on success.
|
||||
/// </summary>
|
||||
bool write_named_style(const named_style &style, xml_node &cell_styles_node) const;
|
||||
|
||||
bool write_named_styles(xml_node &cell_styles_node, xml_node &styles_node) const;
|
||||
|
||||
bool write_colors(xml_node &colors_node) const;
|
||||
|
||||
private:
|
||||
void initialize_vectors();
|
||||
|
||||
/// <summary>
|
||||
/// Set in the constructor, this workbook is used as the source or target for all writing or reading, respectively.
|
||||
/// </summary>
|
||||
workbook &workbook_;
|
||||
|
||||
std::vector<color> colors_;
|
||||
std::vector<border> borders_;
|
||||
std::vector<fill> fills_;
|
||||
std::vector<font> fonts_;
|
||||
std::vector<number_format> number_formats_;
|
||||
std::vector<cell_style> cell_styles_;
|
||||
std::vector<named_style> named_styles_;
|
||||
};
|
||||
|
||||
} // namespace xlnt
|
||||
|
|
|
@ -57,10 +57,14 @@ public:
|
|||
|
||||
bool get_shrink_to_fit() const;
|
||||
|
||||
void apply(bool value);
|
||||
bool apply() const;
|
||||
|
||||
protected:
|
||||
std::string to_hash_string() const override;
|
||||
|
||||
private:
|
||||
bool apply_ = false;
|
||||
horizontal_alignment horizontal_ = horizontal_alignment::none;
|
||||
vertical_alignment vertical_ = vertical_alignment::none;
|
||||
int text_rotation_ = 0;
|
||||
|
|
|
@ -61,10 +61,15 @@ public:
|
|||
std::experimental::optional<side> &get_horizontal();
|
||||
const std::experimental::optional<side> &get_horizontal() const;
|
||||
|
||||
void apply(bool value);
|
||||
bool apply() const;
|
||||
|
||||
protected:
|
||||
std::string to_hash_string() const override;
|
||||
|
||||
private:
|
||||
bool apply_ = false;
|
||||
|
||||
std::experimental::optional<side> start_;
|
||||
std::experimental::optional<side> end_;
|
||||
std::experimental::optional<side> left_;
|
||||
|
|
55
include/xlnt/styles/cell_style.hpp
Normal file
55
include/xlnt/styles/cell_style.hpp
Normal file
|
@ -0,0 +1,55 @@
|
|||
// Copyright (c) 2014-2016 Thomas Fussell
|
||||
// Copyright (c) 2010-2015 openpyxl
|
||||
//
|
||||
// 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, WRISING FROM,
|
||||
// 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
|
||||
#pragma once
|
||||
|
||||
#include <xlnt/styles/common_style.hpp>
|
||||
|
||||
namespace xlnt {
|
||||
|
||||
/// <summary>
|
||||
/// Describes the formatting of a particular cell.
|
||||
/// </summary>
|
||||
class XLNT_CLASS cell_style : public common_style
|
||||
{
|
||||
public:
|
||||
cell_style();
|
||||
cell_style(const cell_style &other);
|
||||
cell_style &operator=(const cell_style &other);
|
||||
|
||||
// Named Style
|
||||
named_style &get_named_style();
|
||||
const named_style &get_named_style() const;
|
||||
void set_named_style(const std::string &style_name);
|
||||
void set_named_style(const named_style &new_named_style);
|
||||
void remove_named_style();
|
||||
|
||||
protected:
|
||||
std::string to_hash_string() const override;
|
||||
|
||||
private:
|
||||
detail::workbook_impl *parent_;
|
||||
std::string named_style_name_;
|
||||
};
|
||||
|
||||
} // namespace xlnt
|
|
@ -33,75 +33,67 @@
|
|||
|
||||
namespace xlnt {
|
||||
|
||||
class workbook;
|
||||
class cell;
|
||||
namespace detail { struct workbook_impl; }
|
||||
|
||||
/// <summary>
|
||||
/// Describes the entirety of the formatting of a particular cell.
|
||||
/// Describes the formatting of a particular cell.
|
||||
/// </summary>
|
||||
class XLNT_CLASS format : public hashable
|
||||
class XLNT_CLASS common_style : public hashable
|
||||
{
|
||||
public:
|
||||
format();
|
||||
format(const format &other);
|
||||
format &operator=(const format &other);
|
||||
common_style();
|
||||
common_style(const common_style &other);
|
||||
common_style &operator=(const common_style &other);
|
||||
|
||||
std::size_t hash() const;
|
||||
void reset();
|
||||
|
||||
const alignment get_alignment() const;
|
||||
const border get_border() const;
|
||||
const fill get_fill() const;
|
||||
const font get_font() const;
|
||||
const number_format get_number_format() const;
|
||||
const protection get_protection() const;
|
||||
bool pivot_button() const;
|
||||
bool quote_prefix() const;
|
||||
// Alignment
|
||||
alignment &get_alignment();
|
||||
const alignment &get_alignment() const;
|
||||
void set_alignment(const alignment &new_alignment);
|
||||
void remove_alignment();
|
||||
|
||||
std::size_t get_id() const;
|
||||
std::size_t get_fill_id() const;
|
||||
std::size_t get_font_id() const;
|
||||
std::size_t get_border_id() const;
|
||||
std::size_t get_number_format_id() const;
|
||||
// Border
|
||||
border &get_border();
|
||||
const border &get_border() const;
|
||||
void set_border(const border &new_border);
|
||||
void remove_border();
|
||||
|
||||
void apply_alignment(bool apply);
|
||||
void apply_border(bool apply);
|
||||
void apply_fill(bool apply);
|
||||
void apply_font(bool apply);
|
||||
void apply_number_format(bool apply);
|
||||
void apply_protection(bool apply);
|
||||
// Fill
|
||||
fill &get_fill();
|
||||
const fill &get_fill() const;
|
||||
void set_fill(const fill &new_fill);
|
||||
void remove_fill();
|
||||
|
||||
// Font
|
||||
font &get_font();
|
||||
const font &get_font() const;
|
||||
void set_font(const font &new_font);
|
||||
void remove_font();
|
||||
|
||||
// Number Format
|
||||
number_format &get_number_format();
|
||||
const number_format &get_number_format() const;
|
||||
void set_number_format(const number_format &new_number_format);
|
||||
void remove_number_format();
|
||||
|
||||
// Protection
|
||||
protection &get_protection();
|
||||
const protection &get_protection() const;
|
||||
void set_protection(const protection &new_protection);
|
||||
void remove_protection();
|
||||
|
||||
protected:
|
||||
std::string to_hash_string() const override;
|
||||
|
||||
private:
|
||||
friend class style_serializer;
|
||||
friend class workbook;
|
||||
|
||||
std::size_t id_;
|
||||
|
||||
bool alignment_apply_;
|
||||
alignment alignment_;
|
||||
|
||||
bool border_apply_;
|
||||
std::size_t border_id_;
|
||||
border border_;
|
||||
|
||||
bool fill_apply_;
|
||||
std::size_t fill_id_;
|
||||
fill fill_;
|
||||
|
||||
bool font_apply_;
|
||||
std::size_t font_id_;
|
||||
font font_;
|
||||
|
||||
bool number_format_apply_;
|
||||
std::size_t number_format_id_;
|
||||
number_format number_format_;
|
||||
|
||||
bool protection_apply_;
|
||||
protection protection_;
|
||||
|
||||
bool pivot_button_;
|
||||
bool quote_prefix_;
|
||||
};
|
||||
|
||||
} // namespace xlnt
|
|
@ -118,18 +118,26 @@ public:
|
|||
|
||||
double get_gradient_bottom() const;
|
||||
|
||||
void apply(bool value);
|
||||
bool apply() const;
|
||||
|
||||
protected:
|
||||
std::string to_hash_string() const override;
|
||||
|
||||
private:
|
||||
bool apply_ = false;
|
||||
|
||||
type type_ = type::none;
|
||||
pattern_type pattern_type_;
|
||||
gradient_type gradient_type_;
|
||||
|
||||
double rotation_ = 0;
|
||||
|
||||
std::experimental::optional<color> foreground_color_ = color::black();
|
||||
std::experimental::optional<color> background_color_ = color::white();
|
||||
std::experimental::optional<color> start_color_ = color::white();
|
||||
std::experimental::optional<color> end_color_ = color::black();
|
||||
|
||||
double gradient_path_left_ = 0;
|
||||
double gradient_path_right_ = 0;
|
||||
double gradient_path_top_ = 0;
|
||||
|
|
|
@ -88,12 +88,17 @@ public:
|
|||
|
||||
bool has_scheme() const;
|
||||
|
||||
void apply(bool value);
|
||||
bool apply() const;
|
||||
|
||||
protected:
|
||||
std::string to_hash_string() const override;
|
||||
|
||||
private:
|
||||
friend class style;
|
||||
|
||||
bool apply_ = false;
|
||||
|
||||
std::string name_ = "Calibri";
|
||||
std::size_t size_ = 11;
|
||||
bool bold_ = false;
|
||||
|
|
|
@ -23,47 +23,39 @@
|
|||
// @author: see AUTHORS file
|
||||
#pragma once
|
||||
|
||||
#include <xlnt/xlnt_config.hpp>
|
||||
#include <xlnt/utils/hashable.hpp>
|
||||
#include <xlnt/styles/common_style.hpp>
|
||||
|
||||
namespace xlnt {
|
||||
|
||||
class workbook;
|
||||
|
||||
/// <summary>
|
||||
/// Describes the entirety of the styling of a particular cell.
|
||||
/// Describes a style which has a name and can be applied to multiple individual
|
||||
/// cell_styles.
|
||||
/// </summary>
|
||||
class XLNT_CLASS style : public hashable
|
||||
class XLNT_CLASS named_style : public common_style
|
||||
{
|
||||
public:
|
||||
style();
|
||||
style(const style &other);
|
||||
style &operator=(const style &other);
|
||||
|
||||
std::size_t hash() const;
|
||||
named_style();
|
||||
named_style(const named_style &other);
|
||||
named_style &operator=(const named_style &other);
|
||||
|
||||
std::string get_name() const;
|
||||
void set_name(const std::string &name);
|
||||
|
||||
std::size_t get_format_id() const;
|
||||
void set_format_id(std::size_t format_id);
|
||||
bool get_hidden() const;
|
||||
void set_hidden(bool value);
|
||||
|
||||
std::size_t get_builtin_id() const;
|
||||
void set_builtin_id(std::size_t builtin_id);
|
||||
|
||||
void set_hidden(bool hidden);
|
||||
bool get_hidden() const;
|
||||
|
||||
protected:
|
||||
std::string to_hash_string() const override;
|
||||
|
||||
private:
|
||||
friend class workbook;
|
||||
std::size_t id_;
|
||||
std::string name_;
|
||||
std::size_t format_id_;
|
||||
std::size_t builtin_id_;
|
||||
bool hidden_;
|
||||
std::size_t builtin_id;
|
||||
};
|
||||
|
||||
} // namespace xlnt
|
|
@ -23,6 +23,7 @@
|
|||
// @author: see AUTHORS file
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
|
||||
#include <xlnt/xlnt_config.hpp>
|
||||
|
@ -95,10 +96,14 @@ public:
|
|||
|
||||
bool is_date_format() const;
|
||||
|
||||
void apply(bool value);
|
||||
bool apply() const;
|
||||
|
||||
protected:
|
||||
std::string to_hash_string() const override;
|
||||
|
||||
private:
|
||||
bool apply_ = false;
|
||||
bool id_set_;
|
||||
std::size_t id_;
|
||||
std::string format_string_;
|
||||
|
|
|
@ -49,10 +49,14 @@ public:
|
|||
void set_locked(type locked_type);
|
||||
void set_hidden(type hidden_type);
|
||||
|
||||
void apply(bool value);
|
||||
bool apply() const;
|
||||
|
||||
protected:
|
||||
std::string to_hash_string() const override;
|
||||
|
||||
private:
|
||||
bool apply_ = false;
|
||||
type locked_;
|
||||
type hidden_;
|
||||
};
|
||||
|
|
|
@ -39,4 +39,17 @@ protected:
|
|||
virtual std::string to_hash_string() const = 0;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
} // namespace xlnt
|
||||
|
||||
namespace std {
|
||||
|
||||
template<>
|
||||
struct hash<xlnt::hashable>
|
||||
{
|
||||
size_t operator()(const xlnt::hashable &k) const
|
||||
{
|
||||
return k.hash();
|
||||
}
|
||||
};
|
||||
|
||||
} // namepsace std
|
||||
|
|
|
@ -37,7 +37,7 @@ namespace xlnt {
|
|||
class alignment;
|
||||
class app_properties;
|
||||
class border;
|
||||
class format;
|
||||
class cell_style;
|
||||
class color;
|
||||
class const_worksheet_iterator;
|
||||
class document_properties;
|
||||
|
@ -53,7 +53,7 @@ class protection;
|
|||
class range;
|
||||
class range_reference;
|
||||
class relationship;
|
||||
class style;
|
||||
class named_style;
|
||||
class theme;
|
||||
class worksheet;
|
||||
class worksheet_iterator;
|
||||
|
@ -176,57 +176,16 @@ public:
|
|||
relationship get_relationship(const std::string &id) const;
|
||||
const std::vector<relationship> &get_relationships() const;
|
||||
|
||||
void add_alignment(const alignment &a);
|
||||
void add_border(const border &b);
|
||||
void add_fill(const fill &f);
|
||||
void add_font(const font &f);
|
||||
void add_color(const color &c);
|
||||
void add_number_format(const number_format &format);
|
||||
void add_protection(const protection &p);
|
||||
|
||||
const std::vector<format> &get_cell_style_formats() const;
|
||||
const std::vector<format> &get_cell_formats() const;
|
||||
const std::vector<style> &get_styles() const;
|
||||
|
||||
const std::vector<color> &get_colors() const;
|
||||
const std::vector<border> &get_borders() const;
|
||||
const std::vector<fill> &get_fills() const;
|
||||
const std::vector<font> &get_fonts() const;
|
||||
const std::vector<number_format> &get_number_formats() const;
|
||||
|
||||
color add_indexed_color(const color &rgb_color);
|
||||
color get_indexed_color(const color &indexed_color) const;
|
||||
|
||||
format &add_default_cell_format();
|
||||
|
||||
const number_format &get_number_format(std::size_t style_id) const;
|
||||
std::size_t set_number_format(const number_format &format, std::size_t style_id);
|
||||
const font &get_font(std::size_t style_id) const;
|
||||
std::size_t set_font(const font &font_, std::size_t style_id);
|
||||
const fill &get_fill(std::size_t style_id) const;
|
||||
std::size_t set_fill(const fill &fill_, std::size_t style_id);
|
||||
const border &get_border(std::size_t style_id) const;
|
||||
std::size_t set_border(const border &border_, std::size_t style_id);
|
||||
const alignment &get_alignment(std::size_t style_id) const;
|
||||
std::size_t set_alignment(const alignment &alignment_, std::size_t style_id);
|
||||
const protection &get_protection(std::size_t style_id) const;
|
||||
std::size_t set_protection(const protection &protection_, std::size_t style_id);
|
||||
bool get_pivot_button(std::size_t style_id) const;
|
||||
bool get_quote_prefix(std::size_t style_id) const;
|
||||
|
||||
void set_code_name(const std::string &code_name);
|
||||
|
||||
bool has_loaded_theme() const;
|
||||
const theme &get_loaded_theme() const;
|
||||
|
||||
const format &get_cell_style_format(std::size_t format_id) const;
|
||||
std::size_t add_cell_style_format(const format &format_);
|
||||
|
||||
const format &get_cell_format(std::size_t format_id) const;
|
||||
std::size_t add_cell_format(const format &format_);
|
||||
|
||||
const style &get_style(std::size_t style_id) const;
|
||||
std::size_t add_style(const style &style_);
|
||||
// Named Styles
|
||||
bool has_named_style(const std::string &name);
|
||||
named_style &get_named_style(const std::string &name);
|
||||
const named_style &get_named_style(const std::string &name) const;
|
||||
named_style &create_named_style(const std::string &name);
|
||||
|
||||
manifest &get_manifest();
|
||||
const manifest &get_manifest() const;
|
||||
|
@ -242,7 +201,7 @@ public:
|
|||
|
||||
private:
|
||||
friend class worksheet;
|
||||
std::shared_ptr<detail::workbook_impl> d_;
|
||||
std::unique_ptr<detail::workbook_impl> d_;
|
||||
};
|
||||
|
||||
} // namespace xlnt
|
||||
|
|
|
@ -30,8 +30,8 @@
|
|||
#include <xlnt/packaging/document_properties.hpp>
|
||||
#include <xlnt/packaging/relationship.hpp>
|
||||
#include <xlnt/serialization/encoding.hpp>
|
||||
#include <xlnt/styles/cell_style.hpp>
|
||||
#include <xlnt/styles/color.hpp>
|
||||
#include <xlnt/styles/format.hpp>
|
||||
#include <xlnt/utils/date.hpp>
|
||||
#include <xlnt/utils/datetime.hpp>
|
||||
#include <xlnt/utils/time.hpp>
|
||||
|
|
|
@ -73,12 +73,6 @@ struct workbook_impl
|
|||
guess_types_ = other.guess_types_;
|
||||
data_only_ = other.data_only_;
|
||||
read_only_ = other.read_only_;
|
||||
styles_ = other.styles_;
|
||||
borders_ = other.borders_;
|
||||
fills_ = other.fills_;
|
||||
fonts_ = other.fonts_;
|
||||
number_formats_ = other.number_formats_;
|
||||
colors_ = other.colors_;
|
||||
manifest_ = other.manifest_;
|
||||
|
||||
return *this;
|
||||
|
@ -98,24 +92,12 @@ struct workbook_impl
|
|||
bool data_only_;
|
||||
bool read_only_;
|
||||
|
||||
std::vector<format> cell_style_formats_;
|
||||
std::vector<format> cell_formats_;
|
||||
std::vector<style> styles_;
|
||||
|
||||
std::size_t next_custom_format_id_;
|
||||
|
||||
std::vector<color> colors_;
|
||||
std::vector<border> borders_;
|
||||
std::vector<fill> fills_;
|
||||
std::vector<font> fonts_;
|
||||
std::vector<number_format> number_formats_;
|
||||
|
||||
manifest manifest_;
|
||||
|
||||
theme theme_;
|
||||
|
||||
encoding encoding_;
|
||||
|
||||
std::vector<std::uint8_t> thumbnail_;
|
||||
};
|
||||
|
||||
|
|
|
@ -22,18 +22,24 @@
|
|||
// @license: http://www.opensource.org/licenses/mit-license.php
|
||||
// @author: see AUTHORS file
|
||||
#include <cctype> // for std::tolower
|
||||
#include <unordered_set>
|
||||
|
||||
#include <xlnt/serialization/style_serializer.hpp>
|
||||
#include <xlnt/cell/cell.hpp>
|
||||
#include <xlnt/serialization/xml_document.hpp>
|
||||
#include <xlnt/serialization/xml_node.hpp>
|
||||
#include <xlnt/styles/alignment.hpp>
|
||||
#include <xlnt/styles/border.hpp>
|
||||
#include <xlnt/styles/cell_style.hpp>
|
||||
#include <xlnt/styles/fill.hpp>
|
||||
#include <xlnt/styles/font.hpp>
|
||||
#include <xlnt/styles/format.hpp>
|
||||
#include <xlnt/styles/number_format.hpp>
|
||||
#include <xlnt/styles/protection.hpp>
|
||||
#include <xlnt/styles/style.hpp>
|
||||
#include <xlnt/workbook/worksheet_iterator.hpp>
|
||||
#include <xlnt/worksheet/cell_iterator.hpp>
|
||||
#include <xlnt/worksheet/cell_vector.hpp>
|
||||
#include <xlnt/worksheet/worksheet.hpp>
|
||||
#include <xlnt/worksheet/range_iterator.hpp>
|
||||
|
||||
namespace {
|
||||
|
||||
|
@ -266,20 +272,45 @@ alignment style_serializer::read_alignment(const xml_node &alignment_node)
|
|||
return align;
|
||||
}
|
||||
|
||||
format style_serializer::read_format(const xml_node &format_node)
|
||||
cell_style style_serializer::read_cell_style(const xml_node &style_node)
|
||||
{
|
||||
format f;
|
||||
cell_style s;
|
||||
|
||||
f.apply_number_format(is_true(format_node.get_attribute("applyNumberFormat")));
|
||||
f.number_format_id_ = std::stoull(format_node.get_attribute("numFmtId"));
|
||||
// Alignment
|
||||
s.get_alignment().apply(style_node.has_child("alignment") || is_true(style_node.get_attribute("applyAlignment")));
|
||||
|
||||
if (s.get_alignment().apply())
|
||||
{
|
||||
auto inline_alignment = read_alignment(style_node.get_child("alignment"));
|
||||
s.set_alignment(inline_alignment);
|
||||
}
|
||||
|
||||
// Border
|
||||
s.get_border().apply(is_true(style_node.get_attribute("applyBorder")));
|
||||
auto border_index = style_node.has_attribute("borderId") ? std::stoull(style_node.get_attribute("borderId")) : 0;
|
||||
s.set_border(borders_.at(border_index));
|
||||
|
||||
// Fill
|
||||
s.get_fill().apply(is_true(style_node.get_attribute("applyFill")));
|
||||
auto fill_index = style_node.has_attribute("fillId") ? std::stoull(style_node.get_attribute("fillId")) : 0;
|
||||
s.set_fill(fills_.at(fill_index));
|
||||
|
||||
// Font
|
||||
s.get_font().apply(is_true(style_node.get_attribute("applyFont")));
|
||||
auto font_index = style_node.has_attribute("fontId") ? std::stoull(style_node.get_attribute("fontId")) : 0;
|
||||
s.set_font(fonts_.at(font_index));
|
||||
|
||||
// Number Format
|
||||
s.get_number_format().apply(is_true(style_node.get_attribute("applyNumberFormat")));
|
||||
auto number_format_id = std::stoull(style_node.get_attribute("numFmtId"));
|
||||
|
||||
bool builtin_format = true;
|
||||
|
||||
for (auto num_fmt : workbook_.get_number_formats())
|
||||
for (const auto &num_fmt : number_formats_)
|
||||
{
|
||||
if (static_cast<std::size_t>(num_fmt.get_id()) == f.get_number_format_id())
|
||||
if (static_cast<std::size_t>(num_fmt.get_id()) == number_format_id)
|
||||
{
|
||||
f.number_format_ = num_fmt;
|
||||
s.set_number_format(num_fmt);
|
||||
builtin_format = false;
|
||||
break;
|
||||
}
|
||||
|
@ -287,48 +318,39 @@ format style_serializer::read_format(const xml_node &format_node)
|
|||
|
||||
if (builtin_format)
|
||||
{
|
||||
f.number_format_ = number_format::from_builtin_id(f.get_number_format_id());
|
||||
s.set_number_format(number_format::from_builtin_id(number_format_id));
|
||||
}
|
||||
|
||||
f.apply_font(is_true(format_node.get_attribute("applyFont")));
|
||||
f.font_id_ = format_node.has_attribute("fontId") ? std::stoull(format_node.get_attribute("fontId")) : 0;
|
||||
f.font_ = workbook_.get_font(f.font_id_);
|
||||
// Protection
|
||||
s.get_protection().apply(style_node.has_attribute("protection") || is_true(style_node.get_attribute("applyProtection")));
|
||||
|
||||
f.apply_fill(is_true(format_node.get_attribute("applyFill")));
|
||||
f.fill_id_ = format_node.has_attribute("fillId") ? std::stoull(format_node.get_attribute("fillId")) : 0;
|
||||
f.fill_ = workbook_.get_fill(f.fill_id_);
|
||||
|
||||
f.apply_border(is_true(format_node.get_attribute("applyBorder")));
|
||||
f.border_id_ = format_node.has_attribute("borderId") ? std::stoull(format_node.get_attribute("borderId")) : 0;
|
||||
f.border_ = workbook_.get_border(f.border_id_);
|
||||
|
||||
f.apply_protection(format_node.has_attribute("protection"));
|
||||
|
||||
if (f.protection_apply_)
|
||||
if (s.get_protection().apply())
|
||||
{
|
||||
auto inline_protection = read_protection(format_node.get_child("protection"));
|
||||
f.protection_ = inline_protection;
|
||||
auto inline_protection = read_protection(style_node.get_child("protection"));
|
||||
s.set_protection(inline_protection);
|
||||
}
|
||||
|
||||
f.apply_alignment(format_node.has_child("alignment"));
|
||||
|
||||
if (f.alignment_apply_)
|
||||
{
|
||||
auto inline_alignment = read_alignment(format_node.get_child("alignment"));
|
||||
f.alignment_ = inline_alignment;
|
||||
}
|
||||
|
||||
return f;
|
||||
return s;
|
||||
}
|
||||
|
||||
style style_serializer::read_style(const xml_node &style_node)
|
||||
named_style style_serializer::read_named_style(const xml_node &named_style_node, const xml_node &style_parent_node)
|
||||
{
|
||||
style s;
|
||||
named_style s;
|
||||
|
||||
s.set_name(style_node.get_attribute("name"));
|
||||
s.set_format_id(std::stoull(style_node.get_attribute("xfId")));
|
||||
s.set_hidden(style_node.has_attribute("hidden") && is_true(style_node.get_attribute("hidden")));
|
||||
s.set_builtin_id(std::stoull(style_node.get_attribute("builtinId")));
|
||||
s.set_name(named_style_node.get_attribute("name"));
|
||||
s.set_hidden(named_style_node.has_attribute("hidden") && is_true(named_style_node.get_attribute("hidden")));
|
||||
s.set_builtin_id(std::stoull(named_style_node.get_attribute("builtinId")));
|
||||
|
||||
auto base_style_id = std::stoull(named_style_node.get_attribute("xfId"));
|
||||
auto base_style_node = style_parent_node.get_children().at(base_style_id);
|
||||
auto base_style = read_cell_style(base_style_node);
|
||||
|
||||
s.set_alignment(base_style.get_alignment());
|
||||
s.set_border(base_style.get_border());
|
||||
s.set_fill(base_style.get_fill());
|
||||
s.set_font(base_style.get_font());
|
||||
s.set_number_format(base_style.get_number_format());
|
||||
s.set_protection(base_style.get_protection());
|
||||
|
||||
return s;
|
||||
}
|
||||
|
@ -342,41 +364,28 @@ bool style_serializer::read_stylesheet(const xml_document &xml)
|
|||
read_fonts(stylesheet_node.get_child("fonts"));
|
||||
read_number_formats(stylesheet_node.get_child("numFmts"));
|
||||
read_colors(stylesheet_node.get_child("colors"));
|
||||
read_named_styles(stylesheet_node.get_child("cellStyles"), stylesheet_node.get_child("cellStyleXfs"));
|
||||
read_cell_styles(stylesheet_node.get_child("cellXfs"));
|
||||
|
||||
auto cell_style_formats_node = stylesheet_node.get_child("cellStyleXfs");
|
||||
return true;
|
||||
}
|
||||
|
||||
for (auto format_node : cell_style_formats_node.get_children())
|
||||
bool style_serializer::read_cell_styles(const xlnt::xml_node &cell_styles_node)
|
||||
{
|
||||
for (auto style_node : cell_styles_node.get_children())
|
||||
{
|
||||
if (format_node.get_name() != "xf")
|
||||
if (style_node.get_name() != "xf")
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
workbook_.add_cell_style_format(read_format(format_node));
|
||||
}
|
||||
auto style = read_cell_style(style_node);
|
||||
|
||||
auto cell_formats_node = stylesheet_node.get_child("cellXfs");
|
||||
|
||||
for (auto format_node : cell_formats_node.get_children())
|
||||
if(style_node.has_attribute("xfId"))
|
||||
{
|
||||
if (format_node.get_name() != "xf")
|
||||
{
|
||||
continue;
|
||||
auto named_style_index = std::stoull(style_node.get_attribute("xfId"));
|
||||
auto named_style = named_styles_.at(named_style_index);
|
||||
}
|
||||
|
||||
workbook_.add_cell_format(read_format(format_node));
|
||||
}
|
||||
|
||||
auto cell_styles_node = stylesheet_node.get_child("cellStyles");
|
||||
|
||||
for (auto cell_style_node : cell_styles_node.get_children())
|
||||
{
|
||||
if (cell_style_node.get_name() != "cellStyle")
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
workbook_.add_style(read_style(cell_style_node));
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -403,7 +412,7 @@ bool style_serializer::read_number_formats(const xml_node &number_formats_node)
|
|||
nf.set_format_string(format_string);
|
||||
nf.set_id(std::stoull(num_fmt_node.get_attribute("numFmtId")));
|
||||
|
||||
workbook_.add_number_format(nf);
|
||||
number_formats_.push_back(nf);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -413,7 +422,7 @@ bool style_serializer::read_fonts(const xml_node &fonts_node)
|
|||
{
|
||||
for (auto font_node : fonts_node.get_children())
|
||||
{
|
||||
workbook_.add_font(read_font(font_node));
|
||||
fonts_.push_back(read_font(font_node));
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -501,7 +510,7 @@ bool style_serializer::read_colors(const xml_node &colors_node)
|
|||
|
||||
for (const auto &indexed_color : indexed_colors)
|
||||
{
|
||||
workbook_.add_color(indexed_color);
|
||||
colors_.push_back(indexed_color);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -512,7 +521,7 @@ bool style_serializer::read_fills(const xml_node &fills_node)
|
|||
{
|
||||
for (auto fill_node : fills_node.get_children())
|
||||
{
|
||||
workbook_.add_fill(read_fill(fill_node));
|
||||
fills_.push_back(read_fill(fill_node));
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -564,7 +573,7 @@ bool style_serializer::read_borders(const xml_node &borders_node)
|
|||
{
|
||||
for (auto border_node : borders_node.get_children())
|
||||
{
|
||||
workbook_.add_border(read_border(border_node));
|
||||
borders_.push_back(read_border(border_node));
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -656,40 +665,67 @@ color style_serializer::read_color(const xml_node &color_node)
|
|||
throw std::runtime_error("bad color");
|
||||
}
|
||||
|
||||
xml_document style_serializer::write_stylesheet() const
|
||||
void style_serializer::initialize_vectors()
|
||||
{
|
||||
xml_document xml;
|
||||
std::unordered_set<cell_style, std::hash<hashable>> cell_styles_set;
|
||||
|
||||
auto style_sheet_node = xml.add_child("styleSheet");
|
||||
xml.add_namespace("", "http://schemas.openxmlformats.org/spreadsheetml/2006/main");
|
||||
xml.add_namespace("mc", "http://schemas.openxmlformats.org/markup-compatibility/2006");
|
||||
style_sheet_node.add_attribute("mc:Ignorable", "x14ac");
|
||||
xml.add_namespace("x14ac", "http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac");
|
||||
|
||||
auto num_fmts_node = style_sheet_node.add_child("numFmts");
|
||||
auto num_fmts = workbook_.get_number_formats();
|
||||
num_fmts_node.add_attribute("count", std::to_string(num_fmts.size()));
|
||||
|
||||
for (const auto &num_fmt : num_fmts)
|
||||
for (auto ws : workbook_)
|
||||
{
|
||||
auto num_fmt_node = num_fmts_node.add_child("numFmt");
|
||||
num_fmt_node.add_attribute("numFmtId", std::to_string(num_fmt.get_id()));
|
||||
num_fmt_node.add_attribute("formatCode", num_fmt.get_format_string());
|
||||
for (auto row : ws)
|
||||
{
|
||||
for (auto c : row)
|
||||
{
|
||||
if (c.has_style())
|
||||
{
|
||||
cell_styles_set.insert(c.get_style());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
auto fonts_node = style_sheet_node.add_child("fonts");
|
||||
auto fonts = workbook_.get_fonts();
|
||||
cell_styles_.assign(cell_styles_set.begin(), cell_styles_set.end());
|
||||
colors_.clear();
|
||||
borders_.clear();
|
||||
fills_.clear();
|
||||
fonts_.clear();
|
||||
number_formats_.clear();
|
||||
|
||||
if (fonts.empty())
|
||||
for (auto &style : cell_styles_)
|
||||
{
|
||||
fonts.push_back(font());
|
||||
if (std::find(borders_.begin(), borders_.end(), style.get_border()) == borders_.end())
|
||||
{
|
||||
borders_.push_back(style.get_border());
|
||||
}
|
||||
|
||||
fonts_node.add_attribute("count", std::to_string(fonts.size()));
|
||||
if (std::find(fills_.begin(), fills_.end(), style.get_fill()) == fills_.end())
|
||||
{
|
||||
fills_.push_back(style.get_fill());
|
||||
}
|
||||
|
||||
if (std::find(fonts_.begin(), fonts_.end(), style.get_font()) == fonts_.end())
|
||||
{
|
||||
fonts_.push_back(style.get_font());
|
||||
}
|
||||
|
||||
if (std::find(number_formats_.begin(), number_formats_.end(), style.get_number_format()) == number_formats_.end())
|
||||
{
|
||||
number_formats_.push_back(style.get_number_format());
|
||||
}
|
||||
}
|
||||
|
||||
if (fonts_.empty())
|
||||
{
|
||||
fonts_.push_back(font());
|
||||
}
|
||||
}
|
||||
|
||||
bool style_serializer::write_fonts(xlnt::xml_node &fonts_node) const
|
||||
{
|
||||
fonts_node.add_attribute("count", std::to_string(fonts_.size()));
|
||||
// TODO: what does this do?
|
||||
// fonts_node.add_attribute("x14ac:knownFonts", "1");
|
||||
|
||||
for (auto &f : fonts)
|
||||
for (auto &f : fonts_)
|
||||
{
|
||||
auto font_node = fonts_node.add_child("font");
|
||||
|
||||
|
@ -763,11 +799,14 @@ xml_document style_serializer::write_stylesheet() const
|
|||
}
|
||||
}
|
||||
|
||||
auto fills_node = style_sheet_node.add_child("fills");
|
||||
const auto &fills = workbook_.get_fills();
|
||||
fills_node.add_attribute("count", std::to_string(fills.size()));
|
||||
return true;
|
||||
}
|
||||
|
||||
for (auto &fill_ : fills)
|
||||
bool style_serializer::write_fills(xlnt::xml_node &fills_node) const
|
||||
{
|
||||
fills_node.add_attribute("count", std::to_string(fills_.size()));
|
||||
|
||||
for (auto &fill_ : fills_)
|
||||
{
|
||||
auto fill_node = fills_node.add_child("fill");
|
||||
|
||||
|
@ -854,11 +893,14 @@ xml_document style_serializer::write_stylesheet() const
|
|||
}
|
||||
}
|
||||
|
||||
auto borders_node = style_sheet_node.add_child("borders");
|
||||
const auto &borders = workbook_.get_borders();
|
||||
borders_node.add_attribute("count", std::to_string(borders.size()));
|
||||
return true;
|
||||
}
|
||||
|
||||
for (const auto &border_ : borders)
|
||||
bool style_serializer::write_borders(xlnt::xml_node &borders_node) const
|
||||
{
|
||||
borders_node.add_attribute("count", std::to_string(borders_.size()));
|
||||
|
||||
for (const auto &border_ : borders_)
|
||||
{
|
||||
auto border_node = borders_node.add_child("border");
|
||||
|
||||
|
@ -963,33 +1005,42 @@ xml_document style_serializer::write_stylesheet() const
|
|||
}
|
||||
}
|
||||
|
||||
auto cell_style_xfs_node = style_sheet_node.add_child("cellStyleXfs");
|
||||
auto &cell_style_formats = workbook_.get_cell_style_formats();
|
||||
cell_style_xfs_node.add_attribute("count", std::to_string(cell_style_formats.size()));
|
||||
return true;
|
||||
}
|
||||
|
||||
for(auto &format : cell_style_formats)
|
||||
bool style_serializer::write_style_common(const alignment &style_alignment, const border &style_border, const fill &style_fill, const font &style_font, const number_format &style_number_format, const protection &style_protection, xml_node xf_node) const
|
||||
{
|
||||
xf_node.add_attribute("numFmtId", std::to_string(style_number_format.get_id()));
|
||||
|
||||
auto font_id = std::distance(fonts_.begin(), std::find(fonts_.begin(), fonts_.end(), style_font));
|
||||
xf_node.add_attribute("fontId", std::to_string(font_id));
|
||||
|
||||
if (style_fill.apply())
|
||||
{
|
||||
auto xf_node = cell_style_xfs_node.add_child("xf");
|
||||
auto fill_id = std::distance(fills_.begin(), std::find(fills_.begin(), fills_.end(), style_fill));
|
||||
xf_node.add_attribute("fillId", std::to_string(fill_id));
|
||||
}
|
||||
|
||||
xf_node.add_attribute("numFmtId", std::to_string(format.get_number_format().get_id()));
|
||||
xf_node.add_attribute("fontId", std::to_string(format.get_font_id()));
|
||||
xf_node.add_attribute("fillId", std::to_string(format.get_fill_id()));
|
||||
xf_node.add_attribute("borderId", std::to_string(format.get_border_id()));
|
||||
if (style_border.apply())
|
||||
{
|
||||
auto border_id = std::distance(borders_.begin(), std::find(borders_.begin(), borders_.end(), style_border));
|
||||
xf_node.add_attribute("borderId", std::to_string(border_id));
|
||||
}
|
||||
|
||||
xf_node.add_attribute("applyNumberFormat", format.number_format_apply_ ? "1" : "0");
|
||||
xf_node.add_attribute("applyFill", format.fill_apply_ ? "1" : "0");
|
||||
xf_node.add_attribute("applyFont", format.font_apply_ ? "1" : "0");
|
||||
xf_node.add_attribute("applyBorder", format.border_apply_ ? "1" : "0");
|
||||
xf_node.add_attribute("applyAlignment", format.alignment_apply_ ? "1" : "0");
|
||||
xf_node.add_attribute("applyProtection", format.protection_apply_ ? "1" : "0");
|
||||
xf_node.add_attribute("applyNumberFormat", style_number_format.apply() ? "1" : "0");
|
||||
xf_node.add_attribute("applyFill", style_fill.apply() ? "1" : "0");
|
||||
xf_node.add_attribute("applyFont", style_font.apply() ? "1" : "0");
|
||||
xf_node.add_attribute("applyBorder", style_border.apply() ? "1" : "0");
|
||||
xf_node.add_attribute("applyAlignment", style_alignment.apply() ? "1" : "0");
|
||||
xf_node.add_attribute("applyProtection", style_protection.apply() ? "1" : "0");
|
||||
|
||||
if (format.alignment_apply_)
|
||||
if (style_alignment.apply())
|
||||
{
|
||||
auto alignment_node = xf_node.add_child("alignment");
|
||||
|
||||
if (format.alignment_.has_vertical())
|
||||
if (style_alignment.has_vertical())
|
||||
{
|
||||
switch (format.alignment_.get_vertical())
|
||||
switch (style_alignment.get_vertical())
|
||||
{
|
||||
case vertical_alignment::bottom:
|
||||
alignment_node.add_attribute("vertical", "bottom");
|
||||
|
@ -1008,9 +1059,9 @@ xml_document style_serializer::write_stylesheet() const
|
|||
}
|
||||
}
|
||||
|
||||
if (format.alignment_.has_horizontal())
|
||||
if (style_alignment.has_horizontal())
|
||||
{
|
||||
switch (format.alignment_.get_horizontal())
|
||||
switch (style_alignment.get_horizontal())
|
||||
{
|
||||
case horizontal_alignment::center:
|
||||
alignment_node.add_attribute("horizontal", "center");
|
||||
|
@ -1035,161 +1086,163 @@ xml_document style_serializer::write_stylesheet() const
|
|||
}
|
||||
}
|
||||
|
||||
if (format.alignment_.get_wrap_text())
|
||||
if (style_alignment.get_wrap_text())
|
||||
{
|
||||
alignment_node.add_attribute("wrapText", "1");
|
||||
}
|
||||
|
||||
if (format.alignment_.get_shrink_to_fit())
|
||||
if (style_alignment.get_shrink_to_fit())
|
||||
{
|
||||
alignment_node.add_attribute("shrinkToFit", "1");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
auto cell_xfs_node = style_sheet_node.add_child("cellXfs");
|
||||
const auto &formats = workbook_.get_cell_formats();
|
||||
cell_xfs_node.add_attribute("count", std::to_string(formats.size()));
|
||||
return true;
|
||||
}
|
||||
|
||||
for (auto &format : formats)
|
||||
bool style_serializer::write_cell_style(const cell_style &style, xml_node &xf_node) const
|
||||
{
|
||||
return write_style_common(style.get_alignment(), style.get_border(), style.get_fill(), style.get_font(), style.get_number_format(), style.get_protection(), xf_node);
|
||||
}
|
||||
|
||||
bool style_serializer::write_named_style(const named_style &style, xml_node &xf_node) const
|
||||
{
|
||||
return write_style_common(style.get_alignment(), style.get_border(), style.get_fill(), style.get_font(), style.get_number_format(), style.get_protection(), xf_node);
|
||||
}
|
||||
|
||||
bool style_serializer::write_named_styles(xml_node &cell_styles_node, xml_node &styles_node) const
|
||||
{
|
||||
styles_node.add_attribute("count", std::to_string(named_styles_.size()));
|
||||
|
||||
for(auto &style : named_styles_)
|
||||
{
|
||||
auto xf_node = cell_xfs_node.add_child("xf");
|
||||
xf_node.add_attribute("numFmtId", std::to_string(format.get_number_format_id()));
|
||||
xf_node.add_attribute("fontId", std::to_string(format.get_font_id()));
|
||||
|
||||
if (format.fill_apply_)
|
||||
{
|
||||
xf_node.add_attribute("fillId", std::to_string(format.get_fill_id()));
|
||||
auto xf_node = styles_node.add_child("xf");
|
||||
write_named_style(style, xf_node);
|
||||
}
|
||||
|
||||
if (format.border_apply_)
|
||||
{
|
||||
xf_node.add_attribute("borderId", std::to_string(format.get_border_id()));
|
||||
}
|
||||
cell_styles_node.add_attribute("count", std::to_string(named_styles_.size()));
|
||||
|
||||
xf_node.add_attribute("xfId", "0");
|
||||
|
||||
xf_node.add_attribute("applyNumberFormat", format.number_format_apply_ ? "1" : "0");
|
||||
xf_node.add_attribute("applyFont", format.font_apply_ ? "1" : "0");
|
||||
xf_node.add_attribute("applyFill", format.fill_apply_ ? "1" : "0");
|
||||
xf_node.add_attribute("applyBorder", format.border_apply_ ? "1" : "0");
|
||||
xf_node.add_attribute("applyAlignment", format.alignment_apply_ ? "1" : "0");
|
||||
xf_node.add_attribute("applyProtection", format.protection_apply_ ? "1" : "0");
|
||||
|
||||
if (format.alignment_apply_)
|
||||
{
|
||||
auto alignment_node = xf_node.add_child("alignment");
|
||||
|
||||
if (format.alignment_.has_vertical())
|
||||
{
|
||||
switch (format.alignment_.get_vertical())
|
||||
{
|
||||
case vertical_alignment::bottom:
|
||||
alignment_node.add_attribute("vertical", "bottom");
|
||||
break;
|
||||
case vertical_alignment::center:
|
||||
alignment_node.add_attribute("vertical", "center");
|
||||
break;
|
||||
case vertical_alignment::justify:
|
||||
alignment_node.add_attribute("vertical", "justify");
|
||||
break;
|
||||
case vertical_alignment::top:
|
||||
alignment_node.add_attribute("vertical", "top");
|
||||
break;
|
||||
default:
|
||||
throw std::runtime_error("invalid alignment");
|
||||
}
|
||||
}
|
||||
|
||||
if (format.alignment_.has_horizontal())
|
||||
{
|
||||
switch (format.alignment_.get_horizontal())
|
||||
{
|
||||
case horizontal_alignment::center:
|
||||
alignment_node.add_attribute("horizontal", "center");
|
||||
break;
|
||||
case horizontal_alignment::center_continuous:
|
||||
alignment_node.add_attribute("horizontal", "center_continuous");
|
||||
break;
|
||||
case horizontal_alignment::general:
|
||||
alignment_node.add_attribute("horizontal", "general");
|
||||
break;
|
||||
case horizontal_alignment::justify:
|
||||
alignment_node.add_attribute("horizontal", "justify");
|
||||
break;
|
||||
case horizontal_alignment::left:
|
||||
alignment_node.add_attribute("horizontal", "left");
|
||||
break;
|
||||
case horizontal_alignment::right:
|
||||
alignment_node.add_attribute("horizontal", "right");
|
||||
break;
|
||||
default:
|
||||
throw std::runtime_error("invalid alignment");
|
||||
}
|
||||
}
|
||||
|
||||
if (format.alignment_.get_wrap_text())
|
||||
{
|
||||
alignment_node.add_attribute("wrapText", "1");
|
||||
}
|
||||
|
||||
if (format.alignment_.get_shrink_to_fit())
|
||||
{
|
||||
alignment_node.add_attribute("shrinkToFit", "1");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
auto cell_styles_node = style_sheet_node.add_child("cellStyles");
|
||||
auto &styles = workbook_.get_styles();
|
||||
cell_styles_node.add_attribute("count", std::to_string(styles.size()));
|
||||
|
||||
for(auto &cell_style : styles)
|
||||
for(auto &style : named_styles_)
|
||||
{
|
||||
auto cell_style_node = cell_styles_node.add_child("cellStyle");
|
||||
|
||||
cell_style_node.add_attribute("name", cell_style.get_name());
|
||||
cell_style_node.add_attribute("xfId", std::to_string(cell_style.get_format_id()));
|
||||
cell_style_node.add_attribute("builtinId", std::to_string(cell_style.get_builtin_id()));
|
||||
cell_style_node.add_attribute("name", style.get_name());
|
||||
// cell_style_node.add_attribute("xfId", std::to_string(style.get_format_id()));
|
||||
cell_style_node.add_attribute("builtinId", std::to_string(style.get_builtin_id()));
|
||||
|
||||
if (cell_style.get_hidden())
|
||||
if (style.get_hidden())
|
||||
{
|
||||
cell_style_node.add_attribute("hidden", "1");
|
||||
}
|
||||
}
|
||||
|
||||
style_sheet_node.add_child("dxfs").add_attribute("count", "0");
|
||||
return true;
|
||||
}
|
||||
|
||||
auto table_styles_node = style_sheet_node.add_child("tableStyles");
|
||||
bool style_serializer::write_cell_styles(xml_node &cell_styles_node) const
|
||||
{
|
||||
cell_styles_node.add_attribute("count", std::to_string(cell_styles_.size()));
|
||||
|
||||
for(auto &style : cell_styles_)
|
||||
{
|
||||
auto xf_node = cell_styles_node.add_child("xf");
|
||||
write_cell_style(style, xf_node);
|
||||
xf_node.add_attribute("xfId", "0"); //TODO point to named style here
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool write_dxfs(xlnt::xml_node &dxfs_node)
|
||||
{
|
||||
dxfs_node.add_attribute("count", "0");
|
||||
return true;
|
||||
}
|
||||
|
||||
bool write_table_styles(xlnt::xml_node &table_styles_node)
|
||||
{
|
||||
table_styles_node.add_attribute("count", "0");
|
||||
table_styles_node.add_attribute("defaultTableStyle", "TableStyleMedium2");
|
||||
table_styles_node.add_attribute("defaultPivotStyle", "PivotStyleMedium9");
|
||||
|
||||
if(!workbook_.get_colors().empty())
|
||||
{
|
||||
auto colors_node = style_sheet_node.add_child("colors");
|
||||
return true;
|
||||
}
|
||||
|
||||
bool style_serializer::write_colors(xlnt::xml_node &colors_node) const
|
||||
{
|
||||
auto indexed_colors_node = colors_node.add_child("indexedColors");
|
||||
|
||||
for (auto &c : workbook_.get_colors())
|
||||
for (auto &c : colors_)
|
||||
{
|
||||
indexed_colors_node.add_child("rgbColor").add_attribute("rgb", c.get_rgb_string());
|
||||
}
|
||||
}
|
||||
|
||||
auto ext_list_node = style_sheet_node.add_child("extLst");
|
||||
return true;
|
||||
}
|
||||
|
||||
bool write_colors(xlnt::xml_node &ext_list_node)
|
||||
{
|
||||
auto ext_node = ext_list_node.add_child("ext");
|
||||
ext_node.add_attribute("uri", "{EB79DEF2-80B8-43e5-95BD-54CBDDF9020C}");
|
||||
ext_node.add_attribute("xmlns:x14", "http://schemas.microsoft.com/office/spreadsheetml/2009/9/main");
|
||||
ext_node.add_child("x14:slicerStyles").add_attribute("defaultSlicerStyle", "SlicerStyleLight1");
|
||||
|
||||
return xml;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool style_serializer::write_number_formats(xml_node number_formats_node) const
|
||||
xml_document style_serializer::write_stylesheet()
|
||||
{
|
||||
number_formats_node.add_attribute("count", std::to_string(workbook_.get_number_formats().size()));
|
||||
initialize_vectors();
|
||||
|
||||
for (const auto &num_fmt : workbook_.get_number_formats())
|
||||
xml_document doc;
|
||||
auto root_node = doc.add_child("styleSheet");
|
||||
doc.add_namespace("", "http://schemas.openxmlformats.org/spreadsheetml/2006/main");
|
||||
doc.add_namespace("mc", "http://schemas.openxmlformats.org/markup-compatibility/2006");
|
||||
root_node.add_attribute("mc:Ignorable", "x14ac");
|
||||
doc.add_namespace("x14ac", "http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac");
|
||||
|
||||
auto number_formats_node = root_node.add_child("numFmts");
|
||||
write_number_formats(number_formats_node);
|
||||
|
||||
auto fonts_node = root_node.add_child("fonts");
|
||||
write_fonts(fonts_node);
|
||||
|
||||
auto fills_node = root_node.add_child("fills");
|
||||
write_fills(fills_node);
|
||||
|
||||
auto borders_node = root_node.add_child("borders");
|
||||
write_borders(borders_node);
|
||||
|
||||
auto cell_style_xfs_node = root_node.add_child("cellStyleXfs");
|
||||
auto cell_styles_node = root_node.add_child("cellStyles");
|
||||
write_named_styles(root_node, cell_style_xfs_node);
|
||||
|
||||
auto cell_xfs_node = root_node.add_child("cellXfs");
|
||||
write_cell_styles(cell_styles_node);
|
||||
|
||||
auto dxfs_node = root_node.add_child("dxfs");
|
||||
write_dxfs(dxfs_node);
|
||||
|
||||
auto table_styles_node = root_node.add_child("tableStyles");
|
||||
write_table_styles(table_styles_node);
|
||||
|
||||
if(!colors_.empty())
|
||||
{
|
||||
auto colors_node = root_node.add_child("colors");
|
||||
write_colors(colors_node);
|
||||
}
|
||||
|
||||
auto ext_list_node = root_node.add_child("extLst");
|
||||
write_ext_list(ext_list_node);
|
||||
|
||||
return doc;
|
||||
}
|
||||
|
||||
bool style_serializer::write_number_formats(xml_node &number_formats_node) const
|
||||
{
|
||||
number_formats_node.add_attribute("count", std::to_string(number_formats_.size()));
|
||||
|
||||
for (const auto &num_fmt : number_formats_)
|
||||
{
|
||||
auto num_fmt_node = number_formats_node.add_child("numFmt");
|
||||
num_fmt_node.add_attribute("numFmtId", std::to_string(num_fmt.get_id()));
|
||||
|
|
117
source/styles/cell_style.cpp
Normal file
117
source/styles/cell_style.cpp
Normal file
|
@ -0,0 +1,117 @@
|
|||
// Copyright (c) 2014-2016 Thomas Fussell
|
||||
// Copyright (c) 2010-2015 openpyxl
|
||||
//
|
||||
// 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, WRISING FROM,
|
||||
// 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
|
||||
#include <xlnt/cell/cell.hpp>
|
||||
#include <xlnt/styles/cell_style.hpp>
|
||||
#include <xlnt/styles/font.hpp>
|
||||
#include <xlnt/styles/number_format.hpp>
|
||||
#include <xlnt/styles/protection.hpp>
|
||||
#include <xlnt/utils/hash_combine.hpp>
|
||||
|
||||
namespace xlnt {
|
||||
|
||||
cell_style::cell_style(cell parent) : parent_(parent)
|
||||
{
|
||||
}
|
||||
|
||||
cell_style::cell_style(const cell_style &other)
|
||||
: alignment_(other.alignment_),
|
||||
border_(other.border_),
|
||||
fill_(other.fill_),
|
||||
font_(other.font_),
|
||||
number_format_(other.number_format_),
|
||||
protection_(other.protection_)
|
||||
{
|
||||
}
|
||||
|
||||
cell_style &cell_style::operator=(const cell_style &other)
|
||||
{
|
||||
parent_ = other.parent_;
|
||||
named_style_name_ = other.named_style_name_;
|
||||
|
||||
alignment_ = other.alignment_;
|
||||
border_ = other.border_;
|
||||
fill_ = other.fill_;
|
||||
font_ = other.font_;
|
||||
number_format_ = other.number_format_;
|
||||
protection_ = other.protection_;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
const alignment &cell_style::get_alignment() const
|
||||
{
|
||||
return alignment_;
|
||||
}
|
||||
|
||||
const number_format &cell_style::get_number_format() const
|
||||
{
|
||||
return number_format_;
|
||||
}
|
||||
|
||||
const border &cell_style::get_border() const
|
||||
{
|
||||
return border_;
|
||||
}
|
||||
|
||||
const fill &cell_style::get_fill() const
|
||||
{
|
||||
return fill_;
|
||||
}
|
||||
|
||||
const font &cell_style::get_font() const
|
||||
{
|
||||
return font_;
|
||||
}
|
||||
|
||||
const protection &cell_style::get_protection() const
|
||||
{
|
||||
return protection_;
|
||||
}
|
||||
|
||||
std::string cell_style::to_hash_string() const
|
||||
{
|
||||
std::string hash_string("style");
|
||||
|
||||
hash_string.append(std::to_string(alignment_.apply()));
|
||||
hash_string.append(alignment_.apply() ? std::to_string(alignment_.hash()) : " ");
|
||||
|
||||
hash_string.append(std::to_string(border_.apply()));
|
||||
hash_string.append(border_.apply() ? std::to_string(border_.hash()) : " ");
|
||||
|
||||
hash_string.append(std::to_string(font_.apply()));
|
||||
hash_string.append(font_.apply() ? std::to_string(font_.hash()) : " ");
|
||||
|
||||
hash_string.append(std::to_string(fill_.apply()));
|
||||
hash_string.append(fill_.apply() ? std::to_string(fill_.hash()) : " ");
|
||||
|
||||
hash_string.append(std::to_string(number_format_.apply()));
|
||||
hash_string.append(number_format_.apply() ? std::to_string(number_format_.hash()) : " ");
|
||||
|
||||
hash_string.append(std::to_string(protection_.apply()));
|
||||
hash_string.append(protection_.apply() ? std::to_string(protection_.hash()) : " ");
|
||||
|
||||
return hash_string;
|
||||
}
|
||||
|
||||
} // namespace xlnt
|
|
@ -27,6 +27,16 @@
|
|||
|
||||
namespace xlnt {
|
||||
|
||||
const color color::black()
|
||||
{
|
||||
return color(color::type::rgb, "ff000000");
|
||||
}
|
||||
|
||||
const color color::white()
|
||||
{
|
||||
return color(color::type::rgb, "ffffffff");
|
||||
}
|
||||
|
||||
color::color()
|
||||
{
|
||||
}
|
||||
|
|
|
@ -1,237 +0,0 @@
|
|||
// Copyright (c) 2014-2016 Thomas Fussell
|
||||
// Copyright (c) 2010-2015 openpyxl
|
||||
//
|
||||
// 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, WRISING FROM,
|
||||
// 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
|
||||
#include <xlnt/cell/cell.hpp>
|
||||
#include <xlnt/styles/font.hpp>
|
||||
#include <xlnt/styles/number_format.hpp>
|
||||
#include <xlnt/styles/protection.hpp>
|
||||
#include <xlnt/styles/format.hpp>
|
||||
|
||||
namespace {
|
||||
|
||||
template <class T>
|
||||
void hash_combine(std::size_t &seed, const T &v)
|
||||
{
|
||||
std::hash<T> hasher;
|
||||
seed ^= hasher(v) + 0x9e3779b9 + (seed << 6) + (seed >> 2);
|
||||
}
|
||||
}
|
||||
|
||||
namespace xlnt {
|
||||
|
||||
const color color::black()
|
||||
{
|
||||
return color(color::type::rgb, "ff000000");
|
||||
}
|
||||
|
||||
const color color::white()
|
||||
{
|
||||
return color(color::type::rgb, "ffffffff");
|
||||
}
|
||||
|
||||
format::format()
|
||||
: id_(0),
|
||||
alignment_apply_(false),
|
||||
border_apply_(false),
|
||||
border_id_(0),
|
||||
fill_apply_(false),
|
||||
fill_id_(0),
|
||||
font_apply_(false),
|
||||
font_id_(0),
|
||||
number_format_apply_(false),
|
||||
number_format_id_(0),
|
||||
protection_apply_(false),
|
||||
pivot_button_(false),
|
||||
quote_prefix_(false)
|
||||
{
|
||||
}
|
||||
|
||||
format::format(const format &other)
|
||||
: id_(other.id_),
|
||||
alignment_apply_(other.alignment_apply_),
|
||||
alignment_(other.alignment_),
|
||||
border_apply_(other.border_apply_),
|
||||
border_id_(other.border_id_),
|
||||
border_(other.border_),
|
||||
fill_apply_(other.fill_apply_),
|
||||
fill_id_(other.fill_id_),
|
||||
fill_(other.fill_),
|
||||
font_apply_(other.font_apply_),
|
||||
font_id_(other.font_id_),
|
||||
font_(other.font_),
|
||||
number_format_apply_(other.number_format_apply_),
|
||||
number_format_id_(other.number_format_id_),
|
||||
number_format_(other.number_format_),
|
||||
protection_apply_(other.protection_apply_),
|
||||
protection_(other.protection_),
|
||||
pivot_button_(other.pivot_button_),
|
||||
quote_prefix_(other.quote_prefix_)
|
||||
{
|
||||
}
|
||||
|
||||
format &format::operator=(const format &other)
|
||||
{
|
||||
id_ = other.id_;
|
||||
alignment_ = other.alignment_;
|
||||
alignment_apply_ = other.alignment_apply_;
|
||||
border_ = other.border_;
|
||||
border_apply_ = other.border_apply_;
|
||||
border_id_ = other.border_id_;
|
||||
fill_ = other.fill_;
|
||||
fill_apply_ = other.fill_apply_;
|
||||
fill_id_ = other.fill_id_;
|
||||
font_ = other.font_;
|
||||
font_apply_ = other.font_apply_;
|
||||
font_id_ = other.font_id_;
|
||||
number_format_ = other.number_format_;
|
||||
number_format_apply_ = other.number_format_apply_;
|
||||
number_format_id_ = other.number_format_id_;
|
||||
protection_ = other.protection_;
|
||||
protection_apply_ = other.protection_apply_;
|
||||
pivot_button_ = other.pivot_button_;
|
||||
quote_prefix_ = other.quote_prefix_;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
std::string format::to_hash_string() const
|
||||
{
|
||||
std::string hash_string("format");
|
||||
|
||||
hash_string.append(std::to_string(alignment_apply_));
|
||||
hash_string.append(alignment_apply_ ? std::to_string(alignment_.hash()) : " ");
|
||||
|
||||
hash_string.append(std::to_string(border_apply_));
|
||||
hash_string.append(border_apply_ ? std::to_string(border_id_) : " ");
|
||||
|
||||
hash_string.append(std::to_string(font_apply_));
|
||||
hash_string.append(font_apply_ ? std::to_string(font_id_) : " ");
|
||||
|
||||
hash_string.append(std::to_string(fill_apply_));
|
||||
hash_string.append(fill_apply_ ? std::to_string(fill_id_) : " ");
|
||||
|
||||
hash_string.append(std::to_string(number_format_apply_));
|
||||
hash_string.append(number_format_apply_ ? std::to_string(number_format_id_) : " ");
|
||||
|
||||
hash_string.append(std::to_string(protection_apply_));
|
||||
hash_string.append(protection_apply_ ? std::to_string(protection_.hash()) : " ");
|
||||
|
||||
return hash_string;
|
||||
}
|
||||
|
||||
const number_format format::get_number_format() const
|
||||
{
|
||||
return number_format_;
|
||||
}
|
||||
|
||||
const border format::get_border() const
|
||||
{
|
||||
return border_;
|
||||
}
|
||||
|
||||
const alignment format::get_alignment() const
|
||||
{
|
||||
return alignment_;
|
||||
}
|
||||
|
||||
const fill format::get_fill() const
|
||||
{
|
||||
return fill_;
|
||||
}
|
||||
|
||||
const font format::get_font() const
|
||||
{
|
||||
return font_;
|
||||
}
|
||||
|
||||
const protection format::get_protection() const
|
||||
{
|
||||
return protection_;
|
||||
}
|
||||
|
||||
bool format::pivot_button() const
|
||||
{
|
||||
return pivot_button_;
|
||||
}
|
||||
|
||||
bool format::quote_prefix() const
|
||||
{
|
||||
return quote_prefix_;
|
||||
}
|
||||
|
||||
std::size_t format::get_id() const
|
||||
{
|
||||
return id_;
|
||||
}
|
||||
|
||||
std::size_t format::get_fill_id() const
|
||||
{
|
||||
return fill_id_;
|
||||
}
|
||||
|
||||
std::size_t format::get_font_id() const
|
||||
{
|
||||
return font_id_;
|
||||
}
|
||||
|
||||
std::size_t format::get_border_id() const
|
||||
{
|
||||
return border_id_;
|
||||
}
|
||||
|
||||
std::size_t format::get_number_format_id() const
|
||||
{
|
||||
return number_format_id_;
|
||||
}
|
||||
|
||||
void format::apply_alignment(bool apply)
|
||||
{
|
||||
alignment_apply_ = apply;
|
||||
}
|
||||
|
||||
void format::apply_border(bool apply)
|
||||
{
|
||||
border_apply_ = apply;
|
||||
}
|
||||
|
||||
void format::apply_fill(bool apply)
|
||||
{
|
||||
fill_apply_ = apply;
|
||||
}
|
||||
|
||||
void format::apply_font(bool apply)
|
||||
{
|
||||
font_apply_ = apply;
|
||||
}
|
||||
|
||||
void format::apply_number_format(bool apply)
|
||||
{
|
||||
number_format_apply_ = apply;
|
||||
}
|
||||
|
||||
void format::apply_protection(bool apply)
|
||||
{
|
||||
protection_apply_ = apply;
|
||||
}
|
||||
|
||||
} // namespace xlnt
|
|
@ -1,108 +0,0 @@
|
|||
// Copyright (c) 2014-2016 Thomas Fussell
|
||||
// Copyright (c) 2010-2015 openpyxl
|
||||
//
|
||||
// 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, WRISING FROM,
|
||||
// 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
|
||||
#include <xlnt/styles/style.hpp>
|
||||
|
||||
namespace {
|
||||
|
||||
template <class T>
|
||||
void hash_combine(std::size_t &seed, const T &v)
|
||||
{
|
||||
std::hash<T> hasher;
|
||||
seed ^= hasher(v) + 0x9e3779b9 + (seed << 6) + (seed >> 2);
|
||||
}
|
||||
}
|
||||
|
||||
namespace xlnt {
|
||||
|
||||
std::string style::to_hash_string() const
|
||||
{
|
||||
std::string hash_string("style");
|
||||
|
||||
hash_string.append(name_);
|
||||
hash_string.append(std::to_string(format_id_));
|
||||
hash_string.append(std::to_string(builtin_id_));
|
||||
hash_string.append(std::to_string(hidden_ ? 0 : 1));
|
||||
|
||||
return hash_string;
|
||||
}
|
||||
|
||||
style::style() : name_("style"), format_id_(0), builtin_id_(0), hidden_(false)
|
||||
{
|
||||
}
|
||||
|
||||
style::style(const style &other) : name_(other.name_), format_id_(other.format_id_), builtin_id_(other.builtin_id_), hidden_(other.hidden_)
|
||||
{
|
||||
}
|
||||
|
||||
style &style::operator=(const xlnt::style &other)
|
||||
{
|
||||
name_ = other.name_;
|
||||
builtin_id_ = other.builtin_id_;
|
||||
format_id_ = other.format_id_;
|
||||
hidden_ = other.hidden_;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
std::string style::get_name() const
|
||||
{
|
||||
return name_;
|
||||
}
|
||||
|
||||
void style::set_name(const std::string &name)
|
||||
{
|
||||
name_ = name;
|
||||
}
|
||||
|
||||
std::size_t style::get_format_id() const
|
||||
{
|
||||
return format_id_;
|
||||
}
|
||||
|
||||
void style::set_format_id(std::size_t format_id)
|
||||
{
|
||||
format_id_ = format_id;
|
||||
}
|
||||
|
||||
std::size_t style::get_builtin_id() const
|
||||
{
|
||||
return builtin_id_;
|
||||
}
|
||||
|
||||
void style::set_builtin_id(std::size_t builtin_id)
|
||||
{
|
||||
builtin_id_ = builtin_id;
|
||||
}
|
||||
|
||||
void style::set_hidden(bool hidden)
|
||||
{
|
||||
hidden_ = hidden;
|
||||
}
|
||||
|
||||
bool style::get_hidden() const
|
||||
{
|
||||
return hidden_;
|
||||
}
|
||||
|
||||
} // namespace xlnt
|
330
source/styles/tests/test_stylesheet.hpp
Normal file
330
source/styles/tests/test_stylesheet.hpp
Normal file
|
@ -0,0 +1,330 @@
|
|||
#pragma once
|
||||
|
||||
#include <iostream>
|
||||
#include <cxxtest/TestSuite.h>
|
||||
|
||||
#include "pugixml.hpp"
|
||||
#include <xlnt/xlnt.hpp>
|
||||
#include <xlnt/packaging/zip_file.hpp>
|
||||
#include <helpers/helper.hpp>
|
||||
#include <helpers/path_helper.hpp>
|
||||
|
||||
class test_number_style : public CxxTest::TestSuite
|
||||
{
|
||||
public:
|
||||
void test_ctor()
|
||||
{
|
||||
xlnt::workbook wb;
|
||||
xlnt::style_serializer style_serializer(wb);
|
||||
xlnt::zip_file archive;
|
||||
auto stylesheet_xml = style_serializer.write_stylesheet().to_string();
|
||||
|
||||
const std::string expected =
|
||||
"<styleSheet xmlns=\"http://schemas.openxmlformats.org/spreadsheetml/2006/main\" xmlns:mc=\"http://schemas.openxmlformats.org/markup-compatibility/2006\" mc:Ignorable=\"x14ac\" xmlns:x14ac=\"http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac\">"
|
||||
" <numFmts count=\"1\">"
|
||||
" <numFmt numFmtId=\"0\" formatCode=\"General\" />"
|
||||
" </numFmts>"
|
||||
" <fonts count=\"1\">"
|
||||
" <font>"
|
||||
" <sz val=\"11\" />"
|
||||
" <color indexed=\"0\" />"
|
||||
" <name val=\"Calibri\" />"
|
||||
" </font>"
|
||||
" </fonts>"
|
||||
" <fills count=\"0\" />"
|
||||
" <borders count=\"0\" />"
|
||||
" <cellStyleXfs count=\"0\" />"
|
||||
" <cellXfs count=\"0\" />"
|
||||
" <cellStyles count=\"0\" />"
|
||||
" <dxfs count=\"0\" />"
|
||||
" <tableStyles count=\"0\" defaultTableStyle=\"TableStyleMedium2\" defaultPivotStyle=\"PivotStyleMedium9\" />"
|
||||
" <extLst>"
|
||||
" <ext uri=\"{EB79DEF2-80B8-43e5-95BD-54CBDDF9020C}\" xmlns:x14=\"http://schemas.microsoft.com/office/spreadsheetml/2009/9/main\">"
|
||||
" <x14:slicerStyles defaultSlicerStyle=\"SlicerStyleLight1\" />"
|
||||
" </ext>"
|
||||
" </extLst>"
|
||||
"</styleSheet>";
|
||||
|
||||
TS_ASSERT(Helper::compare_xml(expected, stylesheet_xml));
|
||||
}
|
||||
|
||||
|
||||
void test_from_simple()
|
||||
{
|
||||
xlnt::xml_document doc;
|
||||
auto xml = PathHelper::read_file(PathHelper::GetDataDirectory("/reader/styles/simple-styles.xml"));
|
||||
doc.from_string(xml);
|
||||
xlnt::workbook wb;
|
||||
xlnt::style_serializer s(wb);
|
||||
TS_ASSERT(s.read_stylesheet(doc));
|
||||
TS_ASSERT_EQUALS(wb.get_number_formats().size(), 1);
|
||||
}
|
||||
|
||||
void test_from_complex()
|
||||
{
|
||||
xlnt::xml_document doc;
|
||||
auto xml = PathHelper::read_file(PathHelper::GetDataDirectory("/reader/styles/complex-styles.xml"));
|
||||
doc.from_string(xml);
|
||||
xlnt::workbook wb;
|
||||
xlnt::style_serializer s(wb);
|
||||
TS_ASSERT(s.read_stylesheet(doc));
|
||||
TS_ASSERT_EQUALS(wb.get_borders().size(), 7);
|
||||
TS_ASSERT_EQUALS(wb.get_fills().size(), 6);
|
||||
TS_ASSERT_EQUALS(wb.get_fonts().size(), 8);
|
||||
TS_ASSERT_EQUALS(wb.get_number_formats().size(), 1);
|
||||
}
|
||||
|
||||
void test_merge_named_styles()
|
||||
{
|
||||
xlnt::xml_document doc;
|
||||
auto xml = PathHelper::read_file(PathHelper::GetDataDirectory("/reader/styles/complex-styles.xml"));
|
||||
doc.from_string(xml);
|
||||
xlnt::workbook wb;
|
||||
xlnt::style_serializer s(wb);
|
||||
TS_ASSERT(s.read_stylesheet(doc));
|
||||
TS_ASSERT_EQUALS(wb.get_named_styles().size(), 3);
|
||||
}
|
||||
/*
|
||||
void _test_unprotected_cell()
|
||||
{
|
||||
datadir.chdir();
|
||||
src = open ("worksheet_unprotected_style.xml");
|
||||
xml = src.read();
|
||||
node = fromstring(xml);
|
||||
stylesheet = Stylesheet.from_tree(node);
|
||||
|
||||
styles = stylesheet.cell_styles;
|
||||
assert len(styles) == 3;
|
||||
// default is cells are locked
|
||||
assert styles[1] == StyleArray([4,0,0,0,0,0,0,0,0]);
|
||||
assert styles[2] == StyleArray([3,0,0,0,1,0,0,0,0]);
|
||||
}
|
||||
|
||||
void _test_read_cell_style()
|
||||
{
|
||||
datadir.chdir();
|
||||
src = open("empty-workbook-styles.xml");
|
||||
xml = src.read();
|
||||
node = fromstring(xml);
|
||||
stylesheet = Stylesheet.from_tree(node);
|
||||
|
||||
styles = stylesheet.cell_styles;
|
||||
assert len(styles) == 2;
|
||||
assert styles[1] == StyleArray([0,0,0,9,0,0,0,0,1];
|
||||
}
|
||||
|
||||
void _test_read_xf_no_number_format()
|
||||
{
|
||||
datadir.chdir();
|
||||
src = open("no_number_format.xml");
|
||||
xml = src.read();
|
||||
node = fromstring(xml);
|
||||
stylesheet = Stylesheet.from_tree(node);
|
||||
|
||||
styles = stylesheet.cell_styles;
|
||||
assert len(styles) == 3;
|
||||
assert styles[1] == StyleArray([1,0,1,0,0,0,0,0,0]);
|
||||
assert styles[2] == StyleArray([0,0,0,14,0,0,0,0,0]);
|
||||
}
|
||||
|
||||
void _test_none_values()
|
||||
{
|
||||
datadir.chdir();
|
||||
src = open("none_value_styles.xml");
|
||||
xml = src.read();
|
||||
node = fromstring(xml);
|
||||
stylesheet = Stylesheet.from_tree(node);
|
||||
|
||||
fonts = stylesheet.fonts;
|
||||
assert fonts[0].scheme is None;
|
||||
assert fonts[0].vertAlign is None;
|
||||
assert fonts[1].u is None;
|
||||
}
|
||||
|
||||
void _test_alignment()
|
||||
{
|
||||
datadir.chdir();
|
||||
src = open("alignment_styles.xml");
|
||||
xml = src.read();
|
||||
node = fromstring(xml);
|
||||
stylesheet = Stylesheet.from_tree(node);
|
||||
|
||||
styles = stylesheet.cell_styles;
|
||||
assert len(styles) == 3;
|
||||
assert styles[2] == StyleArray([0,0,0,0,0,2,0,0,0]);
|
||||
|
||||
assert stylesheet.alignments == [
|
||||
Alignment(),
|
||||
Alignment(textRotation=180),
|
||||
Alignment(vertical='top', textRotation=255),
|
||||
];
|
||||
}
|
||||
|
||||
void _test_rgb_colors()
|
||||
{
|
||||
datadir.chdir();
|
||||
src = open("rgb_colors.xml");
|
||||
xml = src.read();
|
||||
node = fromstring(xml);
|
||||
stylesheet = Stylesheet.from_tree(node);
|
||||
|
||||
assert len(stylesheet.colors.index) == 64;
|
||||
assert stylesheet.colors.index[0] == "00000000";
|
||||
assert stylesheet.colors.index[-1] == "00333333";
|
||||
}
|
||||
|
||||
|
||||
void _test_custom_number_formats()
|
||||
{
|
||||
datadir.chdir();
|
||||
src = open("styles_number_formats.xml", "rb");
|
||||
xml = src.read();
|
||||
node = fromstring(xml);
|
||||
stylesheet = Stylesheet.from_tree(node);
|
||||
|
||||
assert stylesheet.number_formats == [
|
||||
'_ * #,##0.00_ ;_ * \-#,##0.00_ ;_ * "-"??_ ;_ @_ ',
|
||||
"#,##0.00_ ",
|
||||
"yyyy/m/d;@",
|
||||
"0.00000_ "
|
||||
];
|
||||
}
|
||||
|
||||
void _test_assign_number_formats()
|
||||
{
|
||||
node = fromstring(
|
||||
"<styleSheet>"
|
||||
"<numFmts count=\"1\">"
|
||||
" <numFmt numFmtId=\"43\" formatCode=\"_ * #,##0.00_ ;_ * \-#,##0.00_ ;_ * \"-\"??_ ;_ @_ \" />"
|
||||
"</numFmts>"
|
||||
"<cellXfs count=\"0\">"
|
||||
"<xf numFmtId=\"43\" fontId=\"2\" fillId=\"0\" borderId=\"0\""
|
||||
" applyFont=\"0\" applyFill=\"0\" applyBorder=\"0\" applyAlignment=\"0\" applyProtection=\"0\">"
|
||||
" <alignment vertical=\"center\"/>"
|
||||
"</xf>"
|
||||
"</cellXfs>"
|
||||
"</styleSheet>");
|
||||
stylesheet = Stylesheet.from_tree(node);
|
||||
styles = stylesheet.cell_styles;
|
||||
|
||||
assert styles[0] == StyleArray([2, 0, 0, 164, 0, 1, 0, 0, 0]);
|
||||
}
|
||||
|
||||
|
||||
void _test_named_styles()
|
||||
{
|
||||
datadir.chdir();
|
||||
src = open("complex-styles.xml");
|
||||
xml = src.read();
|
||||
node = fromstring(xml);
|
||||
stylesheet = Stylesheet.from_tree(node);
|
||||
|
||||
followed = stylesheet.named_styles['Followed Hyperlink'];
|
||||
assert followed.name == "Followed Hyperlink";
|
||||
assert followed.font == stylesheet.fonts[2];
|
||||
assert followed.fill == DEFAULT_EMPTY_FILL;
|
||||
assert followed.border == Border();
|
||||
|
||||
link = stylesheet.named_styles['Hyperlink'];
|
||||
assert link.name == "Hyperlink";
|
||||
assert link.font == stylesheet.fonts[1];
|
||||
assert link.fill == DEFAULT_EMPTY_FILL;
|
||||
assert link.border == Border();
|
||||
|
||||
normal = stylesheet.named_styles['Normal'];
|
||||
assert normal.name == "Normal";
|
||||
assert normal.font == stylesheet.fonts[0];
|
||||
assert normal.fill == DEFAULT_EMPTY_FILL;
|
||||
assert normal.border == Border();
|
||||
}
|
||||
|
||||
void _test_no_styles()
|
||||
{
|
||||
wb1 = wb2 = Workbook();
|
||||
archive = ZipFile(BytesIO(), "a");
|
||||
apply_stylesheet(archive, wb1);
|
||||
assert wb1._cell_styles == wb2._cell_styles;
|
||||
assert wb2._named_styles == wb2._named_styles;
|
||||
}
|
||||
|
||||
void _test_write_worksheet()
|
||||
{
|
||||
wb = Workbook()
|
||||
node = write_stylesheet(wb);
|
||||
xml = tostring(node);
|
||||
|
||||
const std::string expected =
|
||||
"<styleSheet xmlns=\"http://schemas.openxmlformats.org/spreadsheetml/2006/main\">"
|
||||
" <numFmts count=\"0\" />"
|
||||
" <fonts count=\"1\">"
|
||||
" <font>"
|
||||
" <name val=\"Calibri\"></name>"
|
||||
" <family val=\"2\"></family>"
|
||||
" <color theme=\"1\"></color>"
|
||||
" <sz val=\"11\"></sz>"
|
||||
" <scheme val=\"minor\"></scheme>"
|
||||
" </font>"
|
||||
" </fonts>"
|
||||
" <fills count=\"2\">"
|
||||
" <fill>"
|
||||
" <patternFill></patternFill>"
|
||||
" </fill>"
|
||||
" <fill>"
|
||||
" <patternFill patternType=\"gray125\"></patternFill>"
|
||||
" </fill>"
|
||||
" </fills>"
|
||||
" <borders count=\"1\">"
|
||||
" <border>"
|
||||
" <left></left>"
|
||||
" <right></right>"
|
||||
" <top></top>"
|
||||
" <bottom></bottom>"
|
||||
" <diagonal></diagonal>"
|
||||
" </border>"
|
||||
" </borders>"
|
||||
" <cellStyleXfs count=\"1\">"
|
||||
" <xf borderId=\"0\" fillId=\"0\" fontId=\"0\" numFmtId=\"0\"></xf>"
|
||||
" </cellStyleXfs>"
|
||||
" <cellXfs count=\"1\">"
|
||||
" <xf borderId=\"0\" fillId=\"0\" fontId=\"0\" numFmtId=\"0\" pivotButton=\"0\" quotePrefix=\"0\" xfId=\"0\"></xf>"
|
||||
" </cellXfs>"
|
||||
" <cellStyles count=\"1\">"
|
||||
" <cellStyle builtinId=\"0\" hidden=\"0\" name=\"Normal\" xfId=\"0\"></cellStyle>"
|
||||
" </cellStyles>"
|
||||
"<tableStyles count=\"0\" defaultTableStyle=\"TableStyleMedium9\" defaultPivotStyle=\"PivotStyleLight16\"/>"
|
||||
"</styleSheet>";
|
||||
|
||||
diff = compare_xml(xml, expected);
|
||||
assert diff is None, diff;
|
||||
}
|
||||
|
||||
void _test_simple_styles() {
|
||||
wb = Workbook();
|
||||
wb.guess_types = True;
|
||||
ws = wb.active;
|
||||
now = datetime.date.today();
|
||||
for idx, v in enumerate(['12.34%', now, 'This is a test', '31.31415', None], 1)
|
||||
{
|
||||
ws.append([v]);
|
||||
_ = ws.cell(column=1, row=idx).style_id;
|
||||
}
|
||||
|
||||
// set explicit formats
|
||||
ws['D9'].number_format = numbers.FORMAT_NUMBER_00;
|
||||
ws['D9'].protection = Protection(locked=True);
|
||||
ws['D9'].style_id;
|
||||
ws['E1'].protection = Protection(hidden=True);
|
||||
ws['E1'].style_id;
|
||||
|
||||
assert len(wb._cell_styles) == 5;
|
||||
stylesheet = write_stylesheet(wb);
|
||||
|
||||
datadir.chdir();
|
||||
reference_file = open('simple-styles.xml');
|
||||
expected = reference_file.read();
|
||||
xml = tostring(stylesheet);
|
||||
diff = compare_xml(xml, expected);
|
||||
assert diff is None, diff;
|
||||
}
|
||||
*/
|
||||
};
|
|
@ -664,6 +664,12 @@ std::size_t workbook::add_style(const xlnt::style &style_)
|
|||
return d_->styles_.back().id_;
|
||||
}
|
||||
|
||||
const std::vector<style> &workbook::get_named_styles() const
|
||||
{
|
||||
static std::vector<style> named_styles;
|
||||
return named_styles;
|
||||
}
|
||||
|
||||
color workbook::add_indexed_color(const color &rgb_color)
|
||||
{
|
||||
std::size_t index = 0;
|
||||
|
|
BIN
tests/data/complex-styles.xlsx
Normal file
BIN
tests/data/complex-styles.xlsx
Normal file
Binary file not shown.
47
tests/data/reader/styles/alignment_styles.xml
Normal file
47
tests/data/reader/styles/alignment_styles.xml
Normal file
|
@ -0,0 +1,47 @@
|
|||
<?xml version="1.0"?>
|
||||
<styleSheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main">
|
||||
<numFmts count="0"/>
|
||||
<fonts count="1">
|
||||
<font>
|
||||
<sz val="11"/>
|
||||
<color theme="1"/>
|
||||
<name val="Calibri"/>
|
||||
<family val="2"/>
|
||||
<scheme val="minor"/>
|
||||
</font>
|
||||
</fonts>
|
||||
<fills count="2">
|
||||
<fill>
|
||||
<patternFill patternType="none"/>
|
||||
</fill>
|
||||
<fill>
|
||||
<patternFill patternType="gray125"/>
|
||||
</fill>
|
||||
</fills>
|
||||
<borders count="1">
|
||||
<border>
|
||||
<left/>
|
||||
<right/>
|
||||
<top/>
|
||||
<bottom/>
|
||||
<diagonal/>
|
||||
</border>
|
||||
</borders>
|
||||
<cellStyleXfs count="1">
|
||||
<xf borderId="0" fillId="0" fontId="0" numFmtId="0"/>
|
||||
</cellStyleXfs>
|
||||
<cellXfs count="4">
|
||||
<xf borderId="0" fillId="0" fontId="0" numFmtId="0" xfId="0"/>
|
||||
<xf applyAlignment="1" borderId="0" fillId="0" fontId="0" numFmtId="0" xfId="0">
|
||||
<alignment textRotation="180"/>
|
||||
</xf>
|
||||
<xf applyAlignment="1" borderId="0" fillId="0" fontId="0" numFmtId="0" xfId="0">
|
||||
<alignment textRotation="255" vertical="top"/>
|
||||
</xf>
|
||||
</cellXfs>
|
||||
<cellStyles count="1">
|
||||
<cellStyle builtinId="0" name="Normal" xfId="0"/>
|
||||
</cellStyles>
|
||||
<dxfs count="0"/>
|
||||
<tableStyles count="0" defaultPivotStyle="PivotStyleLight16" defaultTableStyle="TableStyleMedium9"/>
|
||||
</styleSheet>
|
257
tests/data/reader/styles/complex-styles.xml
Normal file
257
tests/data/reader/styles/complex-styles.xml
Normal file
|
@ -0,0 +1,257 @@
|
|||
<?xml version="1.0" standalone="yes"?>
|
||||
<styleSheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:x14ac="http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac" mc:Ignorable="x14ac">
|
||||
<fonts count="8" x14ac:knownFonts="1">
|
||||
<font>
|
||||
<sz val="12"/>
|
||||
<color theme="1"/>
|
||||
<name val="Calibri"/>
|
||||
<family val="2"/>
|
||||
<scheme val="minor"/>
|
||||
</font>
|
||||
<font>
|
||||
<u/>
|
||||
<sz val="12"/>
|
||||
<color theme="10"/>
|
||||
<name val="Calibri"/>
|
||||
<family val="2"/>
|
||||
<scheme val="minor"/>
|
||||
</font>
|
||||
<font>
|
||||
<u/>
|
||||
<sz val="12"/>
|
||||
<color theme="11"/>
|
||||
<name val="Calibri"/>
|
||||
<family val="2"/>
|
||||
<scheme val="minor"/>
|
||||
</font>
|
||||
<font>
|
||||
<b/>
|
||||
<sz val="12"/>
|
||||
<color theme="1"/>
|
||||
<name val="Arial"/>
|
||||
</font>
|
||||
<font>
|
||||
<sz val="10"/>
|
||||
<color theme="1"/>
|
||||
<name val="Arial"/>
|
||||
</font>
|
||||
<font>
|
||||
<i/>
|
||||
<sz val="14"/>
|
||||
<color theme="1"/>
|
||||
<name val="Arial"/>
|
||||
</font>
|
||||
<font>
|
||||
<sz val="12"/>
|
||||
<color rgb="FF3300FF"/>
|
||||
<name val="Calibri"/>
|
||||
<scheme val="minor"/>
|
||||
</font>
|
||||
<font>
|
||||
<sz val="12"/>
|
||||
<color theme="9"/>
|
||||
<name val="Calibri"/>
|
||||
<scheme val="minor"/>
|
||||
</font>
|
||||
</fonts>
|
||||
<fills count="6">
|
||||
<fill>
|
||||
<patternFill patternType="none"/>
|
||||
</fill>
|
||||
<fill>
|
||||
<patternFill patternType="gray125"/>
|
||||
</fill>
|
||||
<fill>
|
||||
<patternFill patternType="solid">
|
||||
<fgColor theme="8"/>
|
||||
<bgColor indexed="64"/>
|
||||
</patternFill>
|
||||
</fill>
|
||||
<fill>
|
||||
<patternFill patternType="solid">
|
||||
<fgColor rgb="FFFFFF66"/>
|
||||
<bgColor indexed="64"/>
|
||||
</patternFill>
|
||||
</fill>
|
||||
<fill>
|
||||
<patternFill patternType="solid">
|
||||
<fgColor rgb="FFCCCCFF"/>
|
||||
<bgColor indexed="64"/>
|
||||
</patternFill>
|
||||
</fill>
|
||||
<fill>
|
||||
<patternFill patternType="solid">
|
||||
<fgColor rgb="FF006600"/>
|
||||
<bgColor indexed="64"/>
|
||||
</patternFill>
|
||||
</fill>
|
||||
</fills>
|
||||
<borders count="7">
|
||||
<border>
|
||||
<left/>
|
||||
<right/>
|
||||
<top/>
|
||||
<bottom/>
|
||||
<diagonal/>
|
||||
</border>
|
||||
<border>
|
||||
<left style="thin">
|
||||
<color rgb="FF006600"/>
|
||||
</left>
|
||||
<right style="thin">
|
||||
<color rgb="FF006600"/>
|
||||
</right>
|
||||
<top style="thin">
|
||||
<color rgb="FF006600"/>
|
||||
</top>
|
||||
<bottom style="thin">
|
||||
<color rgb="FF006600"/>
|
||||
</bottom>
|
||||
<diagonal/>
|
||||
</border>
|
||||
<border>
|
||||
<left style="double">
|
||||
<color theme="7"/>
|
||||
</left>
|
||||
<right style="double">
|
||||
<color theme="7"/>
|
||||
</right>
|
||||
<top style="double">
|
||||
<color theme="7"/>
|
||||
</top>
|
||||
<bottom style="double">
|
||||
<color theme="7"/>
|
||||
</bottom>
|
||||
<diagonal/>
|
||||
</border>
|
||||
<border>
|
||||
<left style="mediumDashed">
|
||||
<color theme="6"/>
|
||||
</left>
|
||||
<right/>
|
||||
<top style="mediumDashed">
|
||||
<color theme="6"/>
|
||||
</top>
|
||||
<bottom/>
|
||||
<diagonal/>
|
||||
</border>
|
||||
<border>
|
||||
<left/>
|
||||
<right style="mediumDashed">
|
||||
<color theme="6"/>
|
||||
</right>
|
||||
<top style="mediumDashed">
|
||||
<color theme="6"/>
|
||||
</top>
|
||||
<bottom/>
|
||||
<diagonal/>
|
||||
</border>
|
||||
<border>
|
||||
<left style="mediumDashed">
|
||||
<color theme="6"/>
|
||||
</left>
|
||||
<right/>
|
||||
<top/>
|
||||
<bottom style="mediumDashed">
|
||||
<color theme="6"/>
|
||||
</bottom>
|
||||
<diagonal/>
|
||||
</border>
|
||||
<border>
|
||||
<left/>
|
||||
<right style="mediumDashed">
|
||||
<color theme="6"/>
|
||||
</right>
|
||||
<top/>
|
||||
<bottom style="mediumDashed">
|
||||
<color theme="6"/>
|
||||
</bottom>
|
||||
<diagonal/>
|
||||
</border>
|
||||
</borders>
|
||||
<cellStyleXfs count="11">
|
||||
<xf numFmtId="0" fontId="0" fillId="0" borderId="0"/>
|
||||
<xf numFmtId="0" fontId="1" fillId="0" borderId="0" applyNumberFormat="0" applyFill="0" applyBorder="0" applyAlignment="0" applyProtection="0"/>
|
||||
<xf numFmtId="0" fontId="2" fillId="0" borderId="0" applyNumberFormat="0" applyFill="0" applyBorder="0" applyAlignment="0" applyProtection="0"/>
|
||||
<xf numFmtId="0" fontId="1" fillId="0" borderId="0" applyNumberFormat="0" applyFill="0" applyBorder="0" applyAlignment="0" applyProtection="0"/>
|
||||
<xf numFmtId="0" fontId="2" fillId="0" borderId="0" applyNumberFormat="0" applyFill="0" applyBorder="0" applyAlignment="0" applyProtection="0"/>
|
||||
<xf numFmtId="0" fontId="1" fillId="0" borderId="0" applyNumberFormat="0" applyFill="0" applyBorder="0" applyAlignment="0" applyProtection="0"/>
|
||||
<xf numFmtId="0" fontId="2" fillId="0" borderId="0" applyNumberFormat="0" applyFill="0" applyBorder="0" applyAlignment="0" applyProtection="0"/>
|
||||
<xf numFmtId="0" fontId="1" fillId="0" borderId="0" applyNumberFormat="0" applyFill="0" applyBorder="0" applyAlignment="0" applyProtection="0"/>
|
||||
<xf numFmtId="0" fontId="2" fillId="0" borderId="0" applyNumberFormat="0" applyFill="0" applyBorder="0" applyAlignment="0" applyProtection="0"/>
|
||||
<xf numFmtId="0" fontId="1" fillId="0" borderId="0" applyNumberFormat="0" applyFill="0" applyBorder="0" applyAlignment="0" applyProtection="0"/>
|
||||
<xf numFmtId="0" fontId="2" fillId="0" borderId="0" applyNumberFormat="0" applyFill="0" applyBorder="0" applyAlignment="0" applyProtection="0"/>
|
||||
</cellStyleXfs>
|
||||
<cellXfs count="29">
|
||||
<xf numFmtId="0" fontId="0" fillId="0" borderId="0" xfId="0"/>
|
||||
<xf numFmtId="0" fontId="3" fillId="0" borderId="0" xfId="0" applyFont="1"/>
|
||||
<xf numFmtId="0" fontId="4" fillId="0" borderId="0" xfId="0" applyFont="1"/>
|
||||
<xf numFmtId="0" fontId="5" fillId="0" borderId="0" xfId="0" applyFont="1"/>
|
||||
<xf numFmtId="0" fontId="6" fillId="0" borderId="0" xfId="0" applyFont="1"/>
|
||||
<xf numFmtId="0" fontId="7" fillId="0" borderId="0" xfId="0" applyFont="1"/>
|
||||
<xf numFmtId="0" fontId="0" fillId="2" borderId="0" xfId="0" applyFill="1"/>
|
||||
<xf numFmtId="0" fontId="0" fillId="3" borderId="0" xfId="0" applyFill="1"/>
|
||||
<xf numFmtId="0" fontId="0" fillId="0" borderId="0" xfId="0" applyAlignment="1">
|
||||
<alignment horizontal="left"/>
|
||||
</xf>
|
||||
<xf numFmtId="0" fontId="0" fillId="0" borderId="0" xfId="0" applyAlignment="1">
|
||||
<alignment horizontal="right"/>
|
||||
</xf>
|
||||
<xf numFmtId="0" fontId="0" fillId="0" borderId="0" xfId="0" applyAlignment="1">
|
||||
<alignment horizontal="center"/>
|
||||
</xf>
|
||||
<xf numFmtId="0" fontId="0" fillId="0" borderId="0" xfId="0" applyAlignment="1">
|
||||
<alignment vertical="top"/>
|
||||
</xf>
|
||||
<xf numFmtId="0" fontId="0" fillId="0" borderId="0" xfId="0" applyAlignment="1">
|
||||
<alignment vertical="center"/>
|
||||
</xf>
|
||||
<xf numFmtId="0" fontId="0" fillId="0" borderId="0" xfId="0" applyAlignment="1"/>
|
||||
<xf numFmtId="2" fontId="0" fillId="0" borderId="0" xfId="0" applyNumberFormat="1"/>
|
||||
<xf numFmtId="14" fontId="0" fillId="0" borderId="0" xfId="0" applyNumberFormat="1"/>
|
||||
<xf numFmtId="10" fontId="0" fillId="0" borderId="0" xfId="0" applyNumberFormat="1"/>
|
||||
<xf numFmtId="0" fontId="0" fillId="0" borderId="0" xfId="0" applyAlignment="1">
|
||||
<alignment horizontal="center"/>
|
||||
</xf>
|
||||
<xf numFmtId="0" fontId="0" fillId="0" borderId="1" xfId="0" applyBorder="1"/>
|
||||
<xf numFmtId="0" fontId="0" fillId="0" borderId="2" xfId="0" applyBorder="1"/>
|
||||
<xf numFmtId="0" fontId="0" fillId="0" borderId="0" xfId="0" applyAlignment="1">
|
||||
<alignment wrapText="1"/>
|
||||
</xf>
|
||||
<xf numFmtId="0" fontId="0" fillId="0" borderId="0" xfId="0" applyAlignment="1">
|
||||
<alignment shrinkToFit="1"/>
|
||||
</xf>
|
||||
<xf numFmtId="0" fontId="0" fillId="0" borderId="0" xfId="0" applyFill="1" applyBorder="1"/>
|
||||
<xf numFmtId="0" fontId="0" fillId="0" borderId="0" xfId="0" applyAlignment="1">
|
||||
<alignment horizontal="center"/>
|
||||
</xf>
|
||||
<xf numFmtId="0" fontId="0" fillId="4" borderId="3" xfId="0" applyFill="1" applyBorder="1" applyAlignment="1">
|
||||
<alignment horizontal="center" vertical="center"/>
|
||||
</xf>
|
||||
<xf numFmtId="0" fontId="0" fillId="4" borderId="4" xfId="0" applyFill="1" applyBorder="1" applyAlignment="1">
|
||||
<alignment horizontal="center" vertical="center"/>
|
||||
</xf>
|
||||
<xf numFmtId="0" fontId="0" fillId="4" borderId="5" xfId="0" applyFill="1" applyBorder="1" applyAlignment="1">
|
||||
<alignment horizontal="center" vertical="center"/>
|
||||
</xf>
|
||||
<xf numFmtId="0" fontId="0" fillId="4" borderId="6" xfId="0" applyFill="1" applyBorder="1" applyAlignment="1">
|
||||
<alignment horizontal="center" vertical="center"/>
|
||||
</xf>
|
||||
<xf numFmtId="0" fontId="6" fillId="5" borderId="0" xfId="0" applyFont="1" applyFill="1"/>
|
||||
</cellXfs>
|
||||
<cellStyles count="11">
|
||||
<cellStyle name="Followed Hyperlink" xfId="2" builtinId="9" hidden="1"/>
|
||||
<cellStyle name="Followed Hyperlink" xfId="4" builtinId="9" hidden="1"/>
|
||||
<cellStyle name="Followed Hyperlink" xfId="6" builtinId="9" hidden="1"/>
|
||||
<cellStyle name="Followed Hyperlink" xfId="8" builtinId="9" hidden="1"/>
|
||||
<cellStyle name="Followed Hyperlink" xfId="10" builtinId="9" hidden="1"/>
|
||||
<cellStyle name="Hyperlink" xfId="1" builtinId="8" hidden="1"/>
|
||||
<cellStyle name="Hyperlink" xfId="3" builtinId="8" hidden="1"/>
|
||||
<cellStyle name="Hyperlink" xfId="5" builtinId="8" hidden="1"/>
|
||||
<cellStyle name="Hyperlink" xfId="7" builtinId="8" hidden="1"/>
|
||||
<cellStyle name="Hyperlink" xfId="9" builtinId="8" hidden="1"/>
|
||||
<cellStyle name="Normal" xfId="0" builtinId="0"/>
|
||||
</cellStyles>
|
||||
<dxfs count="0"/>
|
||||
<tableStyles count="0" defaultTableStyle="TableStyleMedium9" defaultPivotStyle="PivotStyleMedium4"/>
|
||||
</styleSheet>
|
2069
tests/data/reader/styles/dxf_style.xml
Normal file
2069
tests/data/reader/styles/dxf_style.xml
Normal file
File diff suppressed because it is too large
Load Diff
53
tests/data/reader/styles/empty-workbook-styles.xml
Normal file
53
tests/data/reader/styles/empty-workbook-styles.xml
Normal file
|
@ -0,0 +1,53 @@
|
|||
<?xml version="1.0" ?>
|
||||
<styleSheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main">
|
||||
<fonts count="2">
|
||||
<font>
|
||||
<sz val="11" />
|
||||
<color theme="1" />
|
||||
<name val="Calibri" />
|
||||
<family val="2" />
|
||||
<scheme val="minor" />
|
||||
</font>
|
||||
<font>
|
||||
<sz val="11" />
|
||||
<color theme="1" />
|
||||
<name val="Calibri" />
|
||||
<family val="2" />
|
||||
<scheme val="minor" />
|
||||
</font>
|
||||
</fonts>
|
||||
<fills count="2">
|
||||
<fill>
|
||||
<patternFill patternType="none" />
|
||||
</fill>
|
||||
<fill>
|
||||
<patternFill patternType="gray125" />
|
||||
</fill>
|
||||
</fills>
|
||||
<borders count="1">
|
||||
<border>
|
||||
<left />
|
||||
<right />
|
||||
<top />
|
||||
<bottom />
|
||||
<diagonal />
|
||||
</border>
|
||||
</borders>
|
||||
<cellStyleXfs count="2">
|
||||
<xf numFmtId="0" fontId="0" fillId="0" borderId="0" />
|
||||
<xf numFmtId="9" fontId="1" fillId="0" borderId="0" applyFont="0"
|
||||
applyFill="0" applyBorder="0" applyAlignment="0" applyProtection="0" />
|
||||
</cellStyleXfs>
|
||||
<cellXfs count="2">
|
||||
<xf numFmtId="0" fontId="0" fillId="0" borderId="0" xfId="0" />
|
||||
<xf numFmtId="9" fontId="0" fillId="0" borderId="0" xfId="1"
|
||||
applyFont="1" />
|
||||
</cellXfs>
|
||||
<cellStyles count="2">
|
||||
<cellStyle name="Normal" xfId="0" builtinId="0" />
|
||||
<cellStyle name="Percent" xfId="1" builtinId="5" />
|
||||
</cellStyles>
|
||||
<dxfs count="0" />
|
||||
<tableStyles count="0" defaultTableStyle="TableStyleMedium9"
|
||||
defaultPivotStyle="PivotStyleLight16" />
|
||||
</styleSheet>
|
47
tests/data/reader/styles/no_number_format.xml
Normal file
47
tests/data/reader/styles/no_number_format.xml
Normal file
|
@ -0,0 +1,47 @@
|
|||
<?xml version="1.0" ?>
|
||||
<x:styleSheet xmlns:x="http://schemas.openxmlformats.org/spreadsheetml/2006/main">
|
||||
<x:fonts>
|
||||
<x:font>
|
||||
<x:sz val="11"/>
|
||||
<x:color rgb="00000000"/>
|
||||
<x:name val="Calibri"/>
|
||||
</x:font>
|
||||
<x:font>
|
||||
<x:b/>
|
||||
<x:sz val="15"/>
|
||||
<x:color rgb="001F497D"/>
|
||||
<x:name val="Calibri"/>
|
||||
</x:font>
|
||||
</x:fonts>
|
||||
<x:fills>
|
||||
<x:fill>
|
||||
<x:patternFill patternType="none"/>
|
||||
</x:fill>
|
||||
<x:fill>
|
||||
<x:patternFill patternType="gray125"/>
|
||||
</x:fill>
|
||||
</x:fills>
|
||||
<x:borders>
|
||||
<x:border>
|
||||
<x:left/>
|
||||
<x:right/>
|
||||
<x:top/>
|
||||
<x:bottom/>
|
||||
<x:diagonal/>
|
||||
</x:border>
|
||||
<x:border>
|
||||
<x:left/>
|
||||
<x:right/>
|
||||
<x:top/>
|
||||
<x:bottom>
|
||||
<x:color rgb="001F497D"/>
|
||||
</x:bottom>
|
||||
<x:diagonal/>
|
||||
</x:border>
|
||||
</x:borders>
|
||||
<x:cellXfs>
|
||||
<x:xf fontId="0" fillId="0" borderId="0"/>
|
||||
<x:xf fontId="1" fillId="0" borderId="1" applyFont="1"/>
|
||||
<x:xf numFmtId="14" fontId="0" fillId="0" borderId="0" applyNumberFormat="1"/>
|
||||
</x:cellXfs>
|
||||
</x:styleSheet>
|
50
tests/data/reader/styles/none_value_styles.xml
Normal file
50
tests/data/reader/styles/none_value_styles.xml
Normal file
|
@ -0,0 +1,50 @@
|
|||
<?xml version="1.0" standalone="yes"?>
|
||||
<styleSheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:x14ac="http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac" mc:Ignorable="x14ac">
|
||||
<fonts count="2" x14ac:knownFonts="1">
|
||||
<font>
|
||||
<sz val="12"/>
|
||||
<color theme="1"/>
|
||||
<name val="Calibri"/>
|
||||
<family val="2"/>
|
||||
<charset val="136"/>
|
||||
<scheme val="none"/>
|
||||
<vertAlign val="none" />
|
||||
</font>
|
||||
<font>
|
||||
<u val="none"/>
|
||||
<sz val="12"/>
|
||||
<color theme="1"/>
|
||||
<name val="Calibri"/>
|
||||
<scheme val="none"/>
|
||||
</font>
|
||||
</fonts>
|
||||
<fills count="2">
|
||||
<fill>
|
||||
<patternFill patternType="none"/>
|
||||
</fill>
|
||||
<fill>
|
||||
<patternFill patternType="gray125"/>
|
||||
</fill>
|
||||
</fills>
|
||||
<borders count="1">
|
||||
<border>
|
||||
<left/>
|
||||
<right/>
|
||||
<top/>
|
||||
<bottom/>
|
||||
<diagonal/>
|
||||
</border>
|
||||
</borders>
|
||||
<cellStyleXfs count="1">
|
||||
<xf numFmtId="0" fontId="0" fillId="0" borderId="0"/>
|
||||
</cellStyleXfs>
|
||||
<cellXfs count="2">
|
||||
<xf numFmtId="0" fontId="0" fillId="0" borderId="0" xfId="0"/>
|
||||
<xf numFmtId="0" fontId="1" fillId="0" borderId="0" xfId="0" applyFont="1"/>
|
||||
</cellXfs>
|
||||
<cellStyles count="1">
|
||||
<cellStyle name="Standard" xfId="0" builtinId="0"/>
|
||||
</cellStyles>
|
||||
<dxfs count="0"/>
|
||||
<tableStyles count="0" defaultTableStyle="TableStyleMedium9" defaultPivotStyle="PivotStyleMedium4"/>
|
||||
</styleSheet>
|
2024
tests/data/reader/styles/rgb_colors.xml
Executable file
2024
tests/data/reader/styles/rgb_colors.xml
Executable file
File diff suppressed because it is too large
Load Diff
48
tests/data/reader/styles/simple-styles.xml
Normal file
48
tests/data/reader/styles/simple-styles.xml
Normal file
|
@ -0,0 +1,48 @@
|
|||
<?xml version="1.0" ?>
|
||||
<styleSheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main">
|
||||
<numFmts count="1">
|
||||
<numFmt numFmtId="164" formatCode="yyyy-mm-dd"/>
|
||||
</numFmts>
|
||||
<fonts count="1">
|
||||
<font>
|
||||
<name val="Calibri"/>
|
||||
<family val="2"/>
|
||||
<color theme="1"/>
|
||||
<sz val="11"/>
|
||||
<scheme val="minor"/>
|
||||
</font>
|
||||
</fonts>
|
||||
<fills count="2">
|
||||
<fill>
|
||||
<patternFill/>
|
||||
</fill>
|
||||
<fill>
|
||||
<patternFill patternType="gray125"/>
|
||||
</fill>
|
||||
</fills>
|
||||
<borders count="1">
|
||||
<border>
|
||||
<left/>
|
||||
<right/>
|
||||
<top/>
|
||||
<bottom/>
|
||||
<diagonal/>
|
||||
</border>
|
||||
</borders>
|
||||
<cellStyleXfs count="1">
|
||||
<xf numFmtId="0" fontId="0" fillId="0" borderId="0"/>
|
||||
</cellStyleXfs>
|
||||
<cellXfs count="5">
|
||||
<xf borderId="0" fillId="0" fontId="0" numFmtId="0" quotePrefix="0" pivotButton="0" xfId="0"/>
|
||||
<xf borderId="0" fillId="0" fontId="0" numFmtId="9" quotePrefix="0" pivotButton="0" xfId="0"/>
|
||||
<xf borderId="0" fillId="0" fontId="0" numFmtId="164" quotePrefix="0" pivotButton="0" xfId="0"/>
|
||||
<xf borderId="0" fillId="0" fontId="0" numFmtId="2" quotePrefix="0" pivotButton="0" xfId="0"/>
|
||||
<xf applyProtection="1" borderId="0" fillId="0" fontId="0" quotePrefix="0" pivotButton="0" numFmtId="0" xfId="0">
|
||||
<protection hidden="1" locked="1"/>
|
||||
</xf>
|
||||
</cellXfs>
|
||||
<cellStyles count="1">
|
||||
<cellStyle name="Normal" hidden="0" xfId="0" builtinId="0"/>
|
||||
</cellStyles>
|
||||
<tableStyles count="0" defaultTableStyle="TableStyleMedium9" defaultPivotStyle="PivotStyleLight16"/>
|
||||
</styleSheet>
|
112
tests/data/reader/styles/styles_number_formats.xml
Normal file
112
tests/data/reader/styles/styles_number_formats.xml
Normal file
|
@ -0,0 +1,112 @@
|
|||
<?xml version="1.0" standalone="yes"?>
|
||||
<styleSheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:x14ac="http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac" mc:Ignorable="x14ac">
|
||||
<numFmts count="4">
|
||||
<numFmt numFmtId="43" formatCode="_ * #,##0.00_ ;_ * \-#,##0.00_ ;_ * "-"??_ ;_ @_ "/>
|
||||
<numFmt numFmtId="176" formatCode="#,##0.00_ "/>
|
||||
<numFmt numFmtId="180" formatCode="yyyy/m/d;@"/>
|
||||
<numFmt numFmtId="181" formatCode="0.00000_ "/>
|
||||
</numFmts>
|
||||
<fonts count="4">
|
||||
<font>
|
||||
<sz val="11"/>
|
||||
<color theme="1"/>
|
||||
<name val="宋体"/>
|
||||
<family val="2"/>
|
||||
<charset val="134"/>
|
||||
<scheme val="minor"/>
|
||||
</font>
|
||||
<font>
|
||||
<sz val="9"/>
|
||||
<name val="宋体"/>
|
||||
<family val="2"/>
|
||||
<charset val="134"/>
|
||||
<scheme val="minor"/>
|
||||
</font>
|
||||
<font>
|
||||
<sz val="11"/>
|
||||
<color theme="1"/>
|
||||
<name val="宋体"/>
|
||||
<family val="2"/>
|
||||
<charset val="134"/>
|
||||
<scheme val="minor"/>
|
||||
</font>
|
||||
<font>
|
||||
<sz val="9"/>
|
||||
<color indexed="8"/>
|
||||
<name val="仿宋_GB2312"/>
|
||||
<family val="3"/>
|
||||
<charset val="134"/>
|
||||
</font>
|
||||
</fonts>
|
||||
<fills count="2">
|
||||
<fill>
|
||||
<patternFill patternType="none"/>
|
||||
</fill>
|
||||
<fill>
|
||||
<patternFill patternType="gray125"/>
|
||||
</fill>
|
||||
</fills>
|
||||
<borders count="2">
|
||||
<border>
|
||||
<left/>
|
||||
<right/>
|
||||
<top/>
|
||||
<bottom/>
|
||||
<diagonal/>
|
||||
</border>
|
||||
<border>
|
||||
<left style="thin">
|
||||
<color indexed="64"/>
|
||||
</left>
|
||||
<right style="thin">
|
||||
<color indexed="64"/>
|
||||
</right>
|
||||
<top style="thin">
|
||||
<color indexed="64"/>
|
||||
</top>
|
||||
<bottom style="thin">
|
||||
<color indexed="64"/>
|
||||
</bottom>
|
||||
<diagonal/>
|
||||
</border>
|
||||
</borders>
|
||||
<cellStyleXfs count="2">
|
||||
<xf numFmtId="0" fontId="0" fillId="0" borderId="0">
|
||||
<alignment vertical="center"/>
|
||||
</xf>
|
||||
<xf numFmtId="43" fontId="2" fillId="0" borderId="0" applyFont="0" applyFill="0" applyBorder="0" applyAlignment="0" applyProtection="0">
|
||||
<alignment vertical="center"/>
|
||||
</xf>
|
||||
</cellStyleXfs>
|
||||
<cellXfs count="5">
|
||||
<xf numFmtId="0" fontId="0" fillId="0" borderId="0" xfId="0">
|
||||
<alignment vertical="center"/>
|
||||
</xf>
|
||||
<xf numFmtId="176" fontId="3" fillId="0" borderId="1" xfId="0" applyNumberFormat="1" applyFont="1" applyBorder="1" applyAlignment="1">
|
||||
<alignment horizontal="right" vertical="center"/>
|
||||
</xf>
|
||||
<xf numFmtId="43" fontId="3" fillId="0" borderId="1" xfId="1" applyFont="1" applyBorder="1">
|
||||
<alignment vertical="center"/>
|
||||
</xf>
|
||||
<xf numFmtId="180" fontId="3" fillId="0" borderId="1" xfId="0" applyNumberFormat="1" applyFont="1" applyBorder="1" applyAlignment="1">
|
||||
<alignment horizontal="center" vertical="center"/>
|
||||
</xf>
|
||||
<xf numFmtId="181" fontId="3" fillId="0" borderId="1" xfId="0" applyNumberFormat="1" applyFont="1" applyBorder="1">
|
||||
<alignment vertical="center"/>
|
||||
</xf>
|
||||
</cellXfs>
|
||||
<cellStyles count="2">
|
||||
<cellStyle name="常规" xfId="0" builtinId="0"/>
|
||||
<cellStyle name="千位分隔" xfId="1" builtinId="3"/>
|
||||
</cellStyles>
|
||||
<dxfs count="0"/>
|
||||
<tableStyles count="0" defaultTableStyle="TableStyleMedium9" defaultPivotStyle="PivotStyleLight16"/>
|
||||
<extLst>
|
||||
<ext xmlns:x14="http://schemas.microsoft.com/office/spreadsheetml/2009/9/main" uri="{EB79DEF2-80B8-43e5-95BD-54CBDDF9020C}">
|
||||
<x14:slicerStyles defaultSlicerStyle="SlicerStyleLight1"/>
|
||||
</ext>
|
||||
<ext xmlns:x15="http://schemas.microsoft.com/office/spreadsheetml/2010/11/main" uri="{9260A510-F301-46a8-8635-F512D64BE5F5}">
|
||||
<x15:timelineStyles defaultTimelineStyle="TimeSlicerStyleLight1"/>
|
||||
</ext>
|
||||
</extLst>
|
||||
</styleSheet>
|
76
tests/data/reader/styles/worksheet_unprotected_style.xml
Normal file
76
tests/data/reader/styles/worksheet_unprotected_style.xml
Normal file
|
@ -0,0 +1,76 @@
|
|||
<?xml version="1.0" standalone="yes" ?>
|
||||
<styleSheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="x14ac" xmlns:x14ac="http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac">
|
||||
<fonts count="5" x14ac:knownFonts="1">
|
||||
<font>
|
||||
<sz val="12"/>
|
||||
<color theme="1"/>
|
||||
<name val="Calibri"/>
|
||||
<family val="2"/>
|
||||
<scheme val="minor"/>
|
||||
</font>
|
||||
<font>
|
||||
<u/>
|
||||
<sz val="12"/>
|
||||
<color theme="10"/>
|
||||
<name val="Calibri"/>
|
||||
<family val="2"/>
|
||||
<scheme val="minor"/>
|
||||
</font>
|
||||
<font>
|
||||
<u/>
|
||||
<sz val="12"/>
|
||||
<color theme="11"/>
|
||||
<name val="Calibri"/>
|
||||
<family val="2"/>
|
||||
<scheme val="minor"/>
|
||||
</font>
|
||||
<font>
|
||||
<sz val="12"/>
|
||||
<color theme="6"/>
|
||||
<name val="Calibri"/>
|
||||
<scheme val="minor"/>
|
||||
</font>
|
||||
<font>
|
||||
<sz val="12"/>
|
||||
<color theme="5"/>
|
||||
<name val="Calibri"/>
|
||||
<scheme val="minor"/>
|
||||
</font>
|
||||
</fonts>
|
||||
<fills count="2">
|
||||
<fill>
|
||||
<patternFill patternType="none"/>
|
||||
</fill>
|
||||
<fill>
|
||||
<patternFill patternType="gray125"/>
|
||||
</fill>
|
||||
</fills>
|
||||
<borders count="1">
|
||||
<border>
|
||||
<left/>
|
||||
<right/>
|
||||
<top/>
|
||||
<bottom/>
|
||||
<diagonal/>
|
||||
</border>
|
||||
</borders>
|
||||
<cellStyleXfs count="3">
|
||||
<xf numFmtId="0" fontId="0" fillId="0" borderId="0"/>
|
||||
<xf numFmtId="0" fontId="1" fillId="0" borderId="0" applyNumberFormat="0" applyFill="0" applyBorder="0" applyAlignment="0" applyProtection="0"/>
|
||||
<xf numFmtId="0" fontId="2" fillId="0" borderId="0" applyNumberFormat="0" applyFill="0" applyBorder="0" applyAlignment="0" applyProtection="0"/>
|
||||
</cellStyleXfs>
|
||||
<cellXfs count="3">
|
||||
<xf numFmtId="0" fontId="0" fillId="0" borderId="0" xfId="0"/>
|
||||
<xf numFmtId="0" fontId="4" fillId="0" borderId="0" xfId="0" applyFont="1"/>
|
||||
<xf numFmtId="0" fontId="3" fillId="0" borderId="0" xfId="0" applyFont="1" applyProtection="1">
|
||||
<protection locked="0"/>
|
||||
</xf>
|
||||
</cellXfs>
|
||||
<cellStyles count="3">
|
||||
<cellStyle name="Followed Hyperlink" xfId="2" builtinId="9" hidden="1"/>
|
||||
<cellStyle name="Hyperlink" xfId="1" builtinId="8" hidden="1"/>
|
||||
<cellStyle name="Normal" xfId="0" builtinId="0"/>
|
||||
</cellStyles>
|
||||
<dxfs count="0"/>
|
||||
<tableStyles count="0" defaultTableStyle="TableStyleMedium9" defaultPivotStyle="PivotStyleMedium4"/>
|
||||
</styleSheet>
|
Loading…
Reference in New Issue
Block a user