caxlsx 4.4.1 → 4.4.2
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 +9 -0
- data/lib/axlsx/drawing/axis.rb +34 -2
- data/lib/axlsx/drawing/cat_axis.rb +8 -10
- data/lib/axlsx/drawing/drawing.rb +50 -50
- data/lib/axlsx/drawing/ser_axis.rb +6 -7
- data/lib/axlsx/stylesheet/styles.rb +20 -18
- data/lib/axlsx/util/zip_command.rb +1 -1
- data/lib/axlsx/version.rb +1 -1
- data/lib/axlsx/workbook/workbook.rb +63 -58
- data/lib/axlsx/workbook/worksheet/auto_filter/auto_filter.rb +19 -5
- data/lib/axlsx/workbook/worksheet/auto_filter/sort_state.rb +0 -2
- data/lib/axlsx/workbook/worksheet/worksheet.rb +1 -3
- data/lib/axlsx.rb +17 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 033d0bf9c5c5bbc7f229a6b0f7e1096c18228c2a45e52f986b20b0e9be727e7d
|
|
4
|
+
data.tar.gz: 0e1f11c9d82aa7022fde87ce6e46d2a2df6fb0bb628e6a3cb32c2bfa0b154974
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 505d76a46958eb1f87ca56e68dab1d7a9c4b9a29669176a57e1090b0badb30572aba05dab0dc4cc9f6c3568d98ac282370f9c5fadace96f513ab98dc28e235ce
|
|
7
|
+
data.tar.gz: dec00692600e59ec8bf1dfecb7aea03e535c12030d0a658f26313576dd3d62513c8b6f447af26846667e80b0f3482e7de69b67f30d7a4eb80b1ad14d84b9bf35
|
data/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,15 @@ CHANGELOG
|
|
|
2
2
|
---------
|
|
3
3
|
- **Unreleased**
|
|
4
4
|
|
|
5
|
+
- **March.23.26**: 4.4.2
|
|
6
|
+
- [PR #510](https://github.com/caxlsx/caxlsx/pull/510) Add configurable `major_tick_mark` and `minor_tick_mark` attributes to chart axes
|
|
7
|
+
- [PR #495](https://github.com/caxlsx/caxlsx/pull/495) Make worksheet name length validation optional
|
|
8
|
+
- [PR #496](https://github.com/caxlsx/caxlsx/pull/496) Fix FrozenError when passing in a frozen hash to add_style
|
|
9
|
+
- [PR #500](https://github.com/caxlsx/caxlsx/pull/500) Full Ruby 4.0 compatibility
|
|
10
|
+
- [PR #504](https://github.com/caxlsx/caxlsx/pull/504) Support automatic tick label intervals on chart axes
|
|
11
|
+
- [PR #508](https://github.com/caxlsx/caxlsx/pull/508) Auto-insert missing rows or columns to make autofilter works when using not yet existing ranges
|
|
12
|
+
- [PR #512](https://github.com/caxlsx/caxlsx/pull/512) Freeze valid tick mark values constant
|
|
13
|
+
|
|
5
14
|
- **December.03.25**: 4.4.1
|
|
6
15
|
- [PR #482](https://github.com/caxlsx/caxlsx/pull/482) Suppress Zip64 when it't not necessary
|
|
7
16
|
|
data/lib/axlsx/drawing/axis.rb
CHANGED
|
@@ -19,6 +19,8 @@ module Axlsx
|
|
|
19
19
|
@title = @color = nil
|
|
20
20
|
self.ax_pos = :b
|
|
21
21
|
self.tick_lbl_pos = :nextTo
|
|
22
|
+
self.major_tick_mark = :cross
|
|
23
|
+
self.minor_tick_mark = :none
|
|
22
24
|
self.format_code = "General"
|
|
23
25
|
self.crosses = :autoZero
|
|
24
26
|
self.gridlines = true
|
|
@@ -57,6 +59,18 @@ module Axlsx
|
|
|
57
59
|
attr_reader :tick_lbl_pos
|
|
58
60
|
alias :tickLblPos :tick_lbl_pos
|
|
59
61
|
|
|
62
|
+
# the type of major tick mark
|
|
63
|
+
# must be one of [:cross, :in, :none, :out]
|
|
64
|
+
# @return [Symbol]
|
|
65
|
+
attr_reader :major_tick_mark
|
|
66
|
+
alias :majorTickMark :major_tick_mark
|
|
67
|
+
|
|
68
|
+
# the type of minor tick mark
|
|
69
|
+
# must be one of [:cross, :in, :none, :out]
|
|
70
|
+
# @return [Symbol]
|
|
71
|
+
attr_reader :minor_tick_mark
|
|
72
|
+
alias :minorTickMark :minor_tick_mark
|
|
73
|
+
|
|
60
74
|
# The number format format code for this axis
|
|
61
75
|
# default :General
|
|
62
76
|
# @return [String]
|
|
@@ -113,6 +127,24 @@ module Axlsx
|
|
|
113
127
|
end
|
|
114
128
|
alias :tickLblPos= :tick_lbl_pos=
|
|
115
129
|
|
|
130
|
+
VALID_TICK_MARK_VALUES = [:cross, :in, :none, :out].freeze
|
|
131
|
+
|
|
132
|
+
# the type of major tick mark
|
|
133
|
+
# must be one of [:cross, :in, :none, :out]
|
|
134
|
+
def major_tick_mark=(v)
|
|
135
|
+
RestrictionValidator.validate "#{self.class}.major_tick_mark", VALID_TICK_MARK_VALUES, v
|
|
136
|
+
@major_tick_mark = v
|
|
137
|
+
end
|
|
138
|
+
alias :majorTickMark= :major_tick_mark=
|
|
139
|
+
|
|
140
|
+
# the type of minor tick mark
|
|
141
|
+
# must be one of [:cross, :in, :none, :out]
|
|
142
|
+
def minor_tick_mark=(v)
|
|
143
|
+
RestrictionValidator.validate "#{self.class}.minor_tick_mark", VALID_TICK_MARK_VALUES, v
|
|
144
|
+
@minor_tick_mark = v
|
|
145
|
+
end
|
|
146
|
+
alias :minorTickMark= :minor_tick_mark=
|
|
147
|
+
|
|
116
148
|
# The number format format code for this axis
|
|
117
149
|
# default :General
|
|
118
150
|
def format_code=(v)
|
|
@@ -186,8 +218,8 @@ module Axlsx
|
|
|
186
218
|
# otherwise it will never take, as it will always prefer the 'General' formatting
|
|
187
219
|
# of the cells themselves
|
|
188
220
|
str << '<c:numFmt formatCode="' << @format_code << '" sourceLinked="' << (@format_code.eql?('General') ? '1' : '0') << '"/>'
|
|
189
|
-
str << '<c:majorTickMark val="
|
|
190
|
-
str << '<c:minorTickMark val="
|
|
221
|
+
str << '<c:majorTickMark val="' << @major_tick_mark.to_s << '"/>'
|
|
222
|
+
str << '<c:minorTickMark val="' << @minor_tick_mark.to_s << '"/>'
|
|
191
223
|
str << '<c:tickLblPos val="' << @tick_lbl_pos.to_s << '"/>'
|
|
192
224
|
# TODO: this is also being used for series colors
|
|
193
225
|
# time to extract this into a class spPr - Shape Properties
|
|
@@ -4,11 +4,9 @@ module Axlsx
|
|
|
4
4
|
# A CatAxis object defines a chart category axis
|
|
5
5
|
class CatAxis < Axis
|
|
6
6
|
# Creates a new CatAxis object
|
|
7
|
-
# @option options [Integer] tick_lbl_skip
|
|
8
|
-
# @option options [Integer] tick_mark_skip
|
|
7
|
+
# @option options [Integer, nil] tick_lbl_skip
|
|
8
|
+
# @option options [Integer, nil] tick_mark_skip
|
|
9
9
|
def initialize(options = {})
|
|
10
|
-
@tick_lbl_skip = 1
|
|
11
|
-
@tick_mark_skip = 1
|
|
12
10
|
self.auto = 1
|
|
13
11
|
self.lbl_algn = :ctr
|
|
14
12
|
self.lbl_offset = "100"
|
|
@@ -32,12 +30,12 @@ module Axlsx
|
|
|
32
30
|
alias :lblOffset :lbl_offset
|
|
33
31
|
|
|
34
32
|
# The number of tick labels to skip between labels
|
|
35
|
-
# @return [Integer]
|
|
33
|
+
# @return [Integer, nil]
|
|
36
34
|
attr_reader :tick_lbl_skip
|
|
37
35
|
alias :tickLblSkip :tick_lbl_skip
|
|
38
36
|
|
|
39
37
|
# The number of tickmarks to be skipped before the next one is rendered.
|
|
40
|
-
# @return [
|
|
38
|
+
# @return [Integer, nil]
|
|
41
39
|
attr_reader :tick_mark_skip
|
|
42
40
|
alias :tickMarkSkip :tick_mark_skip
|
|
43
41
|
|
|
@@ -46,14 +44,14 @@ module Axlsx
|
|
|
46
44
|
|
|
47
45
|
# @see tick_lbl_skip
|
|
48
46
|
def tick_lbl_skip=(v)
|
|
49
|
-
Axlsx.validate_unsigned_int(v)
|
|
47
|
+
Axlsx.validate_unsigned_int(v) unless v.nil?
|
|
50
48
|
@tick_lbl_skip = v
|
|
51
49
|
end
|
|
52
50
|
alias :tickLblSkip= :tick_lbl_skip=
|
|
53
51
|
|
|
54
52
|
# @see tick_mark_skip
|
|
55
53
|
def tick_mark_skip=(v)
|
|
56
|
-
Axlsx.validate_unsigned_int(v)
|
|
54
|
+
Axlsx.validate_unsigned_int(v) unless v.nil?
|
|
57
55
|
@tick_mark_skip = v
|
|
58
56
|
end
|
|
59
57
|
alias :tickMarkSkip= :tick_mark_skip=
|
|
@@ -89,8 +87,8 @@ module Axlsx
|
|
|
89
87
|
str << '<c:auto val="' << @auto.to_s << '"/>'
|
|
90
88
|
str << '<c:lblAlgn val="' << @lbl_algn.to_s << '"/>'
|
|
91
89
|
str << '<c:lblOffset val="' << @lbl_offset.to_i.to_s << '"/>'
|
|
92
|
-
str << '<c:tickLblSkip val="' << @tick_lbl_skip.to_s << '"/>'
|
|
93
|
-
str << '<c:tickMarkSkip val="' << @tick_mark_skip.to_s << '"/>'
|
|
90
|
+
str << '<c:tickLblSkip val="' << @tick_lbl_skip.to_s << '"/>' unless @tick_lbl_skip.nil?
|
|
91
|
+
str << '<c:tickMarkSkip val="' << @tick_mark_skip.to_s << '"/>' unless @tick_mark_skip.nil?
|
|
94
92
|
str << '</c:catAx>'
|
|
95
93
|
end
|
|
96
94
|
end
|
|
@@ -1,56 +1,56 @@
|
|
|
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
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
4
|
+
autoload :DLbls, 'axlsx/drawing/d_lbls'
|
|
5
|
+
autoload :Title, 'axlsx/drawing/title'
|
|
6
|
+
autoload :SeriesTitle, 'axlsx/drawing/series_title'
|
|
7
|
+
autoload :Series, 'axlsx/drawing/series'
|
|
8
|
+
autoload :PieSeries, 'axlsx/drawing/pie_series'
|
|
9
|
+
autoload :BarSeries, 'axlsx/drawing/bar_series'
|
|
10
|
+
autoload :LineSeries, 'axlsx/drawing/line_series'
|
|
11
|
+
autoload :ScatterSeries, 'axlsx/drawing/scatter_series'
|
|
12
|
+
autoload :BubbleSeries, 'axlsx/drawing/bubble_series'
|
|
13
|
+
autoload :AreaSeries, 'axlsx/drawing/area_series'
|
|
14
|
+
|
|
15
|
+
autoload :Scaling, 'axlsx/drawing/scaling'
|
|
16
|
+
autoload :Axis, 'axlsx/drawing/axis'
|
|
17
|
+
|
|
18
|
+
autoload :StrVal, 'axlsx/drawing/str_val'
|
|
19
|
+
autoload :NumVal, 'axlsx/drawing/num_val'
|
|
20
|
+
autoload :StrData, 'axlsx/drawing/str_data'
|
|
21
|
+
autoload :NumData, 'axlsx/drawing/num_data'
|
|
22
|
+
autoload :NumDataSource, 'axlsx/drawing/num_data_source'
|
|
23
|
+
autoload :AxDataSource, 'axlsx/drawing/ax_data_source'
|
|
24
|
+
|
|
25
|
+
autoload :SerAxis, 'axlsx/drawing/ser_axis'
|
|
26
|
+
autoload :CatAxis, 'axlsx/drawing/cat_axis'
|
|
27
|
+
autoload :ValAxis, 'axlsx/drawing/val_axis'
|
|
28
|
+
autoload :Axes, 'axlsx/drawing/axes'
|
|
29
|
+
|
|
30
|
+
autoload :Marker, 'axlsx/drawing/marker'
|
|
31
|
+
|
|
32
|
+
autoload :OneCellAnchor, 'axlsx/drawing/one_cell_anchor'
|
|
33
|
+
autoload :TwoCellAnchor, 'axlsx/drawing/two_cell_anchor'
|
|
34
|
+
autoload :GraphicFrame, 'axlsx/drawing/graphic_frame'
|
|
35
|
+
|
|
36
|
+
autoload :View3D, 'axlsx/drawing/view_3D'
|
|
37
|
+
autoload :Chart, 'axlsx/drawing/chart'
|
|
38
|
+
autoload :Pie3DChart, 'axlsx/drawing/pie_3D_chart'
|
|
39
|
+
autoload :PieChart, 'axlsx/drawing/pie_chart'
|
|
40
|
+
autoload :Bar3DChart, 'axlsx/drawing/bar_3D_chart'
|
|
41
|
+
autoload :BarChart, 'axlsx/drawing/bar_chart'
|
|
42
|
+
autoload :LineChart, 'axlsx/drawing/line_chart'
|
|
43
|
+
autoload :Line3DChart, 'axlsx/drawing/line_3D_chart'
|
|
44
|
+
autoload :ScatterChart, 'axlsx/drawing/scatter_chart'
|
|
45
|
+
autoload :BubbleChart, 'axlsx/drawing/bubble_chart'
|
|
46
|
+
autoload :AreaChart, 'axlsx/drawing/area_chart'
|
|
47
|
+
|
|
48
|
+
autoload :PictureLocking, 'axlsx/drawing/picture_locking'
|
|
49
|
+
autoload :Pic, 'axlsx/drawing/pic'
|
|
50
|
+
autoload :Hyperlink, 'axlsx/drawing/hyperlink'
|
|
51
|
+
|
|
52
|
+
autoload :VmlDrawing, 'axlsx/drawing/vml_drawing'
|
|
53
|
+
autoload :VmlShape, 'axlsx/drawing/vml_shape'
|
|
54
54
|
|
|
55
55
|
# A Drawing is a canvas for charts and images. Each worksheet has a single drawing that manages anchors.
|
|
56
56
|
# The anchors reference the charts or images via graphical frames. This is not a trivial relationship so please do follow the advice in the note.
|
|
@@ -4,33 +4,32 @@ module Axlsx
|
|
|
4
4
|
# A SerAxis object defines a series axis
|
|
5
5
|
class SerAxis < Axis
|
|
6
6
|
# The number of tick labels to skip between labels
|
|
7
|
-
# @return [Integer]
|
|
7
|
+
# @return [Integer, nil]
|
|
8
8
|
attr_reader :tick_lbl_skip
|
|
9
9
|
alias :tickLblSkip :tick_lbl_skip
|
|
10
10
|
|
|
11
11
|
# The number of tickmarks to be skipped before the next one is rendered.
|
|
12
|
-
# @return [
|
|
12
|
+
# @return [Integer, nil]
|
|
13
13
|
attr_reader :tick_mark_skip
|
|
14
14
|
alias :tickMarkSkip :tick_mark_skip
|
|
15
15
|
|
|
16
16
|
# Creates a new SerAxis object
|
|
17
|
-
# @option options [Integer] tick_lbl_skip
|
|
18
|
-
# @option options [Integer] tick_mark_skip
|
|
17
|
+
# @option options [Integer, nil] tick_lbl_skip
|
|
18
|
+
# @option options [Integer, nil] tick_mark_skip
|
|
19
19
|
def initialize(options = {})
|
|
20
|
-
@tick_lbl_skip, @tick_mark_skip = 1, 1
|
|
21
20
|
super
|
|
22
21
|
end
|
|
23
22
|
|
|
24
23
|
# @see tickLblSkip
|
|
25
24
|
def tick_lbl_skip=(v)
|
|
26
|
-
Axlsx.validate_unsigned_int(v)
|
|
25
|
+
Axlsx.validate_unsigned_int(v) unless v.nil?
|
|
27
26
|
@tick_lbl_skip = v
|
|
28
27
|
end
|
|
29
28
|
alias :tickLblSkip= :tick_lbl_skip=
|
|
30
29
|
|
|
31
30
|
# @see tickMarkSkip
|
|
32
31
|
def tick_mark_skip=(v)
|
|
33
|
-
Axlsx.validate_unsigned_int(v)
|
|
32
|
+
Axlsx.validate_unsigned_int(v) unless v.nil?
|
|
34
33
|
@tick_mark_skip = v
|
|
35
34
|
end
|
|
36
35
|
alias :tickMarkSkip= :tick_mark_skip=
|
|
@@ -1,24 +1,24 @@
|
|
|
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
|
-
|
|
21
|
-
|
|
4
|
+
autoload :Border, 'axlsx/stylesheet/border'
|
|
5
|
+
autoload :BorderPr, 'axlsx/stylesheet/border_pr'
|
|
6
|
+
autoload :CellAlignment, 'axlsx/stylesheet/cell_alignment'
|
|
7
|
+
autoload :CellStyle, 'axlsx/stylesheet/cell_style'
|
|
8
|
+
autoload :Color, 'axlsx/stylesheet/color'
|
|
9
|
+
autoload :Fill, 'axlsx/stylesheet/fill'
|
|
10
|
+
autoload :Font, 'axlsx/stylesheet/font'
|
|
11
|
+
autoload :GradientFill, 'axlsx/stylesheet/gradient_fill'
|
|
12
|
+
autoload :GradientStop, 'axlsx/stylesheet/gradient_stop'
|
|
13
|
+
autoload :NumFmt, 'axlsx/stylesheet/num_fmt'
|
|
14
|
+
autoload :PatternFill, 'axlsx/stylesheet/pattern_fill'
|
|
15
|
+
autoload :TableStyle, 'axlsx/stylesheet/table_style'
|
|
16
|
+
autoload :TableStyles, 'axlsx/stylesheet/table_styles'
|
|
17
|
+
autoload :TableStyleElement, 'axlsx/stylesheet/table_style_element'
|
|
18
|
+
autoload :Theme, 'axlsx/stylesheet/theme'
|
|
19
|
+
autoload :Dxf, 'axlsx/stylesheet/dxf'
|
|
20
|
+
autoload :Xf, 'axlsx/stylesheet/xf'
|
|
21
|
+
autoload :CellProtection, 'axlsx/stylesheet/cell_protection'
|
|
22
22
|
|
|
23
23
|
# The Styles class manages worksheet styles
|
|
24
24
|
# 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.
|
|
@@ -228,6 +228,8 @@ module Axlsx
|
|
|
228
228
|
# An index for cell styles where keys are styles codes as per Axlsx::Style and values are Cell#raw_style
|
|
229
229
|
# The reason for the backward key/value ordering is that style lookup must be most efficient, while `add_style` can be less efficient
|
|
230
230
|
def add_style(options = {})
|
|
231
|
+
options = options.dup
|
|
232
|
+
|
|
231
233
|
# Default to :xf
|
|
232
234
|
options[:type] ||= :xf
|
|
233
235
|
|
|
@@ -40,7 +40,7 @@ module Axlsx
|
|
|
40
40
|
@current_file = "#{@dir}/#{entry.name}"
|
|
41
41
|
@files << entry.name
|
|
42
42
|
FileUtils.mkdir_p(File.dirname(@current_file))
|
|
43
|
-
@io = File.open(@current_file, "wb")
|
|
43
|
+
@io = File.open(@current_file, "wb") # rubocop:disable Style/FileOpen -- we're passing over the file descriptor intentionally
|
|
44
44
|
end
|
|
45
45
|
|
|
46
46
|
# Write to a buffer that will be written to the current entry
|
data/lib/axlsx/version.rb
CHANGED
|
@@ -1,64 +1,69 @@
|
|
|
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
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
4
|
+
autoload :SheetCalcPr, 'axlsx/workbook/worksheet/sheet_calc_pr'
|
|
5
|
+
autoload :AutoFilter, 'axlsx/workbook/worksheet/auto_filter/auto_filter'
|
|
6
|
+
autoload :FilterColumn, 'axlsx/workbook/worksheet/auto_filter/filter_column'
|
|
7
|
+
autoload :Filters, 'axlsx/workbook/worksheet/auto_filter/filters'
|
|
8
|
+
autoload :SortState, 'axlsx/workbook/worksheet/auto_filter/sort_state'
|
|
9
|
+
autoload :SortCondition, 'axlsx/workbook/worksheet/auto_filter/sort_condition'
|
|
10
|
+
autoload :DateTimeConverter, 'axlsx/workbook/worksheet/date_time_converter'
|
|
11
|
+
autoload :ProtectedRange, 'axlsx/workbook/worksheet/protected_range'
|
|
12
|
+
autoload :ProtectedRanges, 'axlsx/workbook/worksheet/protected_ranges'
|
|
13
|
+
autoload :RichTextRun, 'axlsx/workbook/worksheet/rich_text_run'
|
|
14
|
+
autoload :RichText, 'axlsx/workbook/worksheet/rich_text'
|
|
15
|
+
autoload :CellSerializer, 'axlsx/workbook/worksheet/cell_serializer'
|
|
16
|
+
autoload :Cell, 'axlsx/workbook/worksheet/cell'
|
|
17
|
+
autoload :PageMargins, 'axlsx/workbook/worksheet/page_margins'
|
|
18
|
+
autoload :PageSetUpPr, 'axlsx/workbook/worksheet/page_set_up_pr'
|
|
19
|
+
autoload :OutlinePr, 'axlsx/workbook/worksheet/outline_pr'
|
|
20
|
+
autoload :PageSetup, 'axlsx/workbook/worksheet/page_setup'
|
|
21
|
+
autoload :HeaderFooter, 'axlsx/workbook/worksheet/header_footer'
|
|
22
|
+
autoload :PrintOptions, 'axlsx/workbook/worksheet/print_options'
|
|
23
|
+
autoload :Cfvo, 'axlsx/workbook/worksheet/cfvo'
|
|
24
|
+
autoload :Cfvos, 'axlsx/workbook/worksheet/cfvos'
|
|
25
|
+
autoload :ColorScale, 'axlsx/workbook/worksheet/color_scale'
|
|
26
|
+
autoload :DataBar, 'axlsx/workbook/worksheet/data_bar'
|
|
27
|
+
autoload :IconSet, 'axlsx/workbook/worksheet/icon_set'
|
|
28
|
+
autoload :ConditionalFormatting, 'axlsx/workbook/worksheet/conditional_formatting'
|
|
29
|
+
autoload :ConditionalFormattingRule, 'axlsx/workbook/worksheet/conditional_formatting_rule'
|
|
30
|
+
autoload :ConditionalFormattings, 'axlsx/workbook/worksheet/conditional_formattings'
|
|
31
|
+
autoload :Row, 'axlsx/workbook/worksheet/row'
|
|
32
|
+
autoload :Col, 'axlsx/workbook/worksheet/col'
|
|
33
|
+
autoload :Cols, 'axlsx/workbook/worksheet/cols'
|
|
34
|
+
autoload :Comments, 'axlsx/workbook/worksheet/comments'
|
|
35
|
+
autoload :Comment, 'axlsx/workbook/worksheet/comment'
|
|
36
|
+
autoload :MergedCells, 'axlsx/workbook/worksheet/merged_cells'
|
|
37
|
+
autoload :SheetProtection, 'axlsx/workbook/worksheet/sheet_protection'
|
|
38
|
+
autoload :SheetPr, 'axlsx/workbook/worksheet/sheet_pr'
|
|
39
|
+
autoload :Dimension, 'axlsx/workbook/worksheet/dimension'
|
|
40
|
+
autoload :SheetData, 'axlsx/workbook/worksheet/sheet_data'
|
|
41
|
+
autoload :WorksheetDrawing, 'axlsx/workbook/worksheet/worksheet_drawing'
|
|
42
|
+
autoload :WorksheetComments, 'axlsx/workbook/worksheet/worksheet_comments'
|
|
43
|
+
autoload :WorksheetHyperlink, 'axlsx/workbook/worksheet/worksheet_hyperlink'
|
|
44
|
+
autoload :WorksheetHyperlinks, 'axlsx/workbook/worksheet/worksheet_hyperlinks'
|
|
45
|
+
autoload :Break, 'axlsx/workbook/worksheet/break'
|
|
46
|
+
autoload :RowBreaks, 'axlsx/workbook/worksheet/row_breaks'
|
|
47
|
+
autoload :ColBreaks, 'axlsx/workbook/worksheet/col_breaks'
|
|
48
|
+
autoload :WorkbookView, 'axlsx/workbook/workbook_view'
|
|
49
|
+
autoload :WorkbookViews, 'axlsx/workbook/workbook_views'
|
|
50
|
+
autoload :Worksheet, 'axlsx/workbook/worksheet/worksheet'
|
|
51
|
+
autoload :BorderCreator, 'axlsx/workbook/worksheet/border_creator'
|
|
52
|
+
autoload :SharedStringsTable, 'axlsx/workbook/shared_strings_table'
|
|
53
|
+
autoload :DefinedName, 'axlsx/workbook/defined_name'
|
|
54
|
+
autoload :DefinedNames, 'axlsx/workbook/defined_names'
|
|
55
|
+
autoload :TableStyleInfo, 'axlsx/workbook/worksheet/table_style_info'
|
|
56
|
+
autoload :Table, 'axlsx/workbook/worksheet/table'
|
|
57
|
+
autoload :Tables, 'axlsx/workbook/worksheet/tables'
|
|
58
|
+
autoload :PivotTableCacheDefinition, 'axlsx/workbook/worksheet/pivot_table_cache_definition'
|
|
59
|
+
autoload :PivotTable, 'axlsx/workbook/worksheet/pivot_table'
|
|
60
|
+
autoload :PivotTables, 'axlsx/workbook/worksheet/pivot_tables'
|
|
61
|
+
autoload :DataValidation, 'axlsx/workbook/worksheet/data_validation'
|
|
62
|
+
autoload :DataValidations, 'axlsx/workbook/worksheet/data_validations'
|
|
63
|
+
autoload :SheetView, 'axlsx/workbook/worksheet/sheet_view'
|
|
64
|
+
autoload :SheetFormatPr, 'axlsx/workbook/worksheet/sheet_format_pr'
|
|
65
|
+
autoload :Pane, 'axlsx/workbook/worksheet/pane'
|
|
66
|
+
autoload :Selection, 'axlsx/workbook/worksheet/selection'
|
|
62
67
|
|
|
63
68
|
# The Workbook class is an xlsx workbook that manages worksheets, charts, drawings and styles.
|
|
64
69
|
# The following parts of the Office Open XML spreadsheet specification are not implemented in this version.
|
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require_relative 'filter_column'
|
|
4
|
-
require_relative 'filters'
|
|
5
|
-
require_relative 'sort_state'
|
|
6
|
-
|
|
7
3
|
module Axlsx
|
|
8
4
|
# This class represents an auto filter range in a worksheet
|
|
9
5
|
class AutoFilter
|
|
@@ -30,7 +26,25 @@ module Axlsx
|
|
|
30
26
|
def defined_name
|
|
31
27
|
return unless range
|
|
32
28
|
|
|
33
|
-
|
|
29
|
+
cells = range.split(':').collect do |name|
|
|
30
|
+
cell = worksheet.name_to_cell(name)
|
|
31
|
+
next cell if cell
|
|
32
|
+
|
|
33
|
+
# We're calculating the defined_name for the AutoFilter just before serializing,
|
|
34
|
+
# so in theory adding new rows or columns should not cause weird offset issues
|
|
35
|
+
col_index, row_index = *Axlsx.name_to_indices(name)
|
|
36
|
+
while (row = worksheet.rows[row_index]).nil?
|
|
37
|
+
worksheet.add_row
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
while (cell = row[col_index]).nil?
|
|
41
|
+
row.add_cell
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
cell
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
Axlsx.cell_range(cells)
|
|
34
48
|
end
|
|
35
49
|
|
|
36
50
|
# A collection of filterColumns for this auto_filter
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require_relative "border_creator"
|
|
4
|
-
|
|
5
3
|
module Axlsx
|
|
6
4
|
# The Worksheet class represents a worksheet in the workbook.
|
|
7
5
|
class Worksheet
|
|
@@ -768,7 +766,7 @@ module Axlsx
|
|
|
768
766
|
raise ArgumentError, ERR_SHEET_NAME_EMPTY if name.empty?
|
|
769
767
|
|
|
770
768
|
character_length = name.encode("utf-16")[1..-1].encode("utf-16").bytesize / 2
|
|
771
|
-
raise ArgumentError, format(ERR_SHEET_NAME_TOO_LONG, name) if character_length > WORKSHEET_MAX_NAME_LENGTH
|
|
769
|
+
raise ArgumentError, format(ERR_SHEET_NAME_TOO_LONG, name) if character_length > WORKSHEET_MAX_NAME_LENGTH && Axlsx.validate_sheet_name_length
|
|
772
770
|
raise ArgumentError, format(ERR_SHEET_NAME_CHARACTER_FORBIDDEN, name) if WORKSHEET_NAME_FORBIDDEN_CHARS.any? { |char| name.include? char }
|
|
773
771
|
|
|
774
772
|
name = Axlsx.coder.encode(name)
|
data/lib/axlsx.rb
CHANGED
|
@@ -9,7 +9,7 @@ require 'nokogiri'
|
|
|
9
9
|
require 'zip'
|
|
10
10
|
|
|
11
11
|
# Ruby core dependencies
|
|
12
|
-
require 'cgi'
|
|
12
|
+
require 'cgi/escape'
|
|
13
13
|
require 'set'
|
|
14
14
|
require 'time'
|
|
15
15
|
require 'uri'
|
|
@@ -231,6 +231,22 @@ module Axlsx
|
|
|
231
231
|
@escape_formulas = value
|
|
232
232
|
end
|
|
233
233
|
|
|
234
|
+
# Whether to validate the sheet name length.
|
|
235
|
+
# @return [Boolean]
|
|
236
|
+
def self.validate_sheet_name_length
|
|
237
|
+
!defined?(@validate_sheet_name_length) || @validate_sheet_name_length.then { |v| v.nil? || v }
|
|
238
|
+
end
|
|
239
|
+
|
|
240
|
+
# Sets whether to validate sheet name length.
|
|
241
|
+
# By default it validates the max length for sheet names to make it compatible with Microsoft Excel
|
|
242
|
+
# On paper, and by real world examples this is still a valid limitation, but some implementations (e.g. Libre Office) might not break on longer names.
|
|
243
|
+
# Use it if you are sure that the end users could still open the files.
|
|
244
|
+
# @param [Boolean] value The value to set.
|
|
245
|
+
def self.validate_sheet_name_length=(value)
|
|
246
|
+
Axlsx.validate_boolean(value)
|
|
247
|
+
@validate_sheet_name_length = value
|
|
248
|
+
end
|
|
249
|
+
|
|
234
250
|
# Returns a URI parser instance, preferring RFC2396_PARSER if available,
|
|
235
251
|
# otherwise falling back to DEFAULT_PARSER. This method ensures consistent
|
|
236
252
|
# URI parsing across different Ruby versions.
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: caxlsx
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 4.4.
|
|
4
|
+
version: 4.4.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Randy Morgan
|
|
@@ -312,7 +312,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
312
312
|
- !ruby/object:Gem::Version
|
|
313
313
|
version: '0'
|
|
314
314
|
requirements: []
|
|
315
|
-
rubygems_version:
|
|
315
|
+
rubygems_version: 4.0.6
|
|
316
316
|
specification_version: 4
|
|
317
317
|
summary: Excel OOXML (xlsx) with charts, styles, images and autowidth columns.
|
|
318
318
|
test_files: []
|