caxlsx 4.1.0 → 4.2.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 +21 -12
- data/README.md +1 -1
- data/lib/axlsx/content_type/abstract_content_type.rb +2 -2
- data/lib/axlsx/content_type/content_type.rb +3 -3
- data/lib/axlsx/drawing/area_chart.rb +3 -3
- data/lib/axlsx/drawing/area_series.rb +2 -2
- data/lib/axlsx/drawing/ax_data_source.rb +1 -1
- data/lib/axlsx/drawing/axes.rb +1 -1
- data/lib/axlsx/drawing/axis.rb +1 -1
- data/lib/axlsx/drawing/bar_3D_chart.rb +3 -3
- data/lib/axlsx/drawing/bar_chart.rb +3 -3
- data/lib/axlsx/drawing/bar_series.rb +2 -2
- data/lib/axlsx/drawing/bubble_chart.rb +2 -2
- data/lib/axlsx/drawing/bubble_series.rb +2 -2
- data/lib/axlsx/drawing/cat_axis.rb +3 -3
- data/lib/axlsx/drawing/d_lbls.rb +4 -4
- data/lib/axlsx/drawing/drawing.rb +50 -50
- data/lib/axlsx/drawing/hyperlink.rb +1 -1
- data/lib/axlsx/drawing/line_3D_chart.rb +3 -3
- data/lib/axlsx/drawing/line_chart.rb +3 -3
- data/lib/axlsx/drawing/line_series.rb +2 -2
- data/lib/axlsx/drawing/num_val.rb +1 -1
- data/lib/axlsx/drawing/pic.rb +4 -4
- data/lib/axlsx/drawing/pie_3D_chart.rb +2 -2
- data/lib/axlsx/drawing/pie_chart.rb +2 -2
- data/lib/axlsx/drawing/pie_series.rb +2 -2
- data/lib/axlsx/drawing/scatter_chart.rb +2 -2
- data/lib/axlsx/drawing/scatter_series.rb +2 -2
- data/lib/axlsx/drawing/ser_axis.rb +3 -3
- data/lib/axlsx/drawing/two_cell_anchor.rb +1 -1
- data/lib/axlsx/drawing/val_axis.rb +2 -2
- data/lib/axlsx/package.rb +7 -10
- data/lib/axlsx/rels/relationship.rb +2 -2
- data/lib/axlsx/rels/relationships.rb +2 -2
- data/lib/axlsx/stylesheet/border_pr.rb +1 -1
- data/lib/axlsx/stylesheet/cell_alignment.rb +1 -1
- data/lib/axlsx/stylesheet/cell_style.rb +1 -1
- data/lib/axlsx/stylesheet/color.rb +2 -2
- data/lib/axlsx/stylesheet/font.rb +1 -1
- data/lib/axlsx/stylesheet/gradient_fill.rb +1 -1
- data/lib/axlsx/stylesheet/styles.rb +27 -31
- data/lib/axlsx/stylesheet/xf.rb +1 -1
- data/lib/axlsx/util/accessors.rb +1 -1
- data/lib/axlsx/util/constants.rb +2 -2
- data/lib/axlsx/util/serialized_attributes.rb +2 -2
- data/lib/axlsx/util/simple_typed_list.rb +25 -12
- data/lib/axlsx/util/storage.rb +3 -3
- data/lib/axlsx/util/validators.rb +1 -1
- data/lib/axlsx/version.rb +1 -1
- data/lib/axlsx/workbook/defined_name.rb +1 -1
- data/lib/axlsx/workbook/shared_strings_table.rb +3 -3
- data/lib/axlsx/workbook/workbook.rb +61 -61
- data/lib/axlsx/workbook/worksheet/auto_filter/auto_filter.rb +4 -4
- data/lib/axlsx/workbook/worksheet/auto_filter/filter_column.rb +1 -1
- data/lib/axlsx/workbook/worksheet/auto_filter/filters.rb +3 -3
- data/lib/axlsx/workbook/worksheet/auto_filter/sort_condition.rb +1 -1
- data/lib/axlsx/workbook/worksheet/auto_filter/sort_state.rb +2 -2
- data/lib/axlsx/workbook/worksheet/border_creator.rb +4 -4
- data/lib/axlsx/workbook/worksheet/cell.rb +7 -7
- data/lib/axlsx/workbook/worksheet/cell_serializer.rb +1 -1
- data/lib/axlsx/workbook/worksheet/col.rb +22 -9
- data/lib/axlsx/workbook/worksheet/comment.rb +2 -2
- data/lib/axlsx/workbook/worksheet/comments.rb +1 -1
- data/lib/axlsx/workbook/worksheet/conditional_formatting.rb +1 -1
- data/lib/axlsx/workbook/worksheet/conditional_formatting_rule.rb +1 -1
- data/lib/axlsx/workbook/worksheet/conditional_formattings.rb +2 -2
- data/lib/axlsx/workbook/worksheet/data_validation.rb +1 -1
- data/lib/axlsx/workbook/worksheet/data_validations.rb +2 -2
- data/lib/axlsx/workbook/worksheet/date_time_converter.rb +2 -2
- data/lib/axlsx/workbook/worksheet/dimension.rb +1 -1
- data/lib/axlsx/workbook/worksheet/icon_set.rb +1 -1
- data/lib/axlsx/workbook/worksheet/outline_pr.rb +1 -1
- data/lib/axlsx/workbook/worksheet/page_setup.rb +2 -2
- data/lib/axlsx/workbook/worksheet/pivot_table.rb +29 -5
- data/lib/axlsx/workbook/worksheet/rich_text_run.rb +1 -1
- data/lib/axlsx/workbook/worksheet/sheet_pr.rb +1 -1
- data/lib/axlsx/workbook/worksheet/table_style_info.rb +1 -1
- data/lib/axlsx/workbook/worksheet/worksheet.rb +10 -12
- data/lib/axlsx/workbook/worksheet/worksheet_comments.rb +3 -3
- data/lib/axlsx/workbook/worksheet/worksheet_hyperlink.rb +1 -1
- data/lib/axlsx/workbook/worksheet/worksheet_hyperlinks.rb +1 -1
- data/lib/axlsx.rb +44 -30
- data/lib/caxlsx.rb +1 -1
- metadata +6 -6
data/lib/axlsx/drawing/pic.rb
CHANGED
@@ -80,7 +80,7 @@ module Axlsx
|
|
80
80
|
def image_src=(v)
|
81
81
|
Axlsx.validate_string(v)
|
82
82
|
if remote?
|
83
|
-
RegexValidator.validate('Pic.image_src', /\A#{
|
83
|
+
RegexValidator.validate('Pic.image_src', /\A#{Axlsx.uri_parser.make_regexp}\z/, v)
|
84
84
|
RestrictionValidator.validate 'Pic.image_src', ALLOWED_MIME_TYPES, MimeTypeUtils.get_mime_type_from_uri(v)
|
85
85
|
else
|
86
86
|
RestrictionValidator.validate 'Pic.image_src', ALLOWED_MIME_TYPES, MimeTypeUtils.get_mime_type(v)
|
@@ -118,7 +118,7 @@ module Axlsx
|
|
118
118
|
File.basename(image_src) unless remote? || image_src.nil?
|
119
119
|
end
|
120
120
|
|
121
|
-
# returns the extension of image_src without the
|
121
|
+
# returns the extension of image_src without the preceding '.'
|
122
122
|
# @return [String]
|
123
123
|
def extname
|
124
124
|
File.extname(image_src).delete('.') unless image_src.nil?
|
@@ -222,9 +222,9 @@ module Axlsx
|
|
222
222
|
# Return correct xml relationship string portion
|
223
223
|
def relationship_xml_portion
|
224
224
|
if remote?
|
225
|
-
(+'<a:blip xmlns:r
|
225
|
+
(+'<a:blip xmlns:r="' << XML_NS_R << '" r:link="' << relationship.Id << '">')
|
226
226
|
else
|
227
|
-
(+'<a:blip xmlns:r
|
227
|
+
(+'<a:blip xmlns:r="' << XML_NS_R << '" r:embed="' << relationship.Id << '">')
|
228
228
|
end
|
229
229
|
end
|
230
230
|
|
@@ -22,7 +22,7 @@ module Axlsx
|
|
22
22
|
# @see View3D
|
23
23
|
def initialize(frame, options = {})
|
24
24
|
@vary_colors = true
|
25
|
-
super
|
25
|
+
super
|
26
26
|
@series_type = PieSeries
|
27
27
|
@view_3D = View3D.new({ rot_x: 30, perspective: 30 }.merge(options))
|
28
28
|
@d_lbls = nil
|
@@ -32,7 +32,7 @@ module Axlsx
|
|
32
32
|
# @param [String] str
|
33
33
|
# @return [String]
|
34
34
|
def to_xml_string(str = +'')
|
35
|
-
super
|
35
|
+
super do
|
36
36
|
str << '<c:pie3DChart>'
|
37
37
|
str << '<c:varyColors val="' << vary_colors.to_s << '"/>'
|
38
38
|
@series.each { |ser| ser.to_xml_string(str) }
|
@@ -15,7 +15,7 @@ module Axlsx
|
|
15
15
|
# @see Chart
|
16
16
|
def initialize(frame, options = {})
|
17
17
|
@vary_colors = true
|
18
|
-
super
|
18
|
+
super
|
19
19
|
@series_type = PieSeries
|
20
20
|
@d_lbls = nil
|
21
21
|
end
|
@@ -24,7 +24,7 @@ module Axlsx
|
|
24
24
|
# @param [String] str
|
25
25
|
# @return [String]
|
26
26
|
def to_xml_string(str = +'')
|
27
|
-
super
|
27
|
+
super do
|
28
28
|
str << '<c:pieChart>'
|
29
29
|
str << '<c:varyColors val="' << vary_colors.to_s << '"/>'
|
30
30
|
@series.each { |ser| ser.to_xml_string(str) }
|
@@ -30,7 +30,7 @@ module Axlsx
|
|
30
30
|
def initialize(chart, options = {})
|
31
31
|
@explosion = nil
|
32
32
|
@colors = []
|
33
|
-
super
|
33
|
+
super
|
34
34
|
self.labels = AxDataSource.new(data: options[:labels]) unless options[:labels].nil?
|
35
35
|
self.data = NumDataSource.new(options) unless options[:data].nil?
|
36
36
|
end
|
@@ -51,7 +51,7 @@ module Axlsx
|
|
51
51
|
# @param [String] str
|
52
52
|
# @return [String]
|
53
53
|
def to_xml_string(str = +'')
|
54
|
-
super
|
54
|
+
super do
|
55
55
|
str << '<c:explosion val="' << @explosion.to_s << '"/>' unless @explosion.nil?
|
56
56
|
colors.each_with_index do |c, index|
|
57
57
|
str << '<c:dPt>'
|
@@ -33,7 +33,7 @@ module Axlsx
|
|
33
33
|
@vary_colors = 0
|
34
34
|
@scatter_style = :lineMarker
|
35
35
|
|
36
|
-
super
|
36
|
+
super
|
37
37
|
@series_type = ScatterSeries
|
38
38
|
@d_lbls = nil
|
39
39
|
parse_options options
|
@@ -50,7 +50,7 @@ module Axlsx
|
|
50
50
|
# @param [String] str
|
51
51
|
# @return [String]
|
52
52
|
def to_xml_string(str = +'')
|
53
|
-
super
|
53
|
+
super do
|
54
54
|
str << '<c:scatterChart>'
|
55
55
|
str << '<c:scatterStyle val="' << scatter_style.to_s << '"/>'
|
56
56
|
str << '<c:varyColors val="' << vary_colors.to_s << '"/>'
|
@@ -50,7 +50,7 @@ module Axlsx
|
|
50
50
|
@show_marker = [:lineMarker, :marker, :smoothMarker].include?(chart.scatter_style)
|
51
51
|
@marker_symbol = :default
|
52
52
|
|
53
|
-
super
|
53
|
+
super
|
54
54
|
@xData = AxDataSource.new(tag_name: :xVal, data: options[:xData]) unless options[:xData].nil?
|
55
55
|
@yData = NumDataSource.new({ tag_name: :yVal, data: options[:yData] }) unless options[:yData].nil?
|
56
56
|
end
|
@@ -81,7 +81,7 @@ module Axlsx
|
|
81
81
|
# @param [String] str
|
82
82
|
# @return [String]
|
83
83
|
def to_xml_string(str = +'')
|
84
|
-
super
|
84
|
+
super do
|
85
85
|
# needs to override the super color here to push in ln/and something else!
|
86
86
|
if color
|
87
87
|
str << '<c:spPr><a:solidFill>'
|
@@ -3,7 +3,7 @@
|
|
3
3
|
module Axlsx
|
4
4
|
# A SerAxis object defines a series axis
|
5
5
|
class SerAxis < Axis
|
6
|
-
# The number of tick
|
6
|
+
# The number of tick labels to skip between labels
|
7
7
|
# @return [Integer]
|
8
8
|
attr_reader :tick_lbl_skip
|
9
9
|
alias :tickLblSkip :tick_lbl_skip
|
@@ -18,7 +18,7 @@ module Axlsx
|
|
18
18
|
# @option options [Integer] tick_mark_skip
|
19
19
|
def initialize(options = {})
|
20
20
|
@tick_lbl_skip, @tick_mark_skip = 1, 1
|
21
|
-
super
|
21
|
+
super
|
22
22
|
end
|
23
23
|
|
24
24
|
# @see tickLblSkip
|
@@ -40,7 +40,7 @@ module Axlsx
|
|
40
40
|
# @return [String]
|
41
41
|
def to_xml_string(str = +'')
|
42
42
|
str << '<c:serAx>'
|
43
|
-
super
|
43
|
+
super
|
44
44
|
str << '<c:tickLblSkip val="' << @tick_lbl_skip.to_s << '"/>' unless @tick_lbl_skip.nil?
|
45
45
|
str << '<c:tickMarkSkip val="' << @tick_mark_skip.to_s << '"/>' unless @tick_mark_skip.nil?
|
46
46
|
str << '</c:serAx>'
|
@@ -39,7 +39,7 @@ module Axlsx
|
|
39
39
|
parse_options options
|
40
40
|
|
41
41
|
# bit of a hack to work around the fact that the coords for start at and end at
|
42
|
-
# are passed in as an array when specified in
|
42
|
+
# are passed in as an array when specified in initialization options - however
|
43
43
|
start_at(*options[:start_at]) if options[:start_at]
|
44
44
|
end_at(*options[:end_at]) if options[:end_at]
|
45
45
|
end
|
@@ -13,7 +13,7 @@ module Axlsx
|
|
13
13
|
# @option options [Symbol] crosses_between
|
14
14
|
def initialize(options = {})
|
15
15
|
self.cross_between = :between
|
16
|
-
super
|
16
|
+
super
|
17
17
|
end
|
18
18
|
|
19
19
|
# @see cross_between
|
@@ -28,7 +28,7 @@ module Axlsx
|
|
28
28
|
# @return [String]
|
29
29
|
def to_xml_string(str = +'')
|
30
30
|
str << '<c:valAx>'
|
31
|
-
super
|
31
|
+
super
|
32
32
|
str << '<c:crossBetween val="' << @cross_between.to_s << '"/>'
|
33
33
|
str << '</c:valAx>'
|
34
34
|
end
|
data/lib/axlsx/package.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Axlsx
|
4
|
-
# Package is responsible for managing all the bits and
|
4
|
+
# Package is responsible for managing all the bits and pieces that Open Office XML requires to make a valid
|
5
5
|
# xlsx document including validation and serialization.
|
6
6
|
class Package
|
7
7
|
include Axlsx::OptionsParser
|
@@ -55,11 +55,11 @@ module Axlsx
|
|
55
55
|
# @raise ArgumentError if workbook parameter is not a Workbook instance.
|
56
56
|
# @note As there are multiple ways to instantiate a workbook for the package,
|
57
57
|
# here are a few examples:
|
58
|
-
# # assign directly during package
|
58
|
+
# # assign directly during package instantiation
|
59
59
|
# wb = Package.new(:workbook => Workbook.new).workbook
|
60
60
|
#
|
61
61
|
# # get a fresh workbook automatically from the package
|
62
|
-
# wb =
|
62
|
+
# wb = Package.new().workbook
|
63
63
|
# # # set the workbook after creating the package
|
64
64
|
# wb = Package.new().workbook = Workbook.new
|
65
65
|
def workbook
|
@@ -207,7 +207,7 @@ module Axlsx
|
|
207
207
|
# Note: {Core#created} also defaults to the current time – so to generate identical axlsx packages you have
|
208
208
|
# to set this explicitly, too (eg. with `Package.new(created_at: Time.local(2013, 1, 1))`).
|
209
209
|
#
|
210
|
-
# @param part A hash describing a part of this
|
210
|
+
# @param part A hash describing a part of this package (see {#parts})
|
211
211
|
# @return [Zip::Entry]
|
212
212
|
def zip_entry_for_part(part)
|
213
213
|
timestamp = Zip::DOSTime.at(@core.created.to_i)
|
@@ -273,7 +273,7 @@ module Axlsx
|
|
273
273
|
]
|
274
274
|
end
|
275
275
|
|
276
|
-
# Performs xsd validation for a
|
276
|
+
# Performs xsd validation for a single document
|
277
277
|
#
|
278
278
|
# @param [String] schema path to the xsd schema to be used in validation.
|
279
279
|
# @param [String] doc The xml text to be validated
|
@@ -282,11 +282,8 @@ module Axlsx
|
|
282
282
|
def validate_single_doc(schema, doc)
|
283
283
|
schema = Nokogiri::XML::Schema(File.open(schema))
|
284
284
|
doc = Nokogiri::XML(doc)
|
285
|
-
|
286
|
-
schema.validate(doc)
|
287
|
-
errors << error
|
288
|
-
end
|
289
|
-
errors
|
285
|
+
|
286
|
+
schema.validate(doc)
|
290
287
|
end
|
291
288
|
|
292
289
|
# Appends override objects for drawings, charts, and sheets as they exist in your workbook to the default content types.
|
@@ -15,7 +15,7 @@ module Axlsx
|
|
15
15
|
#
|
16
16
|
# This should be called before serializing a package (see {Package#serialize} and
|
17
17
|
# {Package#to_stream}) to make sure that serialization is idempotent (i.e.
|
18
|
-
# Relationship instances are generated with the same IDs
|
18
|
+
# Relationship instances are generated with the same IDs every time the package
|
19
19
|
# is serialized).
|
20
20
|
def initialize_ids_cache
|
21
21
|
Thread.current[:axlsx_relationship_ids_cache] = {}
|
@@ -116,7 +116,7 @@ module Axlsx
|
|
116
116
|
h = Axlsx.instance_values_for(self).reject { |k, _| k == "source_obj" }
|
117
117
|
str << '<Relationship '
|
118
118
|
h.each_with_index do |key_value, index|
|
119
|
-
str << ' ' unless index
|
119
|
+
str << ' ' unless index == 0
|
120
120
|
str << key_value.first.to_s << '="' << Axlsx.coder.encode(key_value.last.to_s) << '"'
|
121
121
|
end
|
122
122
|
str << '/>'
|
@@ -1,10 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Axlsx
|
4
|
-
|
4
|
+
require_relative 'relationship'
|
5
5
|
|
6
6
|
# Relationships are a collection of Relations that define how package parts are related.
|
7
|
-
# @note The package automatically manages
|
7
|
+
# @note The package automatically manages relationships.
|
8
8
|
class Relationships < SimpleTypedList
|
9
9
|
# Creates a new Relationships collection based on SimpleTypedList
|
10
10
|
def initialize
|
@@ -8,7 +8,7 @@ module Axlsx
|
|
8
8
|
include Axlsx::OptionsParser
|
9
9
|
include Axlsx::SerializedAttributes
|
10
10
|
|
11
|
-
#
|
11
|
+
# Creates a new CellStyle object
|
12
12
|
# @option options [String] name
|
13
13
|
# @option options [Integer] xfId
|
14
14
|
# @option options [Integer] buildinId
|
@@ -17,7 +17,7 @@ module Axlsx
|
|
17
17
|
|
18
18
|
serializable_attributes :auto, :rgb, :tint
|
19
19
|
|
20
|
-
# Determines if the color is system color
|
20
|
+
# Determines if the color is system color dependent
|
21
21
|
# @return [Boolean]
|
22
22
|
attr_reader :auto
|
23
23
|
|
@@ -72,7 +72,7 @@ module Axlsx
|
|
72
72
|
# This version does not support themes
|
73
73
|
# def theme=(v) Axlsx::validate_unsigned_integer v; @theme = v end
|
74
74
|
|
75
|
-
# Indexed colors are for backward
|
75
|
+
# Indexed colors are for backward compatibility which I am choosing not to support
|
76
76
|
# def indexed=(v) Axlsx::validate_unsigned_integer v; @indexed = v end
|
77
77
|
|
78
78
|
# Serializes the object
|
@@ -33,7 +33,7 @@ module Axlsx
|
|
33
33
|
# The charset of the font
|
34
34
|
# @return [Integer]
|
35
35
|
# @note
|
36
|
-
# The following values are defined in the OOXML specification and are OS
|
36
|
+
# The following values are defined in the OOXML specification and are OS dependent values
|
37
37
|
# 0 ANSI_CHARSET
|
38
38
|
# 1 DEFAULT_CHARSET
|
39
39
|
# 2 SYMBOL_CHARSET
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Axlsx
|
4
|
-
# A GradientFill defines the color and positioning for
|
4
|
+
# A GradientFill defines the color and positioning for gradient cell fill.
|
5
5
|
# @see Open Office XML Part 1 §18.8.24
|
6
6
|
class GradientFill
|
7
7
|
include Axlsx::OptionsParser
|
@@ -1,27 +1,27 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Axlsx
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
4
|
+
require_relative 'border'
|
5
|
+
require_relative 'border_pr'
|
6
|
+
require_relative 'cell_alignment'
|
7
|
+
require_relative 'cell_style'
|
8
|
+
require_relative 'color'
|
9
|
+
require_relative 'fill'
|
10
|
+
require_relative 'font'
|
11
|
+
require_relative 'gradient_fill'
|
12
|
+
require_relative 'gradient_stop'
|
13
|
+
require_relative 'num_fmt'
|
14
|
+
require_relative 'pattern_fill'
|
15
|
+
require_relative 'table_style'
|
16
|
+
require_relative 'table_styles'
|
17
|
+
require_relative 'table_style_element'
|
18
|
+
require_relative 'dxf'
|
19
|
+
require_relative 'xf'
|
20
|
+
require_relative 'cell_protection'
|
21
21
|
|
22
22
|
# The Styles class manages worksheet styles
|
23
23
|
# In addition to creating the require style objects for a valid xlsx package, this class provides the key mechanism for adding styles to your workbook, and safely applying them to the cells of your worksheet.
|
24
|
-
# All portions of the stylesheet are implemented here exception colors, which specify legacy and modified
|
24
|
+
# All portions of the stylesheet are implemented here exception colors, which specify legacy and modified palette colors, and exLst, which is used as a future feature data storage area.
|
25
25
|
# @see Office Open XML Part 1 18.8.11 for gory details on how this stuff gets put together
|
26
26
|
# @see Styles#add_style
|
27
27
|
# @note The recommended way to manage styles is with add_style
|
@@ -156,7 +156,7 @@ module Axlsx
|
|
156
156
|
# ws = p.workbook.add_worksheet
|
157
157
|
#
|
158
158
|
# # black text on a white background at 14pt with thin borders!
|
159
|
-
# title = ws.styles.add_style(:bg_color => "FFFF0000", :fg_color=>"
|
159
|
+
# title = ws.styles.add_style(:bg_color => "FFFF0000", :fg_color=>"FF000000", :sz=>14, :border=> {:style => :thin, :color => "FFFF0000"}
|
160
160
|
#
|
161
161
|
# ws.add_row ["Least Popular Pets"]
|
162
162
|
# ws.add_row ["", "Dry Skinned Reptiles", "Bald Cats", "Violent Parrots"], :style=>title
|
@@ -174,7 +174,7 @@ module Axlsx
|
|
174
174
|
#
|
175
175
|
# # define your styles
|
176
176
|
# title = ws.styles.add_style(:bg_color => "FFFF0000",
|
177
|
-
# :fg_color=>"
|
177
|
+
# :fg_color=>"FF000000",
|
178
178
|
# :border=>Axlsx::STYLE_THIN_BORDER,
|
179
179
|
# :alignment=>{:horizontal => :center})
|
180
180
|
#
|
@@ -209,10 +209,10 @@ module Axlsx
|
|
209
209
|
#
|
210
210
|
# # define your styles
|
211
211
|
# profitable = wb.styles.add_style(:bg_color => "FFFF0000",
|
212
|
-
# :fg_color=>"
|
212
|
+
# :fg_color=>"FF000000",
|
213
213
|
# :type => :dxf)
|
214
214
|
#
|
215
|
-
# ws.add_row ["
|
215
|
+
# ws.add_row ["Generated At:", Time.now], :styles=>[nil, date_time]
|
216
216
|
# ws.add_row ["Previous Year Quarterly Profits (JPY)"], :style=>title
|
217
217
|
# ws.add_row ["Quarter", "Profit", "% of Total"], :style=>title
|
218
218
|
# ws.add_row ["Q1", 4000, 40], :style=>[title, currency, percent]
|
@@ -245,7 +245,7 @@ module Axlsx
|
|
245
245
|
|
246
246
|
font_defaults = { name: @fonts.first.name, sz: @fonts.first.sz, family: @fonts.first.family }
|
247
247
|
|
248
|
-
raw_style = { type: :xf }.merge(font_defaults
|
248
|
+
raw_style = { type: :xf }.merge(font_defaults, options)
|
249
249
|
|
250
250
|
if raw_style[:format_code]
|
251
251
|
raw_style.delete(:num_fmt)
|
@@ -275,7 +275,7 @@ module Axlsx
|
|
275
275
|
if options[:type] == :xf
|
276
276
|
xf_index = (cellXfs << style)
|
277
277
|
|
278
|
-
# Add styles to style_index cache for
|
278
|
+
# Add styles to style_index cache for reuse
|
279
279
|
style_index[xf_index] = raw_style
|
280
280
|
|
281
281
|
xf_index
|
@@ -298,7 +298,7 @@ module Axlsx
|
|
298
298
|
|
299
299
|
# parses add_style options for alignment
|
300
300
|
# noop if options hash does not include :alignment key
|
301
|
-
# @option options [Hash] alignment A hash of options to prive the CellAlignment
|
301
|
+
# @option options [Hash] alignment A hash of options to prive the CellAlignment initializer
|
302
302
|
# @return [CellAlignment]
|
303
303
|
# @see CellAlignment
|
304
304
|
def parse_alignment_options(options = {})
|
@@ -325,11 +325,7 @@ module Axlsx
|
|
325
325
|
def parse_font_options(options = {})
|
326
326
|
return if (options.keys & [:fg_color, :sz, :b, :i, :u, :strike, :outline, :shadow, :charset, :family, :font_name]).empty?
|
327
327
|
|
328
|
-
Axlsx.instance_values_for(fonts.first).
|
329
|
-
# Thanks for that 1.8.7 - cant do a simple merge...
|
330
|
-
options[key.to_sym] = value unless options.key?(key.to_sym)
|
331
|
-
end
|
332
|
-
font = Font.new(options)
|
328
|
+
font = Font.new(Axlsx.instance_values_for(fonts.first).merge(options))
|
333
329
|
font.color = Color.new(rgb: options[:fg_color]) if options[:fg_color]
|
334
330
|
font.name = options[:font_name] if options[:font_name]
|
335
331
|
options[:type] == :dxf ? font : fonts << font
|
@@ -361,7 +357,7 @@ module Axlsx
|
|
361
357
|
|
362
358
|
# Both bgColor and fgColor happens to configure the background of the cell.
|
363
359
|
# One of them sets the "background" of the cell, while the other one is
|
364
|
-
#
|
360
|
+
# responsible for the "pattern" of the cell. When you pick "solid" pattern for
|
365
361
|
# a normal xf style, then it's a rectangle covering all bgColor with fgColor,
|
366
362
|
# which means we need to to set the given background color to fgColor as well.
|
367
363
|
# For some reason I wasn't able find, it works the opposite for dxf styles
|
data/lib/axlsx/stylesheet/xf.rb
CHANGED
data/lib/axlsx/util/accessors.rb
CHANGED
@@ -23,7 +23,7 @@ module Axlsx
|
|
23
23
|
validated_attr_accessor(symbols, :validate_string)
|
24
24
|
end
|
25
25
|
|
26
|
-
# Creates one or more
|
26
|
+
# Creates one or more unsigned integer attr_accessors
|
27
27
|
# @param [Array] symbols An array of symbols representing the
|
28
28
|
# names of the attributes you will add to your class
|
29
29
|
def unsigned_int_attr_accessor(*symbols)
|
data/lib/axlsx/util/constants.rb
CHANGED
@@ -259,7 +259,7 @@ module Axlsx
|
|
259
259
|
# drawing validation schema
|
260
260
|
DRAWING_XSD = "#{SCHEMA_BASE}dml-spreadsheetDrawing.xsd"
|
261
261
|
|
262
|
-
# number format id for
|
262
|
+
# number format id for percentage formatting using the default formatting id.
|
263
263
|
NUM_FMT_PERCENT = 9
|
264
264
|
|
265
265
|
# number format id for date format like 2011/11/13
|
@@ -404,7 +404,7 @@ module Axlsx
|
|
404
404
|
CONTROL_CHARS = pattern.freeze
|
405
405
|
|
406
406
|
# ISO 8601 date recognition
|
407
|
-
ISO_8601_REGEX = /\A(-?(?:[1-9][0-9]*)?[0-9]{4})-(1[0-2]|0[1-9])-(3[0-1]|0[1-9]|[1-2][0-9])T(2[0-3]|[0-1][0-9]):([0-5][0-9]):([0-5][0-9])(\.[0-9]+)
|
407
|
+
ISO_8601_REGEX = /\A(-?(?:[1-9][0-9]*)?[0-9]{4})-(1[0-2]|0[1-9])-(3[0-1]|0[1-9]|[1-2][0-9])T(2[0-3]|[0-1][0-9]):([0-5][0-9]):([0-5][0-9])(\.[0-9]+)?\Z/.freeze
|
408
408
|
|
409
409
|
# FLOAT recognition
|
410
410
|
SAFE_FLOAT_REGEX = /\A[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]{1,2})?\Z/.freeze
|
@@ -91,8 +91,8 @@ module Axlsx
|
|
91
91
|
|
92
92
|
# serialized instance values at text nodes on a camelized element of the
|
93
93
|
# attribute name. You may pass in a block for evaluation against non nil
|
94
|
-
# values. We use an array for element attributes
|
95
|
-
# break the xml
|
94
|
+
# values. We use an array for element attributes because misordering will
|
95
|
+
# break the xml.
|
96
96
|
# @param [String] str The string instance to which serialized data is appended
|
97
97
|
# @param [Array] additional_attributes An array of additional attribute names.
|
98
98
|
# @return [String] The serialized output.
|
@@ -21,7 +21,7 @@ module Axlsx
|
|
21
21
|
alias :== :equal?
|
22
22
|
alias :eql? :equal?
|
23
23
|
|
24
|
-
#
|
24
|
+
# Creates a new typed list
|
25
25
|
# @param [Array, Class] type An array of Class objects or a single Class object
|
26
26
|
# @param [String] serialize_as The tag name to use in serialization
|
27
27
|
# @raise [ArgumentError] if all members of type are not Class objects
|
@@ -57,7 +57,7 @@ module Axlsx
|
|
57
57
|
# Transposes the list (without blowing up like ruby does)
|
58
58
|
# any non populated cell in the matrix will be a nil value
|
59
59
|
def transpose
|
60
|
-
return clone if size
|
60
|
+
return clone if size == 0
|
61
61
|
|
62
62
|
row_count = size
|
63
63
|
max_column_count = map { |row| row.cells.size }.max
|
@@ -90,21 +90,24 @@ module Axlsx
|
|
90
90
|
self
|
91
91
|
end
|
92
92
|
|
93
|
-
#
|
94
|
-
# @param [Array]
|
93
|
+
# Appends the elements of +others+ to self.
|
94
|
+
# @param [Array<Array>] others one or more arrays to join
|
95
95
|
# @raise [ArgumentError] if any of the values being joined are not
|
96
96
|
# one of the allowed types
|
97
97
|
# @return [SimpleTypedList]
|
98
|
-
def
|
99
|
-
|
100
|
-
|
98
|
+
def concat(*others)
|
99
|
+
others.each do |other|
|
100
|
+
other.each do |item|
|
101
|
+
self << item
|
102
|
+
end
|
101
103
|
end
|
102
|
-
|
104
|
+
self
|
103
105
|
end
|
104
106
|
|
105
|
-
#
|
107
|
+
# Pushes the given object on to the end of this array and returns the index
|
108
|
+
# of the item added.
|
106
109
|
# @param [Any] v the data to be added
|
107
|
-
# @raise [ArgumentError] if the value being added is not one
|
110
|
+
# @raise [ArgumentError] if the value being added is not one of the allowed types
|
108
111
|
# @return [Integer] returns the index of the item added.
|
109
112
|
def <<(v)
|
110
113
|
DataTypeValidator.validate :SimpleTypedList_push, @allowed_types, v
|
@@ -112,7 +115,17 @@ module Axlsx
|
|
112
115
|
size - 1
|
113
116
|
end
|
114
117
|
|
115
|
-
|
118
|
+
# Pushes the given object(s) on to the end of this array. This expression
|
119
|
+
# returns the array itself, so several appends may be chained together.
|
120
|
+
# @param [Any] values the data to be added
|
121
|
+
# @raise [ArgumentError] if any of the values being joined are not
|
122
|
+
# @return [SimpleTypedList]
|
123
|
+
def push(*values)
|
124
|
+
values.each do |value|
|
125
|
+
self << value
|
126
|
+
end
|
127
|
+
self
|
128
|
+
end
|
116
129
|
|
117
130
|
# delete the item from the list
|
118
131
|
# @param [Any] v The item to be deleted.
|
@@ -147,7 +160,7 @@ module Axlsx
|
|
147
160
|
super
|
148
161
|
end
|
149
162
|
|
150
|
-
# inserts an item at the index
|
163
|
+
# inserts an item at the index specified
|
151
164
|
# @param [Integer] index
|
152
165
|
# @param [Any] v
|
153
166
|
# @raise [ArgumentError] if the index is protected by locking
|
data/lib/axlsx/util/storage.rb
CHANGED
@@ -85,16 +85,16 @@ module Axlsx
|
|
85
85
|
# @return [Integer] sector
|
86
86
|
attr_accessor :sector
|
87
87
|
|
88
|
-
# The 0 based index in the
|
88
|
+
# The 0 based index in the directories chain for this the left sibling of this storage.
|
89
89
|
|
90
90
|
# @return [Integer] left
|
91
91
|
attr_accessor :left
|
92
92
|
|
93
|
-
# The 0 based index in the
|
93
|
+
# The 0 based index in the directories chain for this the right sibling of this storage.
|
94
94
|
# @return [Integer] right
|
95
95
|
attr_accessor :right
|
96
96
|
|
97
|
-
# The 0 based index in the
|
97
|
+
# The 0 based index in the directories chain for the child of this storage.
|
98
98
|
# @return [Integer] child
|
99
99
|
attr_accessor :child
|
100
100
|
|
@@ -81,7 +81,7 @@ module Axlsx
|
|
81
81
|
raise ArgumentError, format(ERR_ANGLE, v.inspect) unless v.to_i >= -5400000 && v.to_i <= 5400000
|
82
82
|
end
|
83
83
|
|
84
|
-
# Validates an unsigned
|
84
|
+
# Validates an unsigned integer
|
85
85
|
UINT_VALIDATOR = ->(arg) { arg.respond_to?(:>=) && arg >= 0 }
|
86
86
|
|
87
87
|
# Requires that the value is a Integer and is greater or equal to 0
|
data/lib/axlsx/version.rb
CHANGED
@@ -22,7 +22,7 @@
|
|
22
22
|
# <xsd:attribute name="shortcutKey" type="s:ST_Xstring" use="optional"/>
|
23
23
|
# <xsd:attribute name="publishToServer" type="xsd:boolean" use="optional" default="false"/>
|
24
24
|
# <xsd:attribute name="workbookParameter" type="xsd:boolean" use="optional" default="false"/>
|
25
|
-
# </xsd:
|
25
|
+
# </xsd:extension>
|
26
26
|
# </xsd:simpleContent>
|
27
27
|
|
28
28
|
module Axlsx
|