caxlsx 3.3.0 → 3.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -0
- data/README.md +24 -5
- data/Rakefile +0 -1
- data/lib/axlsx/content_type/abstract_content_type.rb +2 -5
- data/lib/axlsx/content_type/content_type.rb +0 -4
- data/lib/axlsx/content_type/default.rb +1 -5
- data/lib/axlsx/content_type/override.rb +0 -4
- data/lib/axlsx/doc_props/app.rb +1 -6
- data/lib/axlsx/doc_props/core.rb +1 -6
- data/lib/axlsx/drawing/area_chart.rb +3 -6
- data/lib/axlsx/drawing/area_series.rb +1 -4
- data/lib/axlsx/drawing/ax_data_source.rb +1 -6
- data/lib/axlsx/drawing/axes.rb +5 -6
- data/lib/axlsx/drawing/axis.rb +7 -12
- data/lib/axlsx/drawing/bar_3D_chart.rb +7 -10
- data/lib/axlsx/drawing/bar_chart.rb +6 -9
- data/lib/axlsx/drawing/bar_series.rb +2 -8
- data/lib/axlsx/drawing/bubble_chart.rb +2 -5
- data/lib/axlsx/drawing/bubble_series.rb +3 -6
- data/lib/axlsx/drawing/cat_axis.rb +2 -7
- data/lib/axlsx/drawing/chart.rb +7 -12
- data/lib/axlsx/drawing/d_lbls.rb +23 -22
- data/lib/axlsx/drawing/drawing.rb +4 -8
- data/lib/axlsx/drawing/graphic_frame.rb +0 -3
- data/lib/axlsx/drawing/hyperlink.rb +4 -7
- data/lib/axlsx/drawing/line_3D_chart.rb +10 -14
- data/lib/axlsx/drawing/line_chart.rb +3 -6
- data/lib/axlsx/drawing/line_series.rb +1 -4
- data/lib/axlsx/drawing/marker.rb +5 -9
- data/lib/axlsx/drawing/num_data.rb +4 -9
- data/lib/axlsx/drawing/num_data_source.rb +3 -7
- data/lib/axlsx/drawing/num_val.rb +2 -5
- data/lib/axlsx/drawing/one_cell_anchor.rb +4 -6
- data/lib/axlsx/drawing/pic.rb +46 -13
- data/lib/axlsx/drawing/picture_locking.rb +3 -6
- data/lib/axlsx/drawing/pie_3D_chart.rb +2 -7
- data/lib/axlsx/drawing/pie_series.rb +1 -6
- data/lib/axlsx/drawing/scaling.rb +2 -5
- data/lib/axlsx/drawing/scatter_chart.rb +2 -5
- data/lib/axlsx/drawing/scatter_series.rb +2 -5
- data/lib/axlsx/drawing/ser_axis.rb +2 -6
- data/lib/axlsx/drawing/series.rb +3 -5
- data/lib/axlsx/drawing/series_title.rb +0 -2
- data/lib/axlsx/drawing/str_data.rb +3 -8
- data/lib/axlsx/drawing/str_val.rb +2 -5
- data/lib/axlsx/drawing/title.rb +12 -15
- data/lib/axlsx/drawing/two_cell_anchor.rb +5 -7
- data/lib/axlsx/drawing/val_axis.rb +1 -4
- data/lib/axlsx/drawing/view_3D.rb +24 -24
- data/lib/axlsx/drawing/vml_drawing.rb +2 -5
- data/lib/axlsx/drawing/vml_shape.rb +4 -7
- data/lib/axlsx/package.rb +35 -36
- data/lib/axlsx/rels/relationship.rb +21 -24
- data/lib/axlsx/rels/relationships.rb +3 -6
- data/lib/axlsx/stylesheet/border.rb +1 -4
- data/lib/axlsx/stylesheet/border_pr.rb +3 -5
- data/lib/axlsx/stylesheet/cell_alignment.rb +2 -10
- data/lib/axlsx/stylesheet/cell_protection.rb +1 -4
- data/lib/axlsx/stylesheet/cell_style.rb +3 -7
- data/lib/axlsx/stylesheet/color.rb +6 -5
- data/lib/axlsx/stylesheet/dxf.rb +2 -6
- data/lib/axlsx/stylesheet/fill.rb +0 -4
- data/lib/axlsx/stylesheet/font.rb +7 -6
- data/lib/axlsx/stylesheet/gradient_fill.rb +4 -6
- data/lib/axlsx/stylesheet/gradient_stop.rb +2 -3
- data/lib/axlsx/stylesheet/num_fmt.rb +1 -4
- data/lib/axlsx/stylesheet/pattern_fill.rb +3 -5
- data/lib/axlsx/stylesheet/styles.rb +53 -45
- data/lib/axlsx/stylesheet/table_style.rb +5 -8
- data/lib/axlsx/stylesheet/table_style_element.rb +1 -4
- data/lib/axlsx/stylesheet/table_styles.rb +3 -7
- data/lib/axlsx/stylesheet/xf.rb +3 -6
- data/lib/axlsx/util/accessors.rb +2 -4
- data/lib/axlsx/util/constants.rb +3 -5
- data/lib/axlsx/util/mime_type_utils.rb +13 -0
- data/lib/axlsx/util/options_parser.rb +1 -2
- data/lib/axlsx/util/serialized_attributes.rb +4 -5
- data/lib/axlsx/util/simple_typed_list.rb +18 -17
- data/lib/axlsx/util/storage.rb +32 -36
- data/lib/axlsx/util/validators.rb +7 -4
- data/lib/axlsx/util/zip_command.rb +0 -2
- data/lib/axlsx/version.rb +1 -2
- data/lib/axlsx/workbook/defined_name.rb +6 -5
- data/lib/axlsx/workbook/defined_names.rb +1 -2
- data/lib/axlsx/workbook/shared_strings_table.rb +3 -6
- data/lib/axlsx/workbook/workbook.rb +96 -91
- data/lib/axlsx/workbook/workbook_view.rb +5 -10
- data/lib/axlsx/workbook/workbook_views.rb +1 -3
- data/lib/axlsx/workbook/worksheet/auto_filter/auto_filter.rb +9 -8
- data/lib/axlsx/workbook/worksheet/auto_filter/filter_column.rb +6 -6
- data/lib/axlsx/workbook/worksheet/auto_filter/filters.rb +13 -14
- data/lib/axlsx/workbook/worksheet/border_creator.rb +29 -26
- data/lib/axlsx/workbook/worksheet/break.rb +2 -5
- data/lib/axlsx/workbook/worksheet/cell.rb +46 -26
- data/lib/axlsx/workbook/worksheet/cell_serializer.rb +11 -11
- data/lib/axlsx/workbook/worksheet/cfvo.rb +2 -2
- data/lib/axlsx/workbook/worksheet/cfvos.rb +3 -5
- data/lib/axlsx/workbook/worksheet/col.rb +4 -7
- data/lib/axlsx/workbook/worksheet/col_breaks.rb +4 -5
- data/lib/axlsx/workbook/worksheet/color_scale.rb +10 -12
- data/lib/axlsx/workbook/worksheet/cols.rb +6 -6
- data/lib/axlsx/workbook/worksheet/comment.rb +4 -5
- data/lib/axlsx/workbook/worksheet/comments.rb +6 -10
- data/lib/axlsx/workbook/worksheet/conditional_formatting.rb +4 -5
- data/lib/axlsx/workbook/worksheet/conditional_formatting_rule.rb +2 -6
- data/lib/axlsx/workbook/worksheet/conditional_formattings.rb +2 -4
- data/lib/axlsx/workbook/worksheet/data_bar.rb +20 -22
- data/lib/axlsx/workbook/worksheet/data_validation.rb +4 -5
- data/lib/axlsx/workbook/worksheet/data_validations.rb +2 -5
- data/lib/axlsx/workbook/worksheet/date_time_converter.rb +1 -3
- data/lib/axlsx/workbook/worksheet/dimension.rb +5 -4
- data/lib/axlsx/workbook/worksheet/header_footer.rb +0 -1
- data/lib/axlsx/workbook/worksheet/icon_set.rb +2 -3
- data/lib/axlsx/workbook/worksheet/merged_cells.rb +8 -8
- data/lib/axlsx/workbook/worksheet/outline_pr.rb +0 -1
- data/lib/axlsx/workbook/worksheet/page_margins.rb +2 -2
- data/lib/axlsx/workbook/worksheet/page_set_up_pr.rb +1 -3
- data/lib/axlsx/workbook/worksheet/page_setup.rb +117 -120
- data/lib/axlsx/workbook/worksheet/pane.rb +16 -17
- data/lib/axlsx/workbook/worksheet/pivot_table.rb +8 -11
- data/lib/axlsx/workbook/worksheet/pivot_table_cache_definition.rb +8 -11
- data/lib/axlsx/workbook/worksheet/pivot_tables.rb +3 -4
- data/lib/axlsx/workbook/worksheet/print_options.rb +0 -1
- data/lib/axlsx/workbook/worksheet/protected_range.rb +4 -5
- data/lib/axlsx/workbook/worksheet/protected_ranges.rb +9 -9
- data/lib/axlsx/workbook/worksheet/rich_text.rb +4 -6
- data/lib/axlsx/workbook/worksheet/rich_text_run.rb +21 -5
- data/lib/axlsx/workbook/worksheet/row.rb +24 -15
- data/lib/axlsx/workbook/worksheet/row_breaks.rb +3 -4
- data/lib/axlsx/workbook/worksheet/selection.rb +7 -9
- data/lib/axlsx/workbook/worksheet/sheet_calc_pr.rb +5 -6
- data/lib/axlsx/workbook/worksheet/sheet_data.rb +4 -6
- data/lib/axlsx/workbook/worksheet/sheet_format_pr.rb +18 -18
- data/lib/axlsx/workbook/worksheet/sheet_pr.rb +4 -4
- data/lib/axlsx/workbook/worksheet/sheet_protection.rb +12 -13
- data/lib/axlsx/workbook/worksheet/sheet_view.rb +35 -42
- data/lib/axlsx/workbook/worksheet/table.rb +7 -9
- data/lib/axlsx/workbook/worksheet/table_style_info.rb +2 -3
- data/lib/axlsx/workbook/worksheet/tables.rb +4 -4
- data/lib/axlsx/workbook/worksheet/worksheet.rb +63 -35
- data/lib/axlsx/workbook/worksheet/worksheet_comments.rb +6 -6
- data/lib/axlsx/workbook/worksheet/worksheet_drawing.rb +3 -2
- data/lib/axlsx/workbook/worksheet/worksheet_hyperlink.rb +5 -6
- data/lib/axlsx/workbook/worksheet/worksheet_hyperlinks.rb +4 -4
- data/lib/axlsx.rb +23 -9
- data/lib/caxlsx.rb +0 -1
- metadata +3 -3
@@ -1,8 +1,6 @@
|
|
1
1
|
module Axlsx
|
2
|
-
|
3
2
|
# The RichTextRun class creates and self serializing text run.
|
4
3
|
class RichTextRun
|
5
|
-
|
6
4
|
include Axlsx::OptionsParser
|
7
5
|
|
8
6
|
attr_reader :value
|
@@ -13,7 +11,7 @@ module Axlsx
|
|
13
11
|
:shadow, :condense, :extend, :u,
|
14
12
|
:vertAlign, :sz, :color, :scheme].freeze
|
15
13
|
|
16
|
-
def initialize(value, options={})
|
14
|
+
def initialize(value, options = {})
|
17
15
|
self.value = value
|
18
16
|
parse_options(options)
|
19
17
|
end
|
@@ -27,6 +25,7 @@ module Axlsx
|
|
27
25
|
# The inline font_name property for the cell
|
28
26
|
# @return [String]
|
29
27
|
attr_reader :font_name
|
28
|
+
|
30
29
|
# @see font_name
|
31
30
|
def font_name=(v) set_run_style :validate_string, :font_name, v; end
|
32
31
|
|
@@ -53,6 +52,7 @@ module Axlsx
|
|
53
52
|
# 255  OEM_CHARSET
|
54
53
|
# @return [String]
|
55
54
|
attr_reader :charset
|
55
|
+
|
56
56
|
# @see charset
|
57
57
|
def charset=(v) set_run_style :validate_unsigned_int, :charset, v; end
|
58
58
|
|
@@ -64,6 +64,7 @@ module Axlsx
|
|
64
64
|
# 4 Script
|
65
65
|
# 5 Decorative
|
66
66
|
attr_reader :family
|
67
|
+
|
67
68
|
# @see family
|
68
69
|
def family=(v)
|
69
70
|
set_run_style :validate_family, :family, v.to_i
|
@@ -72,42 +73,49 @@ module Axlsx
|
|
72
73
|
# The inline bold property for the cell
|
73
74
|
# @return [Boolean]
|
74
75
|
attr_reader :b
|
76
|
+
|
75
77
|
# @see b
|
76
78
|
def b=(v) set_run_style :validate_boolean, :b, v; end
|
77
79
|
|
78
80
|
# The inline italic property for the cell
|
79
81
|
# @return [Boolean]
|
80
82
|
attr_reader :i
|
83
|
+
|
81
84
|
# @see i
|
82
85
|
def i=(v) set_run_style :validate_boolean, :i, v; end
|
83
86
|
|
84
87
|
# The inline strike property for the cell
|
85
88
|
# @return [Boolean]
|
86
89
|
attr_reader :strike
|
90
|
+
|
87
91
|
# @see strike
|
88
92
|
def strike=(v) set_run_style :validate_boolean, :strike, v; end
|
89
93
|
|
90
94
|
# The inline outline property for the cell
|
91
95
|
# @return [Boolean]
|
92
96
|
attr_reader :outline
|
97
|
+
|
93
98
|
# @see outline
|
94
99
|
def outline=(v) set_run_style :validate_boolean, :outline, v; end
|
95
100
|
|
96
101
|
# The inline shadow property for the cell
|
97
102
|
# @return [Boolean]
|
98
103
|
attr_reader :shadow
|
104
|
+
|
99
105
|
# @see shadow
|
100
106
|
def shadow=(v) set_run_style :validate_boolean, :shadow, v; end
|
101
107
|
|
102
108
|
# The inline condense property for the cell
|
103
109
|
# @return [Boolean]
|
104
110
|
attr_reader :condense
|
111
|
+
|
105
112
|
# @see condense
|
106
113
|
def condense=(v) set_run_style :validate_boolean, :condense, v; end
|
107
114
|
|
108
115
|
# The inline extend property for the cell
|
109
116
|
# @return [Boolean]
|
110
117
|
attr_reader :extend
|
118
|
+
|
111
119
|
# @see extend
|
112
120
|
def extend=(v) set_run_style :validate_boolean, :extend, v; end
|
113
121
|
|
@@ -117,6 +125,7 @@ module Axlsx
|
|
117
125
|
# @return [String]
|
118
126
|
# @note true is for backwards compatability and is reassigned to :single
|
119
127
|
attr_reader :u
|
128
|
+
|
120
129
|
# @see u
|
121
130
|
def u=(v)
|
122
131
|
v = :single if (v == true || v == 1 || v == :true || v == 'true')
|
@@ -126,14 +135,16 @@ module Axlsx
|
|
126
135
|
# The inline color property for the cell
|
127
136
|
# @return [Color]
|
128
137
|
attr_reader :color
|
138
|
+
|
129
139
|
# @param [String] v The 8 character representation for an rgb color #FFFFFFFF"
|
130
140
|
def color=(v)
|
131
|
-
@color = v.is_a?(Color) ? v : Color.new(:rgb=>v)
|
141
|
+
@color = v.is_a?(Color) ? v : Color.new(:rgb => v)
|
132
142
|
end
|
133
143
|
|
134
144
|
# The inline sz property for the cell
|
135
145
|
# @return [Inteter]
|
136
146
|
attr_reader :sz
|
147
|
+
|
137
148
|
# @see sz
|
138
149
|
def sz=(v) set_run_style :validate_unsigned_int, :sz, v; end
|
139
150
|
|
@@ -141,6 +152,7 @@ module Axlsx
|
|
141
152
|
# this must be one of [:baseline, :subscript, :superscript]
|
142
153
|
# @return [Symbol]
|
143
154
|
attr_reader :vertAlign
|
155
|
+
|
144
156
|
# @see vertAlign
|
145
157
|
def vertAlign=(v)
|
146
158
|
RestrictionValidator.validate :cell_vertAlign, [:baseline, :subscript, :superscript], v
|
@@ -151,6 +163,7 @@ module Axlsx
|
|
151
163
|
# this must be one of [:none, major, minor]
|
152
164
|
# @return [Symbol]
|
153
165
|
attr_reader :scheme
|
166
|
+
|
154
167
|
# @see scheme
|
155
168
|
def scheme=(v)
|
156
169
|
RestrictionValidator.validate :cell_scheme, [:none, :major, :minor], v
|
@@ -162,6 +175,7 @@ module Axlsx
|
|
162
175
|
# @return [Array]
|
163
176
|
def autowidth(widtharray)
|
164
177
|
return if value.nil?
|
178
|
+
|
165
179
|
if styles.cellXfs[style].alignment && styles.cellXfs[style].alignment.wrap_text
|
166
180
|
first = true
|
167
181
|
value.to_s.split(/\r?\n/, -1).each do |line|
|
@@ -181,6 +195,7 @@ module Axlsx
|
|
181
195
|
# Utility method for setting inline style attributes
|
182
196
|
def set_run_style(validator, attr, value)
|
183
197
|
return unless INLINE_STYLES.include?(attr.to_sym)
|
198
|
+
|
184
199
|
Axlsx.send(validator, value) unless validator.nil?
|
185
200
|
self.instance_variable_set :"@#{attr.to_s}", value
|
186
201
|
end
|
@@ -190,7 +205,7 @@ module Axlsx
|
|
190
205
|
# @return [String]
|
191
206
|
def to_xml_string(str = '')
|
192
207
|
valid = RichTextRun::INLINE_STYLES
|
193
|
-
data = Hash[Axlsx.instance_values_for(self).map{ |k, v| [k.to_sym, v] }]
|
208
|
+
data = Hash[Axlsx.instance_values_for(self).map { |k, v| [k.to_sym, v] }]
|
194
209
|
data = data.select { |key, value| valid.include?(key) && !value.nil? }
|
195
210
|
|
196
211
|
str << '<r><rPr>'
|
@@ -223,6 +238,7 @@ module Axlsx
|
|
223
238
|
# imagemagick and loading metrics for every character.
|
224
239
|
def font_size
|
225
240
|
return sz if sz
|
241
|
+
|
226
242
|
font = styles.fonts[styles.cellXfs[style].fontId] || styles.fonts[0]
|
227
243
|
(font.b || (defined?(@b) && @b)) ? (font.sz * 1.5) : font.sz
|
228
244
|
end
|
@@ -1,4 +1,3 @@
|
|
1
|
-
# encoding: UTF-8
|
2
1
|
module Axlsx
|
3
2
|
# A Row is a single row in a worksheet.
|
4
3
|
# @note The recommended way to manage rows and cells is to use Worksheet#add_row
|
@@ -6,13 +5,13 @@ module Axlsx
|
|
6
5
|
class Row < SimpleTypedList
|
7
6
|
include SerializedAttributes
|
8
7
|
include Accessors
|
9
|
-
|
8
|
+
|
10
9
|
# No support is provided for the following attributes
|
11
10
|
# spans
|
12
11
|
# thickTop
|
13
12
|
# thickBottom
|
14
13
|
|
15
|
-
|
14
|
+
# Creates a new row. New Cell objects are created based on the values, types and style options.
|
16
15
|
# A new cell is created for each item in the values array. style and types options are applied as follows:
|
17
16
|
# If the types option is defined and is a symbol it is applied to all the cells created.
|
18
17
|
# If the types option is an array, cell types are applied by index for each cell
|
@@ -24,11 +23,12 @@ module Axlsx
|
|
24
23
|
# @option options [Array] values
|
25
24
|
# @option options [Array, Symbol] types
|
26
25
|
# @option options [Array, Integer] style
|
26
|
+
# @option options [Array, Boolean] escape_formulas
|
27
27
|
# @option options [Float] height the row's height (in points)
|
28
28
|
# @option options [Integer] offset - add empty columns before values
|
29
29
|
# @see Row#array_to_cells
|
30
30
|
# @see Cell
|
31
|
-
def initialize(worksheet, values=[], options={})
|
31
|
+
def initialize(worksheet, values = [], options = {})
|
32
32
|
self.worksheet = worksheet
|
33
33
|
super(Cell, nil, values.size + options[:offset].to_i)
|
34
34
|
self.height = options.delete(:height)
|
@@ -64,7 +64,7 @@ module Axlsx
|
|
64
64
|
# @see Row#s
|
65
65
|
def s=(v)
|
66
66
|
Axlsx.validate_unsigned_numeric(v)
|
67
|
-
@custom_format = true
|
67
|
+
@custom_format = true
|
68
68
|
@s = v
|
69
69
|
end
|
70
70
|
|
@@ -73,7 +73,7 @@ module Axlsx
|
|
73
73
|
Axlsx.validate_unsigned_numeric(v)
|
74
74
|
@outline_level = v
|
75
75
|
end
|
76
|
-
|
76
|
+
|
77
77
|
alias :outlineLevel= :outline_level=
|
78
78
|
|
79
79
|
# The index of this row in the worksheet
|
@@ -104,20 +104,29 @@ module Axlsx
|
|
104
104
|
c
|
105
105
|
end
|
106
106
|
|
107
|
-
#
|
107
|
+
# Sets the color for every cell in this row.
|
108
108
|
def color=(color)
|
109
|
-
each_with_index do |
|
109
|
+
each_with_index do |cell, index|
|
110
110
|
cell.color = color.is_a?(Array) ? color[index] : color
|
111
111
|
end
|
112
112
|
end
|
113
113
|
|
114
|
-
#
|
114
|
+
# Sets the style for every cell in this row.
|
115
115
|
def style=(style)
|
116
|
-
each_with_index do |
|
116
|
+
each_with_index do |cell, index|
|
117
117
|
cell.style = style.is_a?(Array) ? style[index] : style
|
118
118
|
end
|
119
119
|
end
|
120
120
|
|
121
|
+
# Sets escape_formulas for every cell in this row. This determines whether to treat
|
122
|
+
# values starting with an equals sign as formulas or as literal strings.
|
123
|
+
# @param [Array, Boolean] value The value to set.
|
124
|
+
def escape_formulas=(value)
|
125
|
+
each_with_index do |cell, index|
|
126
|
+
cell.escape_formulas = value.is_a?(Array) ? value[index] : value
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
121
130
|
# @see height
|
122
131
|
def height=(v)
|
123
132
|
unless v.nil?
|
@@ -126,7 +135,7 @@ module Axlsx
|
|
126
135
|
@ht = v
|
127
136
|
end
|
128
137
|
end
|
129
|
-
|
138
|
+
|
130
139
|
# return cells
|
131
140
|
def cells
|
132
141
|
self
|
@@ -135,7 +144,7 @@ module Axlsx
|
|
135
144
|
private
|
136
145
|
|
137
146
|
# assigns the owning worksheet for this row
|
138
|
-
def worksheet=(v) DataTypeValidator.validate :row_worksheet, Worksheet, v; @worksheet=v; end
|
147
|
+
def worksheet=(v) DataTypeValidator.validate :row_worksheet, Worksheet, v; @worksheet = v; end
|
139
148
|
|
140
149
|
# Converts values, types, and style options into cells and associates them with this row.
|
141
150
|
# A new cell is created for each item in the values array.
|
@@ -146,19 +155,19 @@ module Axlsx
|
|
146
155
|
# @option options [Array] values
|
147
156
|
# @option options [Array, Symbol] types
|
148
157
|
# @option options [Array, Integer] style
|
149
|
-
|
158
|
+
# @option options [Array, Boolean] escape_formulas
|
159
|
+
def array_to_cells(values, options = {})
|
150
160
|
DataTypeValidator.validate :array_to_cells, Array, values
|
151
161
|
types, style, formula_values, escape_formulas, offset = options.delete(:types), options.delete(:style), options.delete(:formula_values), options.delete(:escape_formulas), options.delete(:offset)
|
152
162
|
offset.to_i.times { |index| self[index] = Cell.new(self) } if offset
|
153
163
|
values.each_with_index do |value, index|
|
154
164
|
options[:style] = style.is_a?(Array) ? style[index] : style if style
|
155
165
|
options[:type] = types.is_a?(Array) ? types[index] : types if types
|
156
|
-
options[:escape_formulas] = escape_formulas.is_a?(Array) ? escape_formulas[index] : escape_formulas
|
166
|
+
options[:escape_formulas] = escape_formulas.is_a?(Array) ? escape_formulas[index] : escape_formulas unless escape_formulas.nil?
|
157
167
|
options[:formula_value] = formula_values[index] if formula_values.is_a?(Array)
|
158
168
|
|
159
169
|
self[index + offset.to_i] = Cell.new(self, value, options)
|
160
170
|
end
|
161
171
|
end
|
162
172
|
end
|
163
|
-
|
164
173
|
end
|
@@ -1,9 +1,7 @@
|
|
1
1
|
module Axlsx
|
2
|
-
|
3
2
|
# A collection of break objects that define row breaks (page breaks) for printing and preview
|
4
3
|
|
5
4
|
class RowBreaks < SimpleTypedList
|
6
|
-
|
7
5
|
def initialize
|
8
6
|
super Break
|
9
7
|
end
|
@@ -17,14 +15,15 @@ module Axlsx
|
|
17
15
|
self << Break.new(options.merge(:max => 16383, :man => true))
|
18
16
|
last
|
19
17
|
end
|
20
|
-
|
18
|
+
|
21
19
|
# <rowBreaks count="3" manualBreakCount="3">
|
22
20
|
# <brk id="1" max="16383" man="1"/>
|
23
21
|
# <brk id="7" max="16383" man="1"/>
|
24
22
|
# <brk id="13" max="16383" man="1"/>
|
25
23
|
# </rowBreaks>
|
26
|
-
def to_xml_string(str='')
|
24
|
+
def to_xml_string(str = '')
|
27
25
|
return if empty?
|
26
|
+
|
28
27
|
str << ('<rowBreaks count="' << self.size.to_s << '" manualBreakCount="' << self.size.to_s << '">')
|
29
28
|
each { |brk| brk.to_xml_string(str) }
|
30
29
|
str << '</rowBreaks>'
|
@@ -1,11 +1,9 @@
|
|
1
|
-
# encoding: UTF-8
|
2
1
|
module Axlsx
|
3
2
|
# Selection options for worksheet panes.
|
4
3
|
#
|
5
4
|
# @note The recommended way to manage the selection pane options is via SheetView#add_selection
|
6
5
|
# @see SheetView#add_selection
|
7
6
|
class Selection
|
8
|
-
|
9
7
|
include Axlsx::OptionsParser
|
10
8
|
include Axlsx::SerializedAttributes
|
11
9
|
|
@@ -14,7 +12,7 @@ module Axlsx
|
|
14
12
|
# @option options [Integer] active_cell_id Active Cell Index
|
15
13
|
# @option options [Symbol] pane Pane
|
16
14
|
# @option options [String] sqref Sequence of References
|
17
|
-
def initialize(options={})
|
15
|
+
def initialize(options = {})
|
18
16
|
@active_cell = @active_cell_id = @pane = @sqref = nil
|
19
17
|
parse_options options
|
20
18
|
end
|
@@ -40,16 +38,16 @@ module Axlsx
|
|
40
38
|
|
41
39
|
# Pane
|
42
40
|
# The pane to which this selection belongs.
|
43
|
-
# Options are
|
41
|
+
# Options are
|
44
42
|
# * bottom_left: Bottom left pane, when both vertical and horizontal
|
45
43
|
# splits are applied. This value is also used when only
|
46
|
-
# a horizontal split has been applied, dividing the pane
|
47
|
-
# into upper and lower regions. In that case, this value
|
44
|
+
# a horizontal split has been applied, dividing the pane
|
45
|
+
# into upper and lower regions. In that case, this value
|
48
46
|
# specifies the bottom pane.
|
49
47
|
# * bottom_right: Bottom right pane, when both vertical and horizontal
|
50
48
|
# splits are applied.
|
51
49
|
# * top_left: Top left pane, when both vertical and horizontal splits
|
52
|
-
# are applied. This value is also used when only a horizontal
|
50
|
+
# are applied. This value is also used when only a horizontal
|
53
51
|
# split has been applied, dividing the pane into upper and lower
|
54
52
|
# regions. In that case, this value specifies the top pane.
|
55
53
|
# This value is also used when only a vertical split has
|
@@ -57,8 +55,8 @@ module Axlsx
|
|
57
55
|
# regions. In that case, this value specifies the left pane
|
58
56
|
# * top_right: Top right pane, when both vertical and horizontal
|
59
57
|
# splits are applied. This value is also used when only
|
60
|
-
# a vertical split has been applied, dividing the pane
|
61
|
-
# into right and left regions. In that case, this value
|
58
|
+
# a vertical split has been applied, dividing the pane
|
59
|
+
# into right and left regions. In that case, this value
|
62
60
|
# specifies the right pane.
|
63
61
|
# @see type
|
64
62
|
# @return [Symbol]
|
@@ -1,15 +1,14 @@
|
|
1
1
|
module Axlsx
|
2
|
-
|
3
2
|
# the SheetCalcPr object for the worksheet
|
4
3
|
# This object contains calculation properties for the worksheet.
|
5
4
|
class SheetCalcPr
|
6
|
-
|
7
|
-
|
8
|
-
|
5
|
+
include Axlsx::OptionsParser
|
6
|
+
include Axlsx::SerializedAttributes
|
7
|
+
include Axlsx::Accessors
|
9
8
|
# creates a new SheetCalcPr
|
10
9
|
# @param [Hash] options Options for this object
|
11
10
|
# @option [Boolean] full_calc_on_load @see full_calc_on_load
|
12
|
-
def initialize(options={})
|
11
|
+
def initialize(options = {})
|
13
12
|
@full_calc_on_load = true
|
14
13
|
parse_options options
|
15
14
|
end
|
@@ -22,7 +21,7 @@ module Axlsx
|
|
22
21
|
# @param [String] str the string to append this objects serialized
|
23
22
|
# content to.
|
24
23
|
# @return [String]
|
25
|
-
def to_xml_string(str='')
|
24
|
+
def to_xml_string(str = '')
|
26
25
|
str << "<sheetCalcPr #{serialized_attributes}/>"
|
27
26
|
end
|
28
27
|
end
|
@@ -1,15 +1,14 @@
|
|
1
1
|
module Axlsx
|
2
|
-
|
3
2
|
# This class manages the serialization of rows for worksheets
|
4
3
|
class SheetData
|
5
|
-
|
6
4
|
# Creates a new SheetData object
|
7
5
|
# @param [Worksheet] worksheet The worksheet that owns this sheet data.
|
8
6
|
def initialize(worksheet)
|
9
7
|
raise ArgumentError, "you must provide a worksheet" unless worksheet.is_a?(Worksheet)
|
8
|
+
|
10
9
|
@worksheet = worksheet
|
11
10
|
end
|
12
|
-
|
11
|
+
|
13
12
|
attr_reader :worksheet
|
14
13
|
|
15
14
|
# Serialize the sheet data
|
@@ -17,11 +16,10 @@ module Axlsx
|
|
17
16
|
# @return [String]
|
18
17
|
def to_xml_string(str = '')
|
19
18
|
str << '<sheetData>'
|
20
|
-
worksheet.rows.each_with_index do |row, index|
|
21
|
-
row.to_xml_string(index, str)
|
19
|
+
worksheet.rows.each_with_index do |row, index|
|
20
|
+
row.to_xml_string(index, str)
|
22
21
|
end
|
23
22
|
str << '</sheetData>'
|
24
23
|
end
|
25
|
-
|
26
24
|
end
|
27
25
|
end
|
@@ -1,17 +1,16 @@
|
|
1
1
|
module Axlsx
|
2
|
-
|
3
|
-
#
|
4
|
-
#
|
5
|
-
# <xsd:attribute name="
|
6
|
-
# <xsd:attribute name="
|
7
|
-
# <xsd:attribute name="
|
8
|
-
# <xsd:attribute name="
|
9
|
-
# <xsd:attribute name="
|
10
|
-
# <xsd:attribute name="
|
11
|
-
# <xsd:attribute name="
|
12
|
-
# <xsd:attribute name="
|
13
|
-
#
|
14
|
-
#</xsd:complexType>
|
2
|
+
# Sheet formatting properties
|
3
|
+
# <xsd:complexType name="CT_SheetFormatPr">
|
4
|
+
# <xsd:attribute name="baseColWidth" type="xsd:unsignedInt" use="optional" default="8"/>
|
5
|
+
# <xsd:attribute name="defaultColWidth" type="xsd:double" use="optional"/>
|
6
|
+
# <xsd:attribute name="defaultRowHeight" type="xsd:double" use="required"/>
|
7
|
+
# <xsd:attribute name="customHeight" type="xsd:boolean" use="optional" default="false"/>
|
8
|
+
# <xsd:attribute name="zeroHeight" type="xsd:boolean" use="optional" default="false"/>
|
9
|
+
# <xsd:attribute name="thickTop" type="xsd:boolean" use="optional" default="false"/>
|
10
|
+
# <xsd:attribute name="thickBottom" type="xsd:boolean" use="optional" default="false"/>
|
11
|
+
# <xsd:attribute name="outlineLevelRow" type="xsd:unsignedByte" use="optional" default="0"/>
|
12
|
+
# <xsd:attribute name="outlineLevelCol" type="xsd:unsignedByte" use="optional" default="0"/>
|
13
|
+
# </xsd:complexType>
|
15
14
|
|
16
15
|
class SheetFormatPr
|
17
16
|
include Axlsx::SerializedAttributes
|
@@ -29,29 +28,30 @@ module Axlsx
|
|
29
28
|
# @option [Boolean] thick_bottom 'True' if rows have a thick bottom border by default.
|
30
29
|
# @option [Integer] outline_level_row Highest number of outline level for rows in this sheet. These values shall be in synch with the actual sheet outline levels.
|
31
30
|
# @option [Integer] outline_level_col Highest number of outline levels for columns in this sheet. These values shall be in synch with the actual sheet outline levels.
|
32
|
-
def initialize(options={})
|
31
|
+
def initialize(options = {})
|
33
32
|
set_defaults
|
34
33
|
parse_options options
|
35
34
|
end
|
36
35
|
|
37
36
|
serializable_attributes :base_col_width, :default_col_width, :default_row_height,
|
38
|
-
|
39
|
-
|
37
|
+
:custom_height, :zero_height, :thick_top, :thick_bottom,
|
38
|
+
:outline_level_row, :outline_level_col
|
40
39
|
|
41
40
|
float_attr_accessor :default_col_width, :default_row_height
|
42
41
|
|
43
42
|
boolean_attr_accessor :custom_height, :zero_height, :thick_top, :thick_bottom
|
44
43
|
|
45
|
-
unsigned_int_attr_accessor :base_col_width, :outline_level_row, :outline_level_col
|
44
|
+
unsigned_int_attr_accessor :base_col_width, :outline_level_row, :outline_level_col
|
46
45
|
|
47
46
|
# serializes this object to an xml string
|
48
47
|
# @param [String] str The string this objects serialization will be appended to
|
49
48
|
# @return [String]
|
50
|
-
def to_xml_string(str='')
|
49
|
+
def to_xml_string(str = '')
|
51
50
|
str << "<sheetFormatPr #{serialized_attributes}/>"
|
52
51
|
end
|
53
52
|
|
54
53
|
private
|
54
|
+
|
55
55
|
def set_defaults
|
56
56
|
@base_col_width = 8
|
57
57
|
@default_row_height = 18
|
@@ -1,5 +1,4 @@
|
|
1
1
|
module Axlsx
|
2
|
-
|
3
2
|
# The SheetPr class manages serialization of a worksheet's sheetPr element.
|
4
3
|
class SheetPr
|
5
4
|
include Axlsx::OptionsParser
|
@@ -30,8 +29,9 @@ module Axlsx
|
|
30
29
|
|
31
30
|
# Creates a new SheetPr object
|
32
31
|
# @param [Worksheet] worksheet The worksheet that owns this SheetPr object
|
33
|
-
def initialize(worksheet, options={})
|
32
|
+
def initialize(worksheet, options = {})
|
34
33
|
raise ArgumentError, "you must provide a worksheet" unless worksheet.is_a?(Worksheet)
|
34
|
+
|
35
35
|
@worksheet = worksheet
|
36
36
|
@outline_pr = nil
|
37
37
|
parse_options options
|
@@ -62,7 +62,7 @@ module Axlsx
|
|
62
62
|
def page_setup_pr
|
63
63
|
@page_setup_pr ||= PageSetUpPr.new
|
64
64
|
end
|
65
|
-
|
65
|
+
|
66
66
|
# The OutlinePr for this sheet pr object
|
67
67
|
# @return [OutlinePr]
|
68
68
|
def outline_pr
|
@@ -71,7 +71,7 @@ module Axlsx
|
|
71
71
|
|
72
72
|
# @see tab_color
|
73
73
|
def tab_color=(v)
|
74
|
-
@tab_color
|
74
|
+
@tab_color = Color.new(:rgb => v)
|
75
75
|
end
|
76
76
|
|
77
77
|
private
|
@@ -1,9 +1,6 @@
|
|
1
|
-
# encoding: UTF-8
|
2
1
|
module Axlsx
|
3
|
-
|
4
2
|
# The SheetProtection object manages worksheet protection options per sheet.
|
5
3
|
class SheetProtection
|
6
|
-
|
7
4
|
include Axlsx::OptionsParser
|
8
5
|
include Axlsx::SerializedAttributes
|
9
6
|
include Axlsx::Accessors
|
@@ -26,7 +23,7 @@ module Axlsx
|
|
26
23
|
# @option options [Boolean] pivot_tables @see SheetProtection#pivot_tables
|
27
24
|
# @option options [Boolean] select_unlocked_cells @see SheetProtection#select_unlocked_cells
|
28
25
|
# @option options [String] password. The password required for unlocking. @see SheetProtection#password=
|
29
|
-
def initialize(options={})
|
26
|
+
def initialize(options = {})
|
30
27
|
@objects = @scenarios = @select_locked_cells = @select_unlocked_cells = false
|
31
28
|
@sheet = @format_cells = @format_rows = @format_columns = @insert_columns = @insert_rows = @insert_hyperlinks = @delete_columns = @delete_rows = @sort = @auto_filter = @pivot_tables = true
|
32
29
|
@password = nil
|
@@ -34,12 +31,12 @@ module Axlsx
|
|
34
31
|
end
|
35
32
|
|
36
33
|
boolean_attr_accessor :sheet, :objects, :scenarios, :format_cells, :format_columns, :format_rows,
|
37
|
-
|
38
|
-
|
34
|
+
:insert_columns, :insert_rows, :insert_hyperlinks, :delete_columns, :delete_rows,
|
35
|
+
:select_locked_cells, :sort, :auto_filter, :pivot_tables, :select_unlocked_cells
|
39
36
|
|
40
37
|
serializable_attributes :sheet, :objects, :scenarios, :format_cells, :format_columns, :format_rows,
|
41
|
-
|
42
|
-
|
38
|
+
:insert_columns, :insert_rows, :insert_hyperlinks, :delete_columns, :delete_rows,
|
39
|
+
:select_locked_cells, :sort, :auto_filter, :pivot_tables, :select_unlocked_cells, :salt, :password
|
43
40
|
|
44
41
|
# Specifies the salt which was prepended to the user-supplied password before it was hashed using the hashing algorithm
|
45
42
|
# @return [String]
|
@@ -50,9 +47,9 @@ module Axlsx
|
|
50
47
|
# default nil
|
51
48
|
attr_reader :password
|
52
49
|
|
53
|
-
# This block is intended to implement the salt_value, hash_value and spin count as per the ECMA-376 standard.
|
54
|
-
# However, it does not seem to actually work in EXCEL - instead they are using their old retro algorithm shown below
|
55
|
-
# defined in the transitional portion of the speck. I am leaving this code in in the hope that someday Ill be able to
|
50
|
+
# This block is intended to implement the salt_value, hash_value and spin count as per the ECMA-376 standard.
|
51
|
+
# However, it does not seem to actually work in EXCEL - instead they are using their old retro algorithm shown below
|
52
|
+
# defined in the transitional portion of the speck. I am leaving this code in in the hope that someday Ill be able to
|
56
53
|
# figure out why it does not work, and if Excel even supports it.
|
57
54
|
# def propper_password=(v)
|
58
55
|
# @algorithm_name = v == nil ? nil : 'SHA-1'
|
@@ -69,6 +66,7 @@ module Axlsx
|
|
69
66
|
# encodes password for protection locking
|
70
67
|
def password=(v)
|
71
68
|
return if v == nil
|
69
|
+
|
72
70
|
@password = create_password_hash(v)
|
73
71
|
end
|
74
72
|
|
@@ -80,6 +78,7 @@ module Axlsx
|
|
80
78
|
end
|
81
79
|
|
82
80
|
private
|
81
|
+
|
83
82
|
# Creates a password hash for a given password
|
84
83
|
# @return [String]
|
85
84
|
def create_password_hash(password)
|
@@ -102,14 +101,14 @@ module Axlsx
|
|
102
101
|
|
103
102
|
chars.collect! do |char|
|
104
103
|
i += 1
|
105
|
-
char = char.unpack('c')[0] << i #ord << i
|
104
|
+
char = char.unpack('c')[0] << i # ord << i
|
106
105
|
low_15 = char & 0x7fff
|
107
106
|
high_15 = char & 0x7fff << 15
|
108
107
|
high_15 = high_15 >> 15
|
109
108
|
char = low_15 | high_15
|
110
109
|
end
|
111
110
|
|
112
|
-
encoded_password
|
111
|
+
encoded_password = 0x0000
|
113
112
|
chars.each { |c| encoded_password ^= c }
|
114
113
|
encoded_password ^= count
|
115
114
|
encoded_password ^= 0xCE4B
|