caxlsx 4.1.0 → 4.3.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 +28 -12
- data/README.md +7 -1
- data/Rakefile +2 -9
- 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 +14 -4
- data/lib/axlsx/drawing/bar_chart.rb +14 -4
- 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/chart.rb +1 -0
- data/lib/axlsx/drawing/d_lbls.rb +5 -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/drawing/vml_shape.rb +1 -1
- data/lib/axlsx/package.rb +10 -12
- data/lib/axlsx/rels/relationship.rb +2 -2
- data/lib/axlsx/rels/relationships.rb +2 -2
- data/lib/axlsx/stylesheet/border_pr.rb +2 -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/pattern_fill.rb +1 -0
- data/lib/axlsx/stylesheet/styles.rb +27 -31
- data/lib/axlsx/stylesheet/xf.rb +2 -1
- data/lib/axlsx/util/accessors.rb +1 -1
- data/lib/axlsx/util/buffered_zip_output_stream.rb +2 -2
- 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 +26 -14
- data/lib/axlsx/util/storage.rb +3 -3
- data/lib/axlsx/util/validators.rb +2 -2
- data/lib/axlsx/version.rb +1 -1
- data/lib/axlsx/workbook/defined_name.rb +2 -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 +4 -4
- 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 +10 -10
- data/lib/axlsx/workbook/worksheet/cell_serializer.rb +1 -1
- data/lib/axlsx/workbook/worksheet/col.rb +23 -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/header_footer.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/pane.rb +1 -0
- data/lib/axlsx/workbook/worksheet/pivot_table.rb +30 -6
- data/lib/axlsx/workbook/worksheet/print_options.rb +1 -0
- data/lib/axlsx/workbook/worksheet/rich_text_run.rb +1 -1
- data/lib/axlsx/workbook/worksheet/sheet_calc_pr.rb +1 -0
- data/lib/axlsx/workbook/worksheet/sheet_pr.rb +1 -1
- data/lib/axlsx/workbook/worksheet/table_style_info.rb +2 -1
- data/lib/axlsx/workbook/worksheet/worksheet.rb +10 -12
- data/lib/axlsx/workbook/worksheet/worksheet_comments.rb +4 -4
- data/lib/axlsx/workbook/worksheet/worksheet_drawing.rb +1 -1
- data/lib/axlsx/workbook/worksheet/worksheet_hyperlink.rb +2 -1
- data/lib/axlsx/workbook/worksheet/worksheet_hyperlinks.rb +1 -1
- data/lib/axlsx.rb +44 -30
- data/lib/caxlsx.rb +1 -1
- metadata +7 -10
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Axlsx
|
4
|
-
# The LineChart is a two
|
4
|
+
# The LineChart is a two dimensional line chart (who would have guessed?) that you can add to your worksheet.
|
5
5
|
# @example Creating a chart
|
6
6
|
# # This example creates a line in a single sheet.
|
7
7
|
# require "rubygems" # if that is your preferred way to manage gems!
|
@@ -47,7 +47,7 @@ module Axlsx
|
|
47
47
|
def initialize(frame, options = {})
|
48
48
|
@vary_colors = false
|
49
49
|
@grouping = :standard
|
50
|
-
super
|
50
|
+
super
|
51
51
|
@series_type = LineSeries
|
52
52
|
@d_lbls = nil
|
53
53
|
end
|
@@ -75,7 +75,7 @@ module Axlsx
|
|
75
75
|
# @param [String] str
|
76
76
|
# @return [String]
|
77
77
|
def to_xml_string(str = +'')
|
78
|
-
super
|
78
|
+
super do
|
79
79
|
str << "<c:" << node_name << ">"
|
80
80
|
str << '<c:grouping val="' << grouping.to_s << '"/>'
|
81
81
|
str << '<c:varyColors val="' << vary_colors.to_s << '"/>'
|
@@ -40,7 +40,7 @@ module Axlsx
|
|
40
40
|
@marker_symbol = options[:marker_symbol] || :default
|
41
41
|
@smooth = false
|
42
42
|
@labels, @data = nil, nil
|
43
|
-
super
|
43
|
+
super
|
44
44
|
@labels = AxDataSource.new(data: options[:labels]) unless options[:labels].nil?
|
45
45
|
@data = NumDataSource.new(options) unless options[:data].nil?
|
46
46
|
end
|
@@ -72,7 +72,7 @@ module Axlsx
|
|
72
72
|
# @param [String] str
|
73
73
|
# @return [String]
|
74
74
|
def to_xml_string(str = +'')
|
75
|
-
super
|
75
|
+
super do
|
76
76
|
if color
|
77
77
|
str << '<c:spPr><a:solidFill>'
|
78
78
|
str << '<a:srgbClr val="' << color << '"/>'
|
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
|
@@ -147,7 +147,7 @@ module Axlsx
|
|
147
147
|
|
148
148
|
# Encrypt the package into a CFB using the password provided
|
149
149
|
# This is not ready yet
|
150
|
-
def encrypt(file_name, password)
|
150
|
+
def encrypt(file_name, password) # rubocop:disable Naming/PredicateMethod
|
151
151
|
false
|
152
152
|
# moc = MsOffCrypto.new(file_name, password)
|
153
153
|
# moc.save
|
@@ -207,11 +207,12 @@ 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)
|
214
|
-
|
214
|
+
|
215
|
+
Zip::Entry.new("", part[:entry], time: timestamp)
|
215
216
|
end
|
216
217
|
|
217
218
|
# The parts of a package
|
@@ -273,7 +274,7 @@ module Axlsx
|
|
273
274
|
]
|
274
275
|
end
|
275
276
|
|
276
|
-
# Performs xsd validation for a
|
277
|
+
# Performs xsd validation for a single document
|
277
278
|
#
|
278
279
|
# @param [String] schema path to the xsd schema to be used in validation.
|
279
280
|
# @param [String] doc The xml text to be validated
|
@@ -282,11 +283,8 @@ module Axlsx
|
|
282
283
|
def validate_single_doc(schema, doc)
|
283
284
|
schema = Nokogiri::XML::Schema(File.open(schema))
|
284
285
|
doc = Nokogiri::XML(doc)
|
285
|
-
|
286
|
-
schema.validate(doc)
|
287
|
-
errors << error
|
288
|
-
end
|
289
|
-
errors
|
286
|
+
|
287
|
+
schema.validate(doc)
|
290
288
|
end
|
291
289
|
|
292
290
|
# 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
|
@@ -4,10 +4,11 @@ module Axlsx
|
|
4
4
|
# A border part.
|
5
5
|
class BorderPr
|
6
6
|
include Axlsx::OptionsParser
|
7
|
+
|
7
8
|
# @return [Color] The color of this border part.
|
8
9
|
attr_reader :color
|
9
10
|
|
10
|
-
# @return [Symbol] The
|
11
|
+
# @return [Symbol] The style of this border part.
|
11
12
|
# @note
|
12
13
|
# The following are allowed
|
13
14
|
# :none
|
@@ -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
@@ -8,6 +8,7 @@ module Axlsx
|
|
8
8
|
|
9
9
|
include Axlsx::SerializedAttributes
|
10
10
|
include Axlsx::OptionsParser
|
11
|
+
|
11
12
|
# Creates a new Xf object
|
12
13
|
# @option options [Integer] numFmtId
|
13
14
|
# @option options [Integer] fontId
|
@@ -62,7 +63,7 @@ module Axlsx
|
|
62
63
|
# @return [Integer]
|
63
64
|
attr_reader :xfId
|
64
65
|
|
65
|
-
#
|
66
|
+
# indicates if text should be prefixed by a single quote in the cell
|
66
67
|
# @return [Boolean]
|
67
68
|
attr_reader :quotePrefix
|
68
69
|
|
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)
|
@@ -19,7 +19,7 @@ module Axlsx
|
|
19
19
|
#
|
20
20
|
# The directory and its contents are removed at the end of the block.
|
21
21
|
def self.open(file_name, encrypter = nil)
|
22
|
-
Zip::OutputStream.open(file_name, encrypter) do |zos|
|
22
|
+
Zip::OutputStream.open(file_name, encrypter: encrypter) do |zos|
|
23
23
|
bzos = new(zos)
|
24
24
|
yield(bzos)
|
25
25
|
ensure
|
@@ -28,7 +28,7 @@ module Axlsx
|
|
28
28
|
end
|
29
29
|
|
30
30
|
def self.write_buffer(io = ::StringIO.new, encrypter = nil)
|
31
|
-
Zip::OutputStream.write_buffer(io, encrypter) do |zos|
|
31
|
+
Zip::OutputStream.write_buffer(io, encrypter: encrypter) do |zos|
|
32
32
|
bzos = new(zos)
|
33
33
|
yield(bzos)
|
34
34
|
ensure
|
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.
|