caxlsx 3.3.0 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +25 -0
- data/README.md +25 -7
- data/Rakefile +7 -6
- data/lib/axlsx/content_type/abstract_content_type.rb +11 -9
- data/lib/axlsx/content_type/content_type.rb +7 -9
- data/lib/axlsx/content_type/default.rb +4 -6
- data/lib/axlsx/content_type/override.rb +3 -5
- data/lib/axlsx/doc_props/app.rb +27 -30
- data/lib/axlsx/doc_props/core.rb +9 -12
- data/lib/axlsx/drawing/area_chart.rb +13 -14
- data/lib/axlsx/drawing/area_series.rb +13 -14
- data/lib/axlsx/drawing/ax_data_source.rb +3 -6
- data/lib/axlsx/drawing/axes.rb +10 -9
- data/lib/axlsx/drawing/axis.rb +27 -30
- data/lib/axlsx/drawing/bar_3D_chart.rb +17 -18
- data/lib/axlsx/drawing/bar_chart.rb +16 -17
- data/lib/axlsx/drawing/bar_series.rb +9 -13
- data/lib/axlsx/drawing/bubble_chart.rb +8 -9
- data/lib/axlsx/drawing/bubble_series.rb +9 -10
- data/lib/axlsx/drawing/cat_axis.rb +14 -17
- data/lib/axlsx/drawing/chart.rb +25 -28
- data/lib/axlsx/drawing/d_lbls.rb +29 -26
- data/lib/axlsx/drawing/drawing.rb +60 -62
- data/lib/axlsx/drawing/graphic_frame.rb +6 -7
- data/lib/axlsx/drawing/hyperlink.rb +12 -13
- data/lib/axlsx/drawing/line_3D_chart.rb +13 -15
- data/lib/axlsx/drawing/line_chart.rb +13 -14
- data/lib/axlsx/drawing/line_series.rb +13 -14
- data/lib/axlsx/drawing/marker.rb +14 -16
- data/lib/axlsx/drawing/num_data.rb +13 -16
- data/lib/axlsx/drawing/num_data_source.rb +11 -13
- data/lib/axlsx/drawing/num_val.rb +9 -10
- data/lib/axlsx/drawing/one_cell_anchor.rb +10 -10
- data/lib/axlsx/drawing/pic.rb +57 -22
- data/lib/axlsx/drawing/picture_locking.rb +6 -7
- data/lib/axlsx/drawing/pie_3D_chart.rb +6 -9
- data/lib/axlsx/drawing/pie_series.rb +9 -12
- data/lib/axlsx/drawing/scaling.rb +9 -10
- data/lib/axlsx/drawing/scatter_chart.rb +9 -10
- data/lib/axlsx/drawing/scatter_series.rb +15 -16
- data/lib/axlsx/drawing/ser_axis.rb +9 -11
- data/lib/axlsx/drawing/series.rb +8 -8
- data/lib/axlsx/drawing/series_title.rb +6 -6
- data/lib/axlsx/drawing/str_data.rb +10 -13
- data/lib/axlsx/drawing/str_val.rb +8 -9
- data/lib/axlsx/drawing/title.rb +23 -27
- data/lib/axlsx/drawing/two_cell_anchor.rb +8 -8
- data/lib/axlsx/drawing/val_axis.rb +5 -6
- data/lib/axlsx/drawing/view_3D.rb +32 -30
- data/lib/axlsx/drawing/vml_drawing.rb +19 -20
- data/lib/axlsx/drawing/vml_shape.rb +25 -26
- data/lib/axlsx/package.rb +81 -79
- data/lib/axlsx/rels/relationship.rb +30 -28
- data/lib/axlsx/rels/relationships.rb +7 -8
- data/lib/axlsx/stylesheet/border.rb +7 -8
- data/lib/axlsx/stylesheet/border_pr.rb +8 -8
- data/lib/axlsx/stylesheet/cell_alignment.rb +14 -20
- data/lib/axlsx/stylesheet/cell_protection.rb +6 -7
- data/lib/axlsx/stylesheet/cell_style.rb +12 -14
- data/lib/axlsx/stylesheet/color.rb +15 -12
- data/lib/axlsx/stylesheet/dxf.rb +7 -9
- data/lib/axlsx/stylesheet/fill.rb +3 -5
- data/lib/axlsx/stylesheet/font.rb +24 -21
- data/lib/axlsx/stylesheet/gradient_fill.rb +9 -9
- data/lib/axlsx/stylesheet/gradient_stop.rb +7 -6
- data/lib/axlsx/stylesheet/num_fmt.rb +9 -14
- data/lib/axlsx/stylesheet/pattern_fill.rb +8 -8
- data/lib/axlsx/stylesheet/styles.rb +104 -98
- data/lib/axlsx/stylesheet/table_style.rb +8 -9
- data/lib/axlsx/stylesheet/table_style_element.rb +7 -8
- data/lib/axlsx/stylesheet/table_styles.rb +8 -10
- data/lib/axlsx/stylesheet/xf.rb +21 -22
- data/lib/axlsx/util/accessors.rb +6 -6
- data/lib/axlsx/util/buffered_zip_output_stream.rb +60 -0
- data/lib/axlsx/util/constants.rb +119 -108
- data/lib/axlsx/util/mime_type_utils.rb +11 -0
- data/lib/axlsx/util/options_parser.rb +4 -3
- data/lib/axlsx/util/serialized_attributes.rb +45 -21
- data/lib/axlsx/util/simple_typed_list.rb +58 -57
- data/lib/axlsx/util/storage.rb +38 -41
- data/lib/axlsx/util/validators.rb +107 -44
- data/lib/axlsx/util/zip_command.rb +10 -12
- data/lib/axlsx/version.rb +3 -2
- data/lib/axlsx/workbook/defined_name.rb +11 -8
- data/lib/axlsx/workbook/defined_names.rb +4 -3
- data/lib/axlsx/workbook/shared_strings_table.rb +10 -11
- data/lib/axlsx/workbook/workbook.rb +121 -114
- data/lib/axlsx/workbook/workbook_view.rb +8 -11
- data/lib/axlsx/workbook/workbook_views.rb +4 -4
- data/lib/axlsx/workbook/worksheet/auto_filter/auto_filter.rb +72 -14
- data/lib/axlsx/workbook/worksheet/auto_filter/filter_column.rb +11 -7
- data/lib/axlsx/workbook/worksheet/auto_filter/filters.rb +24 -21
- data/lib/axlsx/workbook/worksheet/auto_filter/sort_condition.rb +51 -0
- data/lib/axlsx/workbook/worksheet/auto_filter/sort_state.rb +56 -0
- data/lib/axlsx/workbook/worksheet/border_creator.rb +30 -25
- data/lib/axlsx/workbook/worksheet/break.rb +4 -5
- data/lib/axlsx/workbook/worksheet/cell.rb +92 -65
- data/lib/axlsx/workbook/worksheet/cell_serializer.rb +32 -28
- data/lib/axlsx/workbook/worksheet/cfvo.rb +7 -5
- data/lib/axlsx/workbook/worksheet/cfvos.rb +5 -5
- data/lib/axlsx/workbook/worksheet/col.rb +9 -10
- data/lib/axlsx/workbook/worksheet/col_breaks.rb +8 -7
- data/lib/axlsx/workbook/worksheet/color_scale.rb +16 -16
- data/lib/axlsx/workbook/worksheet/cols.rb +9 -7
- data/lib/axlsx/workbook/worksheet/comment.rb +12 -11
- data/lib/axlsx/workbook/worksheet/comments.rb +10 -12
- data/lib/axlsx/workbook/worksheet/conditional_formatting.rb +12 -8
- data/lib/axlsx/workbook/worksheet/conditional_formatting_rule.rb +19 -21
- data/lib/axlsx/workbook/worksheet/conditional_formattings.rb +5 -5
- data/lib/axlsx/workbook/worksheet/data_bar.rb +29 -30
- data/lib/axlsx/workbook/worksheet/data_validation.rb +34 -33
- data/lib/axlsx/workbook/worksheet/data_validations.rb +5 -6
- data/lib/axlsx/workbook/worksheet/date_time_converter.rb +8 -8
- data/lib/axlsx/workbook/worksheet/dimension.rb +9 -6
- data/lib/axlsx/workbook/worksheet/header_footer.rb +4 -3
- data/lib/axlsx/workbook/worksheet/icon_set.rb +24 -8
- data/lib/axlsx/workbook/worksheet/merged_cells.rb +10 -10
- data/lib/axlsx/workbook/worksheet/outline_pr.rb +6 -3
- data/lib/axlsx/workbook/worksheet/page_margins.rb +17 -12
- data/lib/axlsx/workbook/worksheet/page_set_up_pr.rb +6 -4
- data/lib/axlsx/workbook/worksheet/page_setup.rb +128 -129
- data/lib/axlsx/workbook/worksheet/pane.rb +27 -26
- data/lib/axlsx/workbook/worksheet/pivot_table.rb +23 -25
- data/lib/axlsx/workbook/worksheet/pivot_table_cache_definition.rb +12 -13
- data/lib/axlsx/workbook/worksheet/pivot_tables.rb +5 -4
- data/lib/axlsx/workbook/worksheet/print_options.rb +3 -2
- data/lib/axlsx/workbook/worksheet/protected_range.rb +6 -5
- data/lib/axlsx/workbook/worksheet/protected_ranges.rb +12 -10
- data/lib/axlsx/workbook/worksheet/rich_text.rb +6 -6
- data/lib/axlsx/workbook/worksheet/rich_text_run.rb +35 -17
- data/lib/axlsx/workbook/worksheet/row.rb +30 -22
- data/lib/axlsx/workbook/worksheet/row_breaks.rb +8 -7
- data/lib/axlsx/workbook/worksheet/selection.rb +16 -16
- data/lib/axlsx/workbook/worksheet/sheet_calc_pr.rb +10 -7
- data/lib/axlsx/workbook/worksheet/sheet_data.rb +7 -7
- data/lib/axlsx/workbook/worksheet/sheet_format_pr.rb +23 -19
- data/lib/axlsx/workbook/worksheet/sheet_pr.rb +11 -7
- data/lib/axlsx/workbook/worksheet/sheet_protection.rb +21 -20
- data/lib/axlsx/workbook/worksheet/sheet_view.rb +48 -53
- data/lib/axlsx/workbook/worksheet/table.rb +13 -13
- data/lib/axlsx/workbook/worksheet/table_style_info.rb +6 -5
- data/lib/axlsx/workbook/worksheet/tables.rb +7 -5
- data/lib/axlsx/workbook/worksheet/worksheet.rb +92 -63
- data/lib/axlsx/workbook/worksheet/worksheet_comments.rb +10 -8
- data/lib/axlsx/workbook/worksheet/worksheet_drawing.rb +11 -4
- data/lib/axlsx/workbook/worksheet/worksheet_hyperlink.rb +9 -8
- data/lib/axlsx/workbook/worksheet/worksheet_hyperlinks.rb +7 -5
- data/lib/axlsx.rb +75 -47
- data/lib/caxlsx.rb +3 -2
- metadata +50 -44
@@ -1,16 +1,13 @@
|
|
1
|
-
#
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
2
3
|
module Axlsx
|
3
|
-
|
4
|
-
|
5
4
|
# CellAlignment stores information about the cell alignment of a style Xf Object.
|
6
5
|
# @note Using Styles#add_style is the recommended way to manage cell alignment.
|
7
6
|
# @see Styles#add_style
|
8
7
|
class CellAlignment
|
9
|
-
|
10
|
-
|
11
8
|
include Axlsx::SerializedAttributes
|
12
9
|
include Axlsx::OptionsParser
|
13
|
-
|
10
|
+
|
14
11
|
serializable_attributes :horizontal, :vertical, :text_rotation, :wrap_text, :indent, :relative_indent, :justify_last_line, :shrink_to_fit, :reading_order
|
15
12
|
# Create a new cell_alignment object
|
16
13
|
# @option options [Symbol] horizontal
|
@@ -22,12 +19,10 @@ module Axlsx
|
|
22
19
|
# @option options [Boolean] justify_last_line
|
23
20
|
# @option options [Boolean] shrink_to_fit
|
24
21
|
# @option options [Integer] reading_order
|
25
|
-
def initialize(options={})
|
22
|
+
def initialize(options = {})
|
26
23
|
parse_options options
|
27
24
|
end
|
28
25
|
|
29
|
-
|
30
|
-
|
31
26
|
# The horizontal alignment of the cell.
|
32
27
|
# @note
|
33
28
|
# The horizontal cell alignement style must be one of
|
@@ -91,42 +86,41 @@ module Axlsx
|
|
91
86
|
alias :readingOrder :reading_order
|
92
87
|
|
93
88
|
# @see horizontal
|
94
|
-
def horizontal=(v) Axlsx
|
89
|
+
def horizontal=(v) Axlsx.validate_horizontal_alignment v; @horizontal = v end
|
95
90
|
# @see vertical
|
96
|
-
def vertical=(v) Axlsx
|
91
|
+
def vertical=(v) Axlsx.validate_vertical_alignment v; @vertical = v end
|
97
92
|
# @see textRotation
|
98
|
-
def text_rotation=(v) Axlsx
|
93
|
+
def text_rotation=(v) Axlsx.validate_unsigned_int v; @text_rotation = v end
|
99
94
|
alias :textRotation= :text_rotation=
|
100
95
|
|
101
96
|
# @see wrapText
|
102
|
-
def wrap_text=(v) Axlsx
|
97
|
+
def wrap_text=(v) Axlsx.validate_boolean v; @wrap_text = v end
|
103
98
|
alias :wrapText= :wrap_text=
|
104
99
|
|
105
100
|
# @see indent
|
106
|
-
def indent=(v) Axlsx
|
101
|
+
def indent=(v) Axlsx.validate_unsigned_int v; @indent = v end
|
107
102
|
|
108
103
|
# @see relativeIndent
|
109
|
-
def relative_indent=(v) Axlsx
|
104
|
+
def relative_indent=(v) Axlsx.validate_int v; @relative_indent = v end
|
110
105
|
alias :relativeIndent= :relative_indent=
|
111
106
|
|
112
107
|
# @see justifyLastLine
|
113
|
-
def justify_last_line=(v) Axlsx
|
108
|
+
def justify_last_line=(v) Axlsx.validate_boolean v; @justify_last_line = v end
|
114
109
|
alias :justifyLastLine= :justify_last_line=
|
115
110
|
|
116
111
|
# @see shrinkToFit
|
117
|
-
def shrink_to_fit=(v) Axlsx
|
112
|
+
def shrink_to_fit=(v) Axlsx.validate_boolean v; @shrink_to_fit = v end
|
118
113
|
alias :shrinkToFit= :shrink_to_fit=
|
119
114
|
|
120
115
|
# @see readingOrder
|
121
|
-
def reading_order=(v) Axlsx
|
116
|
+
def reading_order=(v) Axlsx.validate_unsigned_int v; @reading_order = v end
|
122
117
|
alias :readingOrder= :reading_order=
|
123
118
|
|
124
119
|
# Serializes the object
|
125
120
|
# @param [String] str
|
126
121
|
# @return [String]
|
127
|
-
def to_xml_string(str = '')
|
122
|
+
def to_xml_string(str = +'')
|
128
123
|
serialized_tag('alignment', str)
|
129
124
|
end
|
130
|
-
|
131
125
|
end
|
132
126
|
end
|
@@ -1,10 +1,10 @@
|
|
1
|
-
#
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
2
3
|
module Axlsx
|
3
4
|
# CellProtection stores information about locking or hiding cells in spreadsheet.
|
4
5
|
# @note Using Styles#add_style is the recommended way to manage cell protection.
|
5
6
|
# @see Styles#add_style
|
6
7
|
class CellProtection
|
7
|
-
|
8
8
|
include Axlsx::OptionsParser
|
9
9
|
include Axlsx::SerializedAttributes
|
10
10
|
|
@@ -21,21 +21,20 @@ module Axlsx
|
|
21
21
|
# Creates a new CellProtection
|
22
22
|
# @option options [Boolean] hidden value for hidden protection
|
23
23
|
# @option options [Boolean] locked value for locked protection
|
24
|
-
def initialize(options={})
|
24
|
+
def initialize(options = {})
|
25
25
|
parse_options options
|
26
26
|
end
|
27
27
|
|
28
28
|
# @see hidden
|
29
|
-
def hidden=(v) Axlsx
|
29
|
+
def hidden=(v) Axlsx.validate_boolean v; @hidden = v end
|
30
30
|
# @see locked
|
31
|
-
def locked=(v) Axlsx
|
31
|
+
def locked=(v) Axlsx.validate_boolean v; @locked = v end
|
32
32
|
|
33
33
|
# Serializes the object
|
34
34
|
# @param [String] str
|
35
35
|
# @return [String]
|
36
|
-
def to_xml_string(str = '')
|
36
|
+
def to_xml_string(str = +'')
|
37
37
|
serialized_tag('protection', str)
|
38
38
|
end
|
39
|
-
|
40
39
|
end
|
41
40
|
end
|
@@ -1,10 +1,10 @@
|
|
1
|
-
#
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
2
3
|
module Axlsx
|
3
4
|
# CellStyle defines named styles that reference defined formatting records and can be used in your worksheet.
|
4
5
|
# @note Using Styles#add_style is the recommended way to manage cell styling.
|
5
6
|
# @see Styles#add_style
|
6
7
|
class CellStyle
|
7
|
-
|
8
8
|
include Axlsx::OptionsParser
|
9
9
|
include Axlsx::SerializedAttributes
|
10
10
|
|
@@ -15,7 +15,7 @@ module Axlsx
|
|
15
15
|
# @option options [Integer] iLevel
|
16
16
|
# @option options [Boolean] hidden
|
17
17
|
# @option options [Boolean] customBuiltIn
|
18
|
-
def initialize(options={})
|
18
|
+
def initialize(options = {})
|
19
19
|
parse_options options
|
20
20
|
end
|
21
21
|
|
@@ -39,7 +39,7 @@ module Axlsx
|
|
39
39
|
# @return [Integer]
|
40
40
|
attr_reader :iLevel
|
41
41
|
|
42
|
-
# Determines if this named style should show in the list of styles when using
|
42
|
+
# Determines if this named style should show in the list of styles when using Excel
|
43
43
|
# @return [Boolean]
|
44
44
|
attr_reader :hidden
|
45
45
|
|
@@ -47,26 +47,24 @@ module Axlsx
|
|
47
47
|
# @return [Boolean]
|
48
48
|
attr_reader :customBuiltin
|
49
49
|
|
50
|
-
|
51
|
-
def name=(v)
|
50
|
+
# @see name
|
51
|
+
def name=(v) Axlsx.validate_string v; @name = v end
|
52
52
|
# @see xfId
|
53
|
-
def xfId=(v) Axlsx
|
53
|
+
def xfId=(v) Axlsx.validate_unsigned_int v; @xfId = v end
|
54
54
|
# @see builtinId
|
55
|
-
def builtinId=(v) Axlsx
|
55
|
+
def builtinId=(v) Axlsx.validate_unsigned_int v; @builtinId = v end
|
56
56
|
# @see iLivel
|
57
|
-
def iLevel=(v) Axlsx
|
57
|
+
def iLevel=(v) Axlsx.validate_unsigned_int v; @iLevel = v end
|
58
58
|
# @see hidden
|
59
|
-
def hidden=(v) Axlsx
|
59
|
+
def hidden=(v) Axlsx.validate_boolean v; @hidden = v end
|
60
60
|
# @see customBuiltin
|
61
|
-
def customBuiltin=(v) Axlsx
|
61
|
+
def customBuiltin=(v) Axlsx.validate_boolean v; @customBuiltin = v end
|
62
62
|
|
63
63
|
# Serializes the object
|
64
64
|
# @param [String] str
|
65
65
|
# @return [String]
|
66
|
-
def to_xml_string(str = '')
|
66
|
+
def to_xml_string(str = +'')
|
67
67
|
serialized_tag('cellStyle', str)
|
68
68
|
end
|
69
|
-
|
70
69
|
end
|
71
|
-
|
72
70
|
end
|
@@ -1,8 +1,8 @@
|
|
1
|
-
#
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
2
3
|
module Axlsx
|
3
4
|
# The color class represents a color used for borders, fills an fonts
|
4
5
|
class Color
|
5
|
-
|
6
6
|
include Axlsx::OptionsParser
|
7
7
|
include Axlsx::SerializedAttributes
|
8
8
|
|
@@ -10,7 +10,7 @@ module Axlsx
|
|
10
10
|
# @option options [Boolean] auto
|
11
11
|
# @option options [String] rgb
|
12
12
|
# @option options [Float] tint
|
13
|
-
def initialize(options={})
|
13
|
+
def initialize(options = {})
|
14
14
|
@rgb = "FF000000"
|
15
15
|
parse_options options
|
16
16
|
end
|
@@ -39,26 +39,29 @@ module Axlsx
|
|
39
39
|
|
40
40
|
# no support for theme just yet
|
41
41
|
# @return [Integer]
|
42
|
-
#attr_reader :theme
|
42
|
+
# attr_reader :theme
|
43
43
|
|
44
44
|
# The tint value.
|
45
45
|
# @note valid values are between -1.0 and 1.0
|
46
46
|
# @return [Float]
|
47
47
|
attr_reader :tint
|
48
48
|
|
49
|
-
|
50
|
-
def auto=(v) Axlsx
|
49
|
+
# @see auto
|
50
|
+
def auto=(v) Axlsx.validate_boolean v; @auto = v end
|
51
|
+
|
51
52
|
# @see color
|
52
53
|
def rgb=(v)
|
53
|
-
Axlsx
|
54
|
+
Axlsx.validate_string(v)
|
54
55
|
v = v.upcase
|
55
|
-
v
|
56
|
+
v *= 3 if v.size == 2
|
56
57
|
v = v.rjust(8, 'FF')
|
57
|
-
raise ArgumentError, "Invalid color rgb value: #{v}." unless
|
58
|
+
raise ArgumentError, "Invalid color rgb value: #{v}." unless /[0-9A-F]{8}/.match?(v)
|
59
|
+
|
58
60
|
@rgb = v
|
59
61
|
end
|
62
|
+
|
60
63
|
# @see tint
|
61
|
-
def tint=(v) Axlsx
|
64
|
+
def tint=(v) Axlsx.validate_float v; @tint = v end
|
62
65
|
|
63
66
|
# This version does not support themes
|
64
67
|
# def theme=(v) Axlsx::validate_unsigned_integer v; @theme = v end
|
@@ -69,8 +72,8 @@ module Axlsx
|
|
69
72
|
# Serializes the object
|
70
73
|
# @param [String] str
|
71
74
|
# @return [String]
|
72
|
-
def to_xml_string(str = '', tag_name = 'color')
|
73
|
-
serialized_tag(
|
75
|
+
def to_xml_string(str = +'', tag_name = 'color')
|
76
|
+
serialized_tag(tag_name.to_s, str)
|
74
77
|
end
|
75
78
|
end
|
76
79
|
end
|
data/lib/axlsx/stylesheet/dxf.rb
CHANGED
@@ -1,15 +1,15 @@
|
|
1
|
-
#
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
2
3
|
module Axlsx
|
3
4
|
# The Dxf class defines an incremental formatting record for use in Styles. The recommended way to manage styles for your workbook is with Styles#add_style
|
4
5
|
# @see Styles#add_style
|
5
6
|
class Dxf
|
6
|
-
|
7
7
|
include Axlsx::OptionsParser
|
8
8
|
|
9
9
|
# The order in which the child elements is put in the XML seems to
|
10
10
|
# be important for Excel
|
11
|
-
CHILD_ELEMENTS = [:font, :numFmt, :fill, :alignment, :border, :protection]
|
12
|
-
#does not support extList (ExtensionList)
|
11
|
+
CHILD_ELEMENTS = [:font, :numFmt, :fill, :alignment, :border, :protection].freeze
|
12
|
+
# does not support extList (ExtensionList)
|
13
13
|
|
14
14
|
# The cell alignment for this style
|
15
15
|
# @return [CellAlignment]
|
@@ -44,7 +44,7 @@ module Axlsx
|
|
44
44
|
# @option options [Font] font
|
45
45
|
# @option options [CellAlignment] alignment
|
46
46
|
# @option options [CellProtection] protection
|
47
|
-
def initialize(options={})
|
47
|
+
def initialize(options = {})
|
48
48
|
parse_options options
|
49
49
|
end
|
50
50
|
|
@@ -64,16 +64,14 @@ module Axlsx
|
|
64
64
|
# Serializes the object
|
65
65
|
# @param [String] str
|
66
66
|
# @return [String]
|
67
|
-
def to_xml_string(str = '')
|
67
|
+
def to_xml_string(str = +'')
|
68
68
|
str << '<dxf>'
|
69
69
|
# Dxf elements have no attributes. All of the instance variables
|
70
70
|
# are child elements.
|
71
71
|
CHILD_ELEMENTS.each do |element|
|
72
|
-
|
72
|
+
send(element).to_xml_string(str) if send(element)
|
73
73
|
end
|
74
74
|
str << '</dxf>'
|
75
75
|
end
|
76
|
-
|
77
76
|
end
|
78
|
-
|
79
77
|
end
|
@@ -1,4 +1,5 @@
|
|
1
|
-
#
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
2
3
|
module Axlsx
|
3
4
|
# The Fill is a formatting object that manages the background color, and pattern for cells.
|
4
5
|
# @note The recommended way to manage styles in your workbook is to use Styles#add_style.
|
@@ -6,7 +7,6 @@ module Axlsx
|
|
6
7
|
# @see PatternFill
|
7
8
|
# @see GradientFill
|
8
9
|
class Fill
|
9
|
-
|
10
10
|
# The type of fill
|
11
11
|
# @return [PatternFill, GradientFill]
|
12
12
|
attr_reader :fill_type
|
@@ -21,7 +21,7 @@ module Axlsx
|
|
21
21
|
# Serializes the object
|
22
22
|
# @param [String] str
|
23
23
|
# @return [String]
|
24
|
-
def to_xml_string(str = '')
|
24
|
+
def to_xml_string(str = +'')
|
25
25
|
str << '<fill>'
|
26
26
|
@fill_type.to_xml_string(str)
|
27
27
|
str << '</fill>'
|
@@ -29,7 +29,5 @@ module Axlsx
|
|
29
29
|
|
30
30
|
# @see fill_type
|
31
31
|
def fill_type=(v) DataTypeValidator.validate "Fill.fill_type", [PatternFill, GradientFill], v; @fill_type = v; end
|
32
|
-
|
33
|
-
|
34
32
|
end
|
35
33
|
end
|
@@ -1,4 +1,5 @@
|
|
1
|
-
#
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
2
3
|
module Axlsx
|
3
4
|
# The Font class details a font instance for use in styling cells.
|
4
5
|
# @note The recommended way to manage fonts, and other styles is Styles#add_style
|
@@ -21,7 +22,7 @@ module Axlsx
|
|
21
22
|
# @option options [Boolean] extend
|
22
23
|
# @option options [Color] color
|
23
24
|
# @option options [Integer] sz
|
24
|
-
def initialize(options={})
|
25
|
+
def initialize(options = {})
|
25
26
|
parse_options options
|
26
27
|
end
|
27
28
|
|
@@ -100,7 +101,7 @@ module Axlsx
|
|
100
101
|
|
101
102
|
# The font's extend property
|
102
103
|
# @return [Boolean]
|
103
|
-
attr_reader
|
104
|
+
attr_reader :extend
|
104
105
|
|
105
106
|
# The color of the font
|
106
107
|
# @return [Color]
|
@@ -110,45 +111,47 @@ module Axlsx
|
|
110
111
|
# @return [Integer]
|
111
112
|
attr_reader :sz
|
112
113
|
|
113
|
-
|
114
|
-
def name=(v) Axlsx
|
114
|
+
# @see name
|
115
|
+
def name=(v) Axlsx.validate_string v; @name = v end
|
115
116
|
# @see charset
|
116
|
-
def charset=(v) Axlsx
|
117
|
+
def charset=(v) Axlsx.validate_unsigned_int v; @charset = v end
|
117
118
|
# @see family
|
118
|
-
def family=(v) Axlsx
|
119
|
+
def family=(v) Axlsx.validate_unsigned_int v; @family = v end
|
119
120
|
# @see b
|
120
|
-
def b=(v) Axlsx
|
121
|
+
def b=(v) Axlsx.validate_boolean v; @b = v end
|
121
122
|
# @see i
|
122
|
-
def i=(v) Axlsx
|
123
|
+
def i=(v) Axlsx.validate_boolean v; @i = v end
|
124
|
+
|
123
125
|
# @see u
|
124
126
|
def u=(v)
|
125
|
-
v = :single if
|
126
|
-
v = :none if
|
127
|
-
Axlsx
|
127
|
+
v = :single if v == true || v == 1 || v == :true || v == 'true'
|
128
|
+
v = :none if v == false || v == 0 || v == :false || v == 'false'
|
129
|
+
Axlsx.validate_cell_u v
|
128
130
|
@u = v
|
129
131
|
end
|
132
|
+
|
130
133
|
# @see strike
|
131
|
-
def strike=(v) Axlsx
|
134
|
+
def strike=(v) Axlsx.validate_boolean v; @strike = v end
|
132
135
|
# @see outline
|
133
|
-
def outline=(v) Axlsx
|
136
|
+
def outline=(v) Axlsx.validate_boolean v; @outline = v end
|
134
137
|
# @see shadow
|
135
|
-
def shadow=(v) Axlsx
|
138
|
+
def shadow=(v) Axlsx.validate_boolean v; @shadow = v end
|
136
139
|
# @see condense
|
137
|
-
def condense=(v) Axlsx
|
140
|
+
def condense=(v) Axlsx.validate_boolean v; @condense = v end
|
138
141
|
# @see extend
|
139
|
-
def extend=(v) Axlsx
|
142
|
+
def extend=(v) Axlsx.validate_boolean v; @extend = v end
|
140
143
|
# @see color
|
141
|
-
def color=(v) DataTypeValidator.validate "Font.color", Color, v; @color=v end
|
144
|
+
def color=(v) DataTypeValidator.validate "Font.color", Color, v; @color = v end
|
142
145
|
# @see sz
|
143
|
-
def sz=(v) Axlsx
|
146
|
+
def sz=(v) Axlsx.validate_unsigned_int v; @sz = v end
|
144
147
|
|
145
148
|
# Serializes the object
|
146
149
|
# @param [String] str
|
147
150
|
# @return [String]
|
148
|
-
def to_xml_string(str = '')
|
151
|
+
def to_xml_string(str = +'')
|
149
152
|
str << '<font>'
|
150
153
|
Axlsx.instance_values_for(self).each do |k, v|
|
151
|
-
v.is_a?(Color) ? v.to_xml_string(str) : (str <<
|
154
|
+
v.is_a?(Color) ? v.to_xml_string(str) : (str << '<' << k.to_s << ' val="' << Axlsx.booleanize(v).to_s << '"/>')
|
152
155
|
end
|
153
156
|
str << '</font>'
|
154
157
|
end
|
@@ -1,9 +1,9 @@
|
|
1
|
-
#
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
2
3
|
module Axlsx
|
3
4
|
# A GradientFill defines the color and positioning for gradiant cell fill.
|
4
5
|
# @see Open Office XML Part 1 §18.8.24
|
5
6
|
class GradientFill
|
6
|
-
|
7
7
|
include Axlsx::OptionsParser
|
8
8
|
include Axlsx::SerializedAttributes
|
9
9
|
|
@@ -14,7 +14,7 @@ module Axlsx
|
|
14
14
|
# @option options [Float] right
|
15
15
|
# @option options [Float] top
|
16
16
|
# @option options [Float] bottom
|
17
|
-
def initialize(options={})
|
17
|
+
def initialize(options = {})
|
18
18
|
options[:type] ||= :linear
|
19
19
|
parse_options options
|
20
20
|
@stop = SimpleTypedList.new GradientStop
|
@@ -55,10 +55,10 @@ module Axlsx
|
|
55
55
|
attr_reader :stop
|
56
56
|
|
57
57
|
# @see type
|
58
|
-
def type=(v) Axlsx
|
58
|
+
def type=(v) Axlsx.validate_gradient_type v; @type = v end
|
59
59
|
|
60
60
|
# @see degree
|
61
|
-
def degree=(v) Axlsx
|
61
|
+
def degree=(v) Axlsx.validate_float v; @degree = v end
|
62
62
|
|
63
63
|
# @see left
|
64
64
|
def left=(v)
|
@@ -68,8 +68,8 @@ module Axlsx
|
|
68
68
|
|
69
69
|
# @see right
|
70
70
|
def right=(v)
|
71
|
-
|
72
|
-
|
71
|
+
validate_format_percentage "GradientFill.right", v
|
72
|
+
@right = v
|
73
73
|
end
|
74
74
|
|
75
75
|
# @see top
|
@@ -86,13 +86,13 @@ module Axlsx
|
|
86
86
|
|
87
87
|
# validates that the value provided is between 0.0 and 1.0
|
88
88
|
def validate_format_percentage(name, value)
|
89
|
-
DataTypeValidator.validate name, Float, value,
|
89
|
+
DataTypeValidator.validate name, Float, value, ->(arg) { arg >= 0.0 && arg <= 1.0 }
|
90
90
|
end
|
91
91
|
|
92
92
|
# Serializes the object
|
93
93
|
# @param [String] str
|
94
94
|
# @return [String]
|
95
|
-
def to_xml_string(str = '')
|
95
|
+
def to_xml_string(str = +'')
|
96
96
|
str << '<gradientFill '
|
97
97
|
serialized_attributes str
|
98
98
|
str << '>'
|
@@ -1,4 +1,5 @@
|
|
1
|
-
#
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
2
3
|
module Axlsx
|
3
4
|
# The GradientStop object represents a color point in a gradient.
|
4
5
|
# @see Open Office XML Part 1 §18.8.24
|
@@ -21,16 +22,16 @@ module Axlsx
|
|
21
22
|
end
|
22
23
|
|
23
24
|
# @see color
|
24
|
-
def color=(v) DataTypeValidator.validate "GradientStop.color", Color, v; @color=v end
|
25
|
+
def color=(v) DataTypeValidator.validate "GradientStop.color", Color, v; @color = v end
|
25
26
|
# @see position
|
26
|
-
def position=(v) DataTypeValidator.validate "GradientStop.position", Float, v,
|
27
|
+
def position=(v) DataTypeValidator.validate "GradientStop.position", Float, v, ->(arg) { arg >= 0 && arg <= 1 }; @position = v end
|
27
28
|
|
28
29
|
# Serializes the object
|
29
30
|
# @param [String] str
|
30
31
|
# @return [String]
|
31
|
-
def to_xml_string(str = '')
|
32
|
-
str <<
|
33
|
-
|
32
|
+
def to_xml_string(str = +'')
|
33
|
+
str << '<stop position="' << position.to_s << '">'
|
34
|
+
color.to_xml_string(str)
|
34
35
|
str << '</stop>'
|
35
36
|
end
|
36
37
|
end
|
@@ -1,9 +1,9 @@
|
|
1
|
-
#
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
2
3
|
module Axlsx
|
3
4
|
# A NumFmt object defines an identifier and formatting code for data in cells.
|
4
5
|
# @note The recommended way to manage styles is Styles#add_style
|
5
6
|
class NumFmt
|
6
|
-
|
7
7
|
include Axlsx::OptionsParser
|
8
8
|
include Axlsx::SerializedAttributes
|
9
9
|
|
@@ -11,7 +11,7 @@ module Axlsx
|
|
11
11
|
# @param [Hash] options Options for the number format object
|
12
12
|
# @option [Integer] numFmtId The predefined format id or new format id for this format
|
13
13
|
# @option [String] formatCode The format code for this number format
|
14
|
-
def initialize(options={})
|
14
|
+
def initialize(options = {})
|
15
15
|
@numFmtId = 0
|
16
16
|
@formatCode = ""
|
17
17
|
parse_options options
|
@@ -20,7 +20,7 @@ module Axlsx
|
|
20
20
|
serializable_attributes :formatCode, :numFmtId
|
21
21
|
|
22
22
|
# @return [String] The formatting to use for this number format.
|
23
|
-
# @see
|
23
|
+
# @see https://support.microsoft.com/kb/264372
|
24
24
|
attr_reader :formatCode
|
25
25
|
|
26
26
|
# @return [Integer] An unsigned integer referencing a standard or custom number format.
|
@@ -61,26 +61,21 @@ module Axlsx
|
|
61
61
|
attr_reader :numFmtId
|
62
62
|
|
63
63
|
# @see numFmtId
|
64
|
-
def numFmtId=(v) Axlsx
|
64
|
+
def numFmtId=(v) Axlsx.validate_unsigned_int v; @numFmtId = v end
|
65
65
|
|
66
66
|
# @see formatCode
|
67
|
-
def formatCode=(v) Axlsx
|
67
|
+
def formatCode=(v) Axlsx.validate_string v; @formatCode = v end
|
68
68
|
|
69
69
|
# Serializes the object
|
70
70
|
# @param [String] str
|
71
71
|
# @return [String]
|
72
|
-
def to_xml_string(str = '')
|
72
|
+
def to_xml_string(str = +'')
|
73
73
|
serialized_tag('numFmt', str)
|
74
74
|
end
|
75
75
|
|
76
76
|
# Override to avoid removing underscores
|
77
|
-
def serialized_attributes(str = '', additional_attributes = {})
|
78
|
-
|
79
|
-
attributes.each do |key, value|
|
80
|
-
str << "#{Axlsx.camel(key, false)}=\"#{Axlsx.booleanize(value)}\" "
|
81
|
-
end
|
82
|
-
str
|
77
|
+
def serialized_attributes(str = +'', additional_attributes = {})
|
78
|
+
super(str, additional_attributes, false)
|
83
79
|
end
|
84
|
-
|
85
80
|
end
|
86
81
|
end
|
@@ -1,16 +1,16 @@
|
|
1
|
-
#
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
2
3
|
module Axlsx
|
3
4
|
# A PatternFill is the pattern and solid fill styling for a cell.
|
4
5
|
# @note The recommended way to manage styles is with Styles#add_style
|
5
6
|
# @see Style#add_style
|
6
7
|
class PatternFill
|
7
|
-
|
8
8
|
include Axlsx::OptionsParser
|
9
9
|
# Creates a new PatternFill Object
|
10
10
|
# @option options [Symbol] patternType
|
11
11
|
# @option options [Color] fgColor
|
12
12
|
# @option options [Color] bgColor
|
13
|
-
def initialize(options={})
|
13
|
+
def initialize(options = {})
|
14
14
|
@patternType = :none
|
15
15
|
parse_options options
|
16
16
|
end
|
@@ -49,17 +49,17 @@ module Axlsx
|
|
49
49
|
attr_reader :patternType
|
50
50
|
|
51
51
|
# @see fgColor
|
52
|
-
def fgColor=(v) DataTypeValidator.validate "PatternFill.fgColor", Color, v; @fgColor=v end
|
52
|
+
def fgColor=(v) DataTypeValidator.validate "PatternFill.fgColor", Color, v; @fgColor = v end
|
53
53
|
# @see bgColor
|
54
|
-
def bgColor=(v) DataTypeValidator.validate "PatternFill.bgColor", Color, v; @bgColor=v end
|
54
|
+
def bgColor=(v) DataTypeValidator.validate "PatternFill.bgColor", Color, v; @bgColor = v end
|
55
55
|
# @see patternType
|
56
|
-
def patternType=(v) Axlsx
|
56
|
+
def patternType=(v) Axlsx.validate_pattern_type v; @patternType = v end
|
57
57
|
|
58
58
|
# Serializes the object
|
59
59
|
# @param [String] str
|
60
60
|
# @return [String]
|
61
|
-
def to_xml_string(str = '')
|
62
|
-
str <<
|
61
|
+
def to_xml_string(str = +'')
|
62
|
+
str << '<patternFill patternType="' << patternType.to_s << '">'
|
63
63
|
if fgColor.is_a?(Color)
|
64
64
|
fgColor.to_xml_string str, "fgColor"
|
65
65
|
end
|