caxlsx 4.0.0 → 4.2.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 +29 -12
- data/README.md +1 -1
- data/examples/generate.rb +3 -1
- data/lib/axlsx/content_type/abstract_content_type.rb +6 -3
- data/lib/axlsx/content_type/content_type.rb +4 -4
- data/lib/axlsx/content_type/default.rb +4 -1
- data/lib/axlsx/content_type/override.rb +4 -1
- data/lib/axlsx/doc_props/app.rb +91 -24
- data/lib/axlsx/drawing/area_chart.rb +3 -3
- data/lib/axlsx/drawing/area_series.rb +10 -4
- data/lib/axlsx/drawing/ax_data_source.rb +1 -1
- data/lib/axlsx/drawing/axes.rb +1 -1
- data/lib/axlsx/drawing/axis.rb +25 -7
- 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 +14 -5
- 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 +23 -8
- data/lib/axlsx/drawing/chart.rb +32 -8
- data/lib/axlsx/drawing/d_lbls.rb +8 -8
- data/lib/axlsx/drawing/drawing.rb +50 -49
- data/lib/axlsx/drawing/hyperlink.rb +13 -4
- 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 +10 -4
- data/lib/axlsx/drawing/marker.rb +19 -4
- data/lib/axlsx/drawing/num_val.rb +1 -1
- data/lib/axlsx/drawing/one_cell_anchor.rb +8 -2
- data/lib/axlsx/drawing/pic.rb +17 -8
- data/lib/axlsx/drawing/pie_3D_chart.rb +3 -3
- data/lib/axlsx/drawing/pie_chart.rb +36 -0
- data/lib/axlsx/drawing/pie_series.rb +18 -6
- data/lib/axlsx/drawing/scaling.rb +18 -4
- 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 +11 -5
- data/lib/axlsx/drawing/series.rb +8 -2
- data/lib/axlsx/drawing/two_cell_anchor.rb +1 -1
- data/lib/axlsx/drawing/val_axis.rb +2 -2
- data/lib/axlsx/drawing/view_3D.rb +8 -2
- data/lib/axlsx/package.rb +11 -11
- data/lib/axlsx/rels/relationship.rb +15 -5
- data/lib/axlsx/rels/relationships.rb +3 -3
- data/lib/axlsx/stylesheet/border.rb +12 -3
- data/lib/axlsx/stylesheet/border_pr.rb +15 -4
- data/lib/axlsx/stylesheet/cell_alignment.rb +39 -10
- data/lib/axlsx/stylesheet/cell_protection.rb +9 -2
- data/lib/axlsx/stylesheet/cell_style.rb +30 -7
- data/lib/axlsx/stylesheet/color.rb +10 -4
- data/lib/axlsx/stylesheet/dxf.rb +29 -6
- data/lib/axlsx/stylesheet/fill.rb +4 -1
- data/lib/axlsx/stylesheet/font.rb +59 -13
- data/lib/axlsx/stylesheet/gradient_fill.rb +9 -3
- data/lib/axlsx/stylesheet/gradient_stop.rb +9 -2
- data/lib/axlsx/stylesheet/num_fmt.rb +8 -2
- data/lib/axlsx/stylesheet/pattern_fill.rb +14 -3
- data/lib/axlsx/stylesheet/styles.rb +83 -43
- data/lib/axlsx/stylesheet/table_style.rb +15 -4
- data/lib/axlsx/stylesheet/table_style_element.rb +12 -3
- data/lib/axlsx/stylesheet/table_styles.rb +10 -3
- data/lib/axlsx/stylesheet/xf.rb +69 -16
- data/lib/axlsx/util/accessors.rb +9 -7
- 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 +4 -4
- 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/defined_names.rb +1 -1
- data/lib/axlsx/workbook/shared_strings_table.rb +3 -3
- data/lib/axlsx/workbook/workbook.rb +80 -67
- data/lib/axlsx/workbook/workbook_views.rb +1 -1
- data/lib/axlsx/workbook/worksheet/auto_filter/auto_filter.rb +4 -4
- data/lib/axlsx/workbook/worksheet/auto_filter/filter_column.rb +5 -3
- 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 +37 -17
- data/lib/axlsx/workbook/worksheet/cell_serializer.rb +1 -1
- data/lib/axlsx/workbook/worksheet/cfvo.rb +8 -2
- data/lib/axlsx/workbook/worksheet/col.rb +22 -9
- data/lib/axlsx/workbook/worksheet/col_breaks.rb +1 -1
- data/lib/axlsx/workbook/worksheet/cols.rb +1 -1
- 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 +9 -3
- data/lib/axlsx/workbook/worksheet/conditional_formatting_rule.rb +70 -15
- data/lib/axlsx/workbook/worksheet/conditional_formattings.rb +3 -3
- data/lib/axlsx/workbook/worksheet/data_validation.rb +53 -14
- data/lib/axlsx/workbook/worksheet/data_validations.rb +3 -3
- 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 +17 -5
- data/lib/axlsx/workbook/worksheet/merged_cells.rb +1 -1
- data/lib/axlsx/workbook/worksheet/outline_pr.rb +1 -1
- data/lib/axlsx/workbook/worksheet/page_margins.rb +30 -7
- data/lib/axlsx/workbook/worksheet/page_set_up_pr.rb +1 -2
- data/lib/axlsx/workbook/worksheet/page_setup.rb +32 -9
- data/lib/axlsx/workbook/worksheet/pane.rb +8 -2
- data/lib/axlsx/workbook/worksheet/pivot_table.rb +29 -5
- data/lib/axlsx/workbook/worksheet/pivot_tables.rb +1 -1
- data/lib/axlsx/workbook/worksheet/protected_ranges.rb +1 -1
- data/lib/axlsx/workbook/worksheet/rich_text_run.rb +31 -11
- data/lib/axlsx/workbook/worksheet/row.rb +5 -2
- data/lib/axlsx/workbook/worksheet/row_breaks.rb +1 -1
- data/lib/axlsx/workbook/worksheet/selection.rb +8 -2
- data/lib/axlsx/workbook/worksheet/sheet_pr.rb +1 -1
- data/lib/axlsx/workbook/worksheet/sheet_protection.rb +1 -1
- data/lib/axlsx/workbook/worksheet/sheet_view.rb +30 -9
- data/lib/axlsx/workbook/worksheet/table_style_info.rb +2 -2
- data/lib/axlsx/workbook/worksheet/tables.rb +1 -1
- data/lib/axlsx/workbook/worksheet/worksheet.rb +28 -14
- data/lib/axlsx/workbook/worksheet/worksheet_comments.rb +3 -3
- data/lib/axlsx/workbook/worksheet/worksheet_hyperlink.rb +2 -2
- data/lib/axlsx/workbook/worksheet/worksheet_hyperlinks.rb +2 -2
- data/lib/axlsx.rb +44 -30
- data/lib/caxlsx.rb +1 -1
- metadata +10 -48
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
module Axlsx
|
|
4
|
-
# The Pie3DChart is a three
|
|
4
|
+
# The Pie3DChart is a three dimensional pie chart (who would have guessed?) that you can add to your worksheet.
|
|
5
5
|
# @see Worksheet#add_chart
|
|
6
6
|
# @see Chart#add_series
|
|
7
7
|
# @see README for an example
|
|
@@ -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) }
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Axlsx
|
|
4
|
+
# The PieChart is a pie chart that you can add to your worksheet.
|
|
5
|
+
# @see Worksheet#add_chart
|
|
6
|
+
# @see Chart#add_series
|
|
7
|
+
# @see README for an example
|
|
8
|
+
class PieChart < Chart
|
|
9
|
+
# Creates a new pie chart object
|
|
10
|
+
# @param [GraphicFrame] frame The workbook that owns this chart.
|
|
11
|
+
# @option options [Cell, String] title
|
|
12
|
+
# @option options [Boolean] show_legend
|
|
13
|
+
# @option options [Symbol] grouping
|
|
14
|
+
# @option options [String] gap_depth
|
|
15
|
+
# @see Chart
|
|
16
|
+
def initialize(frame, options = {})
|
|
17
|
+
@vary_colors = true
|
|
18
|
+
super
|
|
19
|
+
@series_type = PieSeries
|
|
20
|
+
@d_lbls = nil
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
# Serializes the object
|
|
24
|
+
# @param [String] str
|
|
25
|
+
# @return [String]
|
|
26
|
+
def to_xml_string(str = +'')
|
|
27
|
+
super do
|
|
28
|
+
str << '<c:pieChart>'
|
|
29
|
+
str << '<c:varyColors val="' << vary_colors.to_s << '"/>'
|
|
30
|
+
@series.each { |ser| ser.to_xml_string(str) }
|
|
31
|
+
d_lbls.to_xml_string(str) if @d_lbls
|
|
32
|
+
str << '</c:pieChart>'
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
@@ -30,22 +30,28 @@ 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
|
|
37
37
|
|
|
38
38
|
# @see colors
|
|
39
|
-
def colors=(v)
|
|
39
|
+
def colors=(v)
|
|
40
|
+
DataTypeValidator.validate "BarSeries.colors", [Array], v
|
|
41
|
+
@colors = v
|
|
42
|
+
end
|
|
40
43
|
|
|
41
44
|
# @see explosion
|
|
42
|
-
def explosion=(v)
|
|
45
|
+
def explosion=(v)
|
|
46
|
+
Axlsx.validate_unsigned_int(v)
|
|
47
|
+
@explosion = v
|
|
48
|
+
end
|
|
43
49
|
|
|
44
50
|
# Serializes the object
|
|
45
51
|
# @param [String] str
|
|
46
52
|
# @return [String]
|
|
47
53
|
def to_xml_string(str = +'')
|
|
48
|
-
super
|
|
54
|
+
super do
|
|
49
55
|
str << '<c:explosion val="' << @explosion.to_s << '"/>' unless @explosion.nil?
|
|
50
56
|
colors.each_with_index do |c, index|
|
|
51
57
|
str << '<c:dPt>'
|
|
@@ -63,9 +69,15 @@ module Axlsx
|
|
|
63
69
|
private
|
|
64
70
|
|
|
65
71
|
# assigns the data for this series
|
|
66
|
-
def data=(v)
|
|
72
|
+
def data=(v)
|
|
73
|
+
DataTypeValidator.validate "Series.data", [NumDataSource], v
|
|
74
|
+
@data = v
|
|
75
|
+
end
|
|
67
76
|
|
|
68
77
|
# assigns the labels for this series
|
|
69
|
-
def labels=(v)
|
|
78
|
+
def labels=(v)
|
|
79
|
+
DataTypeValidator.validate "Series.labels", [AxDataSource], v
|
|
80
|
+
@labels = v
|
|
81
|
+
end
|
|
70
82
|
end
|
|
71
83
|
end
|
|
@@ -35,14 +35,28 @@ module Axlsx
|
|
|
35
35
|
attr_reader :min
|
|
36
36
|
|
|
37
37
|
# @see logBase
|
|
38
|
-
def logBase=(v)
|
|
38
|
+
def logBase=(v)
|
|
39
|
+
DataTypeValidator.validate "Scaling.logBase", [Integer], v, ->(arg) { arg >= 2 && arg <= 1000 }
|
|
40
|
+
@logBase = v
|
|
41
|
+
end
|
|
42
|
+
|
|
39
43
|
# @see orientation
|
|
40
|
-
def orientation=(v)
|
|
44
|
+
def orientation=(v)
|
|
45
|
+
RestrictionValidator.validate "Scaling.orientation", [:minMax, :maxMin], v
|
|
46
|
+
@orientation = v
|
|
47
|
+
end
|
|
48
|
+
|
|
41
49
|
# @see max
|
|
42
|
-
def max=(v)
|
|
50
|
+
def max=(v)
|
|
51
|
+
DataTypeValidator.validate "Scaling.max", Float, v
|
|
52
|
+
@max = v
|
|
53
|
+
end
|
|
43
54
|
|
|
44
55
|
# @see min
|
|
45
|
-
def min=(v)
|
|
56
|
+
def min=(v)
|
|
57
|
+
DataTypeValidator.validate "Scaling.min", Float, v
|
|
58
|
+
@min = v
|
|
59
|
+
end
|
|
46
60
|
|
|
47
61
|
# Serializes the object
|
|
48
62
|
# @param [String] str
|
|
@@ -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,15 +18,21 @@ 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
|
|
25
|
-
def tick_lbl_skip=(v)
|
|
25
|
+
def tick_lbl_skip=(v)
|
|
26
|
+
Axlsx.validate_unsigned_int(v)
|
|
27
|
+
@tick_lbl_skip = v
|
|
28
|
+
end
|
|
26
29
|
alias :tickLblSkip= :tick_lbl_skip=
|
|
27
30
|
|
|
28
31
|
# @see tickMarkSkip
|
|
29
|
-
def tick_mark_skip=(v)
|
|
32
|
+
def tick_mark_skip=(v)
|
|
33
|
+
Axlsx.validate_unsigned_int(v)
|
|
34
|
+
@tick_mark_skip = v
|
|
35
|
+
end
|
|
30
36
|
alias :tickMarkSkip= :tick_mark_skip=
|
|
31
37
|
|
|
32
38
|
# Serializes the object
|
|
@@ -34,7 +40,7 @@ module Axlsx
|
|
|
34
40
|
# @return [String]
|
|
35
41
|
def to_xml_string(str = +'')
|
|
36
42
|
str << '<c:serAx>'
|
|
37
|
-
super
|
|
43
|
+
super
|
|
38
44
|
str << '<c:tickLblSkip val="' << @tick_lbl_skip.to_s << '"/>' unless @tick_lbl_skip.nil?
|
|
39
45
|
str << '<c:tickMarkSkip val="' << @tick_mark_skip.to_s << '"/>' unless @tick_mark_skip.nil?
|
|
40
46
|
str << '</c:serAx>'
|
data/lib/axlsx/drawing/series.rb
CHANGED
|
@@ -40,7 +40,10 @@ module Axlsx
|
|
|
40
40
|
end
|
|
41
41
|
|
|
42
42
|
# @see order
|
|
43
|
-
def order=(v)
|
|
43
|
+
def order=(v)
|
|
44
|
+
Axlsx.validate_unsigned_int(v)
|
|
45
|
+
@order = v
|
|
46
|
+
end
|
|
44
47
|
|
|
45
48
|
# @see title
|
|
46
49
|
def title=(v)
|
|
@@ -52,7 +55,10 @@ module Axlsx
|
|
|
52
55
|
private
|
|
53
56
|
|
|
54
57
|
# assigns the chart for this series
|
|
55
|
-
def chart=(v)
|
|
58
|
+
def chart=(v)
|
|
59
|
+
DataTypeValidator.validate "Series.chart", Chart, v
|
|
60
|
+
@chart = v
|
|
61
|
+
end
|
|
56
62
|
|
|
57
63
|
# Serializes the object
|
|
58
64
|
# @param [String] str
|
|
@@ -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
|
|
@@ -78,11 +78,17 @@ module Axlsx
|
|
|
78
78
|
alias :rotY= :rot_y=
|
|
79
79
|
|
|
80
80
|
# @see depth_percent
|
|
81
|
-
def depth_percent=(v)
|
|
81
|
+
def depth_percent=(v)
|
|
82
|
+
RegexValidator.validate "#{self.class}.depth_percent", DEPTH_PERCENT_REGEX, v
|
|
83
|
+
@depth_percent = v
|
|
84
|
+
end
|
|
82
85
|
alias :depthPercent= :depth_percent=
|
|
83
86
|
|
|
84
87
|
# @see r_ang_ax
|
|
85
|
-
def r_ang_ax=(v)
|
|
88
|
+
def r_ang_ax=(v)
|
|
89
|
+
Axlsx.validate_boolean(v)
|
|
90
|
+
@r_ang_ax = v
|
|
91
|
+
end
|
|
86
92
|
alias :rAngAx= :r_ang_ax=
|
|
87
93
|
|
|
88
94
|
# @see perspective
|
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
|
|
@@ -69,7 +69,10 @@ module Axlsx
|
|
|
69
69
|
end
|
|
70
70
|
|
|
71
71
|
# @see workbook
|
|
72
|
-
def workbook=(workbook)
|
|
72
|
+
def workbook=(workbook)
|
|
73
|
+
DataTypeValidator.validate :Package_workbook, Workbook, workbook
|
|
74
|
+
@workbook = workbook
|
|
75
|
+
end
|
|
73
76
|
|
|
74
77
|
# Serialize your workbook to disk as an xlsx document.
|
|
75
78
|
#
|
|
@@ -204,7 +207,7 @@ module Axlsx
|
|
|
204
207
|
# Note: {Core#created} also defaults to the current time – so to generate identical axlsx packages you have
|
|
205
208
|
# to set this explicitly, too (eg. with `Package.new(created_at: Time.local(2013, 1, 1))`).
|
|
206
209
|
#
|
|
207
|
-
# @param part A hash describing a part of this
|
|
210
|
+
# @param part A hash describing a part of this package (see {#parts})
|
|
208
211
|
# @return [Zip::Entry]
|
|
209
212
|
def zip_entry_for_part(part)
|
|
210
213
|
timestamp = Zip::DOSTime.at(@core.created.to_i)
|
|
@@ -270,7 +273,7 @@ module Axlsx
|
|
|
270
273
|
]
|
|
271
274
|
end
|
|
272
275
|
|
|
273
|
-
# Performs xsd validation for a
|
|
276
|
+
# Performs xsd validation for a single document
|
|
274
277
|
#
|
|
275
278
|
# @param [String] schema path to the xsd schema to be used in validation.
|
|
276
279
|
# @param [String] doc The xml text to be validated
|
|
@@ -279,11 +282,8 @@ module Axlsx
|
|
|
279
282
|
def validate_single_doc(schema, doc)
|
|
280
283
|
schema = Nokogiri::XML::Schema(File.open(schema))
|
|
281
284
|
doc = Nokogiri::XML(doc)
|
|
282
|
-
|
|
283
|
-
schema.validate(doc)
|
|
284
|
-
errors << error
|
|
285
|
-
end
|
|
286
|
-
errors
|
|
285
|
+
|
|
286
|
+
schema.validate(doc)
|
|
287
287
|
end
|
|
288
288
|
|
|
289
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] = {}
|
|
@@ -92,12 +92,22 @@ module Axlsx
|
|
|
92
92
|
end
|
|
93
93
|
|
|
94
94
|
# @see Target
|
|
95
|
-
def Target=(v)
|
|
95
|
+
def Target=(v)
|
|
96
|
+
Axlsx.validate_string v
|
|
97
|
+
@Target = v
|
|
98
|
+
end
|
|
99
|
+
|
|
96
100
|
# @see Type
|
|
97
|
-
def Type=(v)
|
|
101
|
+
def Type=(v)
|
|
102
|
+
Axlsx.validate_relationship_type v
|
|
103
|
+
@Type = v
|
|
104
|
+
end
|
|
98
105
|
|
|
99
106
|
# @see TargetMode
|
|
100
|
-
def TargetMode=(v)
|
|
107
|
+
def TargetMode=(v)
|
|
108
|
+
RestrictionValidator.validate 'Relationship.TargetMode', [:External, :Internal], v
|
|
109
|
+
@TargetMode = v
|
|
110
|
+
end
|
|
101
111
|
|
|
102
112
|
# serialize relationship
|
|
103
113
|
# @param [String] str
|
|
@@ -106,7 +116,7 @@ module Axlsx
|
|
|
106
116
|
h = Axlsx.instance_values_for(self).reject { |k, _| k == "source_obj" }
|
|
107
117
|
str << '<Relationship '
|
|
108
118
|
h.each_with_index do |key_value, index|
|
|
109
|
-
str << ' ' unless index
|
|
119
|
+
str << ' ' unless index == 0
|
|
110
120
|
str << key_value.first.to_s << '="' << Axlsx.coder.encode(key_value.last.to_s) << '"'
|
|
111
121
|
end
|
|
112
122
|
str << '/>'
|
|
@@ -1,14 +1,14 @@
|
|
|
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
|
|
11
|
-
super
|
|
11
|
+
super(Relationship)
|
|
12
12
|
end
|
|
13
13
|
|
|
14
14
|
# The relationship instance for the given source object, or nil if none exists.
|
|
@@ -43,15 +43,24 @@ module Axlsx
|
|
|
43
43
|
attr_reader :prs
|
|
44
44
|
|
|
45
45
|
# @see diagonalUp
|
|
46
|
-
def diagonal_up=(v)
|
|
46
|
+
def diagonal_up=(v)
|
|
47
|
+
Axlsx.validate_boolean v
|
|
48
|
+
@diagonal_up = v
|
|
49
|
+
end
|
|
47
50
|
alias :diagonalUp= :diagonal_up=
|
|
48
51
|
|
|
49
52
|
# @see diagonalDown
|
|
50
|
-
def diagonal_down=(v)
|
|
53
|
+
def diagonal_down=(v)
|
|
54
|
+
Axlsx.validate_boolean v
|
|
55
|
+
@diagonal_down = v
|
|
56
|
+
end
|
|
51
57
|
alias :diagonalDown= :diagonal_down=
|
|
52
58
|
|
|
53
59
|
# @see outline
|
|
54
|
-
def outline=(v)
|
|
60
|
+
def outline=(v)
|
|
61
|
+
Axlsx.validate_boolean v
|
|
62
|
+
@outline = v
|
|
63
|
+
end
|
|
55
64
|
|
|
56
65
|
# Serializes the object
|
|
57
66
|
# @param [String] str
|
|
@@ -7,7 +7,7 @@ module Axlsx
|
|
|
7
7
|
# @return [Color] The color of this border part.
|
|
8
8
|
attr_reader :color
|
|
9
9
|
|
|
10
|
-
# @return [Symbol] The
|
|
10
|
+
# @return [Symbol] The style of this border part.
|
|
11
11
|
# @note
|
|
12
12
|
# The following are allowed
|
|
13
13
|
# :none
|
|
@@ -53,11 +53,22 @@ module Axlsx
|
|
|
53
53
|
end
|
|
54
54
|
|
|
55
55
|
# @see name
|
|
56
|
-
def name=(v)
|
|
56
|
+
def name=(v)
|
|
57
|
+
RestrictionValidator.validate "BorderPr.name", [:start, :end, :left, :right, :top, :bottom, :diagonal, :vertical, :horizontal], v
|
|
58
|
+
@name = v
|
|
59
|
+
end
|
|
60
|
+
|
|
57
61
|
# @see color
|
|
58
|
-
def color=(v)
|
|
62
|
+
def color=(v)
|
|
63
|
+
DataTypeValidator.validate(:color, Color, v)
|
|
64
|
+
@color = v
|
|
65
|
+
end
|
|
66
|
+
|
|
59
67
|
# @see style
|
|
60
|
-
def style=(v)
|
|
68
|
+
def style=(v)
|
|
69
|
+
RestrictionValidator.validate "BorderPr.style", [:none, :thin, :medium, :dashed, :dotted, :thick, :double, :hair, :mediumDashed, :dashDot, :mediumDashDot, :dashDotDot, :mediumDashDotDot, :slantDashDot], v
|
|
70
|
+
@style = v
|
|
71
|
+
end
|
|
61
72
|
|
|
62
73
|
# Serializes the object
|
|
63
74
|
# @param [String] str
|
|
@@ -25,7 +25,7 @@ module Axlsx
|
|
|
25
25
|
|
|
26
26
|
# The horizontal alignment of the cell.
|
|
27
27
|
# @note
|
|
28
|
-
# The horizontal cell
|
|
28
|
+
# The horizontal cell alignment style must be one of
|
|
29
29
|
# :general
|
|
30
30
|
# :left
|
|
31
31
|
# :center
|
|
@@ -86,34 +86,63 @@ module Axlsx
|
|
|
86
86
|
alias :readingOrder :reading_order
|
|
87
87
|
|
|
88
88
|
# @see horizontal
|
|
89
|
-
def horizontal=(v)
|
|
89
|
+
def horizontal=(v)
|
|
90
|
+
Axlsx.validate_horizontal_alignment v
|
|
91
|
+
@horizontal = v
|
|
92
|
+
end
|
|
93
|
+
|
|
90
94
|
# @see vertical
|
|
91
|
-
def vertical=(v)
|
|
95
|
+
def vertical=(v)
|
|
96
|
+
Axlsx.validate_vertical_alignment v
|
|
97
|
+
@vertical = v
|
|
98
|
+
end
|
|
99
|
+
|
|
92
100
|
# @see textRotation
|
|
93
|
-
def text_rotation=(v)
|
|
101
|
+
def text_rotation=(v)
|
|
102
|
+
Axlsx.validate_unsigned_int v
|
|
103
|
+
@text_rotation = v
|
|
104
|
+
end
|
|
94
105
|
alias :textRotation= :text_rotation=
|
|
95
106
|
|
|
96
107
|
# @see wrapText
|
|
97
|
-
def wrap_text=(v)
|
|
108
|
+
def wrap_text=(v)
|
|
109
|
+
Axlsx.validate_boolean v
|
|
110
|
+
@wrap_text = v
|
|
111
|
+
end
|
|
98
112
|
alias :wrapText= :wrap_text=
|
|
99
113
|
|
|
100
114
|
# @see indent
|
|
101
|
-
def indent=(v)
|
|
115
|
+
def indent=(v)
|
|
116
|
+
Axlsx.validate_unsigned_int v
|
|
117
|
+
@indent = v
|
|
118
|
+
end
|
|
102
119
|
|
|
103
120
|
# @see relativeIndent
|
|
104
|
-
def relative_indent=(v)
|
|
121
|
+
def relative_indent=(v)
|
|
122
|
+
Axlsx.validate_int v
|
|
123
|
+
@relative_indent = v
|
|
124
|
+
end
|
|
105
125
|
alias :relativeIndent= :relative_indent=
|
|
106
126
|
|
|
107
127
|
# @see justifyLastLine
|
|
108
|
-
def justify_last_line=(v)
|
|
128
|
+
def justify_last_line=(v)
|
|
129
|
+
Axlsx.validate_boolean v
|
|
130
|
+
@justify_last_line = v
|
|
131
|
+
end
|
|
109
132
|
alias :justifyLastLine= :justify_last_line=
|
|
110
133
|
|
|
111
134
|
# @see shrinkToFit
|
|
112
|
-
def shrink_to_fit=(v)
|
|
135
|
+
def shrink_to_fit=(v)
|
|
136
|
+
Axlsx.validate_boolean v
|
|
137
|
+
@shrink_to_fit = v
|
|
138
|
+
end
|
|
113
139
|
alias :shrinkToFit= :shrink_to_fit=
|
|
114
140
|
|
|
115
141
|
# @see readingOrder
|
|
116
|
-
def reading_order=(v)
|
|
142
|
+
def reading_order=(v)
|
|
143
|
+
Axlsx.validate_unsigned_int v
|
|
144
|
+
@reading_order = v
|
|
145
|
+
end
|
|
117
146
|
alias :readingOrder= :reading_order=
|
|
118
147
|
|
|
119
148
|
# Serializes the object
|
|
@@ -26,9 +26,16 @@ module Axlsx
|
|
|
26
26
|
end
|
|
27
27
|
|
|
28
28
|
# @see hidden
|
|
29
|
-
def hidden=(v)
|
|
29
|
+
def hidden=(v)
|
|
30
|
+
Axlsx.validate_boolean v
|
|
31
|
+
@hidden = v
|
|
32
|
+
end
|
|
33
|
+
|
|
30
34
|
# @see locked
|
|
31
|
-
def locked=(v)
|
|
35
|
+
def locked=(v)
|
|
36
|
+
Axlsx.validate_boolean v
|
|
37
|
+
@locked = v
|
|
38
|
+
end
|
|
32
39
|
|
|
33
40
|
# Serializes the object
|
|
34
41
|
# @param [String] str
|
|
@@ -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
|
|
@@ -48,17 +48,40 @@ module Axlsx
|
|
|
48
48
|
attr_reader :customBuiltin
|
|
49
49
|
|
|
50
50
|
# @see name
|
|
51
|
-
def name=(v)
|
|
51
|
+
def name=(v)
|
|
52
|
+
Axlsx.validate_string v
|
|
53
|
+
@name = v
|
|
54
|
+
end
|
|
55
|
+
|
|
52
56
|
# @see xfId
|
|
53
|
-
def xfId=(v)
|
|
57
|
+
def xfId=(v)
|
|
58
|
+
Axlsx.validate_unsigned_int v
|
|
59
|
+
@xfId = v
|
|
60
|
+
end
|
|
61
|
+
|
|
54
62
|
# @see builtinId
|
|
55
|
-
def builtinId=(v)
|
|
63
|
+
def builtinId=(v)
|
|
64
|
+
Axlsx.validate_unsigned_int v
|
|
65
|
+
@builtinId = v
|
|
66
|
+
end
|
|
67
|
+
|
|
56
68
|
# @see iLivel
|
|
57
|
-
def iLevel=(v)
|
|
69
|
+
def iLevel=(v)
|
|
70
|
+
Axlsx.validate_unsigned_int v
|
|
71
|
+
@iLevel = v
|
|
72
|
+
end
|
|
73
|
+
|
|
58
74
|
# @see hidden
|
|
59
|
-
def hidden=(v)
|
|
75
|
+
def hidden=(v)
|
|
76
|
+
Axlsx.validate_boolean v
|
|
77
|
+
@hidden = v
|
|
78
|
+
end
|
|
79
|
+
|
|
60
80
|
# @see customBuiltin
|
|
61
|
-
def customBuiltin=(v)
|
|
81
|
+
def customBuiltin=(v)
|
|
82
|
+
Axlsx.validate_boolean v
|
|
83
|
+
@customBuiltin = v
|
|
84
|
+
end
|
|
62
85
|
|
|
63
86
|
# Serializes the object
|
|
64
87
|
# @param [String] str
|