write_xlsx 1.10.0 → 1.10.1
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/.rubocop.yml +5 -1
- data/Changes +3 -0
- data/README.md +1 -1
- data/examples/autofilter.rb +1 -1
- data/examples/chart_area.rb +12 -12
- data/examples/chart_bar.rb +12 -12
- data/examples/chart_clustered.rb +12 -12
- data/examples/chart_column.rb +12 -12
- data/examples/chart_combined.rb +25 -25
- data/examples/chart_data_labels.rb +99 -99
- data/examples/chart_data_table.rb +25 -25
- data/examples/chart_data_tools.rb +50 -50
- data/examples/chart_doughnut.rb +29 -29
- data/examples/chart_gauge.rb +18 -18
- data/examples/chart_line.rb +32 -32
- data/examples/chart_pareto.rb +16 -16
- data/examples/chart_pie.rb +17 -17
- data/examples/chart_radar.rb +38 -38
- data/examples/chart_scatter.rb +12 -12
- data/examples/chart_secondary_axis.rb +13 -13
- data/examples/chart_stock.rb +12 -12
- data/examples/chart_styles.rb +5 -5
- data/examples/colors.rb +11 -11
- data/examples/comments2.rb +15 -15
- data/examples/conditional_format.rb +74 -74
- data/examples/data_validate.rb +64 -64
- data/examples/date_time.rb +3 -3
- data/examples/demo.rb +14 -14
- data/examples/diag_border.rb +6 -6
- data/examples/dynamic_arrays.rb +2 -2
- data/examples/formats.rb +10 -10
- data/examples/hyperlink1.rb +4 -4
- data/examples/ignore_errors.rb +2 -2
- data/examples/indent.rb +2 -2
- data/examples/macros.rb +4 -4
- data/examples/merge1.rb +1 -1
- data/examples/merge2.rb +9 -9
- data/examples/merge3.rb +5 -5
- data/examples/merge4.rb +20 -20
- data/examples/merge5.rb +18 -18
- data/examples/merge6.rb +7 -7
- data/examples/outline.rb +1 -1
- data/examples/outline_collapsed.rb +1 -1
- data/examples/panes.rb +4 -4
- data/examples/properties.rb +9 -9
- data/examples/protection.rb +2 -2
- data/examples/rich_strings.rb +6 -6
- data/examples/shape1.rb +7 -7
- data/examples/shape2.rb +16 -16
- data/examples/shape3.rb +5 -5
- data/examples/shape4.rb +7 -7
- data/examples/shape5.rb +7 -7
- data/examples/shape6.rb +7 -7
- data/examples/shape7.rb +10 -10
- data/examples/shape8.rb +10 -10
- data/examples/shape_all.rb +4 -4
- data/examples/sparklines1.rb +11 -11
- data/examples/sparklines2.rb +76 -76
- data/examples/tables.rb +87 -87
- data/examples/watermark.rb +1 -1
- data/lib/write_xlsx/chart/bar.rb +4 -4
- data/lib/write_xlsx/chart/line.rb +1 -1
- data/lib/write_xlsx/chart/radar.rb +2 -2
- data/lib/write_xlsx/chart/scatter.rb +4 -4
- data/lib/write_xlsx/chart/series.rb +27 -27
- data/lib/write_xlsx/chart/stock.rb +5 -5
- data/lib/write_xlsx/chart.rb +30 -30
- data/lib/write_xlsx/colors.rb +19 -19
- data/lib/write_xlsx/package/conditional_format.rb +3 -3
- data/lib/write_xlsx/package/table.rb +8 -8
- data/lib/write_xlsx/shape.rb +5 -5
- data/lib/write_xlsx/sheets.rb +1 -1
- data/lib/write_xlsx/sparkline.rb +286 -286
- data/lib/write_xlsx/utility.rb +23 -23
- data/lib/write_xlsx/version.rb +1 -1
- data/lib/write_xlsx/workbook.rb +20 -20
- data/lib/write_xlsx/worksheet/cell_data.rb +1 -1
- data/lib/write_xlsx/worksheet.rb +28 -28
- metadata +2 -2
data/examples/watermark.rb
CHANGED
@@ -20,7 +20,7 @@ worksheet = workbook.add_worksheet
|
|
20
20
|
dirname = File.dirname(File.expand_path(__FILE__))
|
21
21
|
worksheet.set_header(
|
22
22
|
'&C&C&[Picture]', nil,
|
23
|
-
{ :
|
23
|
+
{ image_center: File.join(dirname, 'watermark.png') }
|
24
24
|
)
|
25
25
|
|
26
26
|
workbook.close
|
data/lib/write_xlsx/chart/bar.rb
CHANGED
@@ -86,14 +86,14 @@ module Writexlsx
|
|
86
86
|
|
87
87
|
def axis_defaults_set
|
88
88
|
if @x_axis.defaults
|
89
|
-
@x_axis.defaults[:major_gridlines] = { :
|
89
|
+
@x_axis.defaults[:major_gridlines] = { visible: 1 }
|
90
90
|
else
|
91
|
-
@x_axis.defaults = { :
|
91
|
+
@x_axis.defaults = { major_gridlines: { visible: 1 } }
|
92
92
|
end
|
93
93
|
if @y_axis.defaults
|
94
|
-
@y_axis.defaults[:major_gridlines] = { :
|
94
|
+
@y_axis.defaults[:major_gridlines] = { visible: 0 }
|
95
95
|
else
|
96
|
-
@y_axis.defaults = { :
|
96
|
+
@y_axis.defaults = { major_gridlines: { visible: 0 } }
|
97
97
|
end
|
98
98
|
@x_axis.defaults[:num_format] = '0%' if @subtype == 'percent_stacked'
|
99
99
|
end
|
@@ -32,10 +32,10 @@ module Writexlsx
|
|
32
32
|
def initialize(subtype)
|
33
33
|
super(subtype)
|
34
34
|
@subtype = subtype || 'marker'
|
35
|
-
@default_marker = Marker.new(:
|
35
|
+
@default_marker = Marker.new(type: 'none') if @subtype == 'marker'
|
36
36
|
|
37
37
|
# Override and reset the default axis values.
|
38
|
-
@x_axis.defaults[:major_gridlines] = { :
|
38
|
+
@x_axis.defaults[:major_gridlines] = { visible: 1 }
|
39
39
|
set_x_axis
|
40
40
|
|
41
41
|
# Hardcode major_tick_mark for now untill there is an accessor.
|
@@ -123,8 +123,8 @@ module Writexlsx
|
|
123
123
|
write_layout(@plotarea.layout, 'plot')
|
124
124
|
|
125
125
|
# Write the subclass chart type elements for primary and secondary axes.
|
126
|
-
write_chart_type(:
|
127
|
-
write_chart_type(:
|
126
|
+
write_chart_type(primary_axes: 1)
|
127
|
+
write_chart_type(primary_axes: 0)
|
128
128
|
|
129
129
|
# Write c:catAx and c:valAx elements for series using primary axes.
|
130
130
|
write_cat_val_axis(@x_axis, @y_axis, @axis_ids, 'b')
|
@@ -201,7 +201,7 @@ module Writexlsx
|
|
201
201
|
# Go through each series and define default values.
|
202
202
|
@series.each do |series|
|
203
203
|
# Set a line type unless there is already a user defined type.
|
204
|
-
series.line = line_properties(:
|
204
|
+
series.line = line_properties(width: 2.25, none: 1, _defined: 1) unless series.line_defined?
|
205
205
|
end
|
206
206
|
end
|
207
207
|
|
@@ -210,7 +210,7 @@ module Writexlsx
|
|
210
210
|
# Go through each series and define default values.
|
211
211
|
@series.each do |series|
|
212
212
|
# Set a marker type unless there is already a user defined type.
|
213
|
-
series.marker = Marker.new(:
|
213
|
+
series.marker = Marker.new(type: 'none', _defined: 1) unless ptrue?(series.marker)
|
214
214
|
end
|
215
215
|
end
|
216
216
|
end
|
@@ -77,12 +77,12 @@ module Writexlsx
|
|
77
77
|
|
78
78
|
def types
|
79
79
|
{
|
80
|
-
:
|
81
|
-
:
|
82
|
-
:
|
83
|
-
:
|
84
|
-
:
|
85
|
-
:
|
80
|
+
exponential: 'exp',
|
81
|
+
linear: 'linear',
|
82
|
+
log: 'log',
|
83
|
+
moving_average: 'movingAvg',
|
84
|
+
polynomial: 'poly',
|
85
|
+
power: 'power'
|
86
86
|
}
|
87
87
|
end
|
88
88
|
end
|
@@ -108,20 +108,20 @@ module Writexlsx
|
|
108
108
|
|
109
109
|
def types
|
110
110
|
{
|
111
|
-
:
|
112
|
-
:
|
113
|
-
:
|
114
|
-
:
|
115
|
-
:
|
116
|
-
:
|
117
|
-
:
|
118
|
-
:
|
119
|
-
:
|
120
|
-
:
|
121
|
-
:
|
122
|
-
:
|
123
|
-
:
|
124
|
-
:
|
111
|
+
automatic: 'automatic',
|
112
|
+
none: 'none',
|
113
|
+
square: 'square',
|
114
|
+
diamond: 'diamond',
|
115
|
+
triangle: 'triangle',
|
116
|
+
x: 'x',
|
117
|
+
star: 'star',
|
118
|
+
dot: 'dot',
|
119
|
+
short_dash: 'dot',
|
120
|
+
dash: 'dash',
|
121
|
+
long_dash: 'dash',
|
122
|
+
circle: 'circle',
|
123
|
+
plus: 'plus',
|
124
|
+
picture: 'picture'
|
125
125
|
}
|
126
126
|
end
|
127
127
|
end
|
@@ -155,11 +155,11 @@ module Writexlsx
|
|
155
155
|
|
156
156
|
def types
|
157
157
|
{
|
158
|
-
:
|
159
|
-
:
|
160
|
-
:
|
161
|
-
:
|
162
|
-
:
|
158
|
+
fixed: 'fixedVal',
|
159
|
+
percentage: 'percentage',
|
160
|
+
standard_deviation: 'stdDev',
|
161
|
+
standard_error: 'stdErr',
|
162
|
+
custom: 'cust'
|
163
163
|
}
|
164
164
|
end
|
165
165
|
|
@@ -261,8 +261,8 @@ module Writexlsx
|
|
261
261
|
|
262
262
|
def errorbars(x, y)
|
263
263
|
{
|
264
|
-
:
|
265
|
-
:
|
264
|
+
_x_error_bars: x ? Errorbars.new(x) : nil,
|
265
|
+
_y_error_bars: y ? Errorbars.new(y) : nil
|
266
266
|
}
|
267
267
|
end
|
268
268
|
|
@@ -104,17 +104,17 @@ module Writexlsx
|
|
104
104
|
if index % 4 != 3
|
105
105
|
unless series.line_defined?
|
106
106
|
series.line = {
|
107
|
-
:
|
108
|
-
:
|
109
|
-
:
|
107
|
+
width: 2.25,
|
108
|
+
none: 1,
|
109
|
+
_defined: 1
|
110
110
|
}
|
111
111
|
end
|
112
112
|
|
113
113
|
unless ptrue?(series.marker)
|
114
114
|
series.marker = if index % 4 == 2
|
115
|
-
Marker.new(:
|
115
|
+
Marker.new(type: 'dot', size: 3)
|
116
116
|
else
|
117
|
-
Marker.new(:
|
117
|
+
Marker.new(type: 'none')
|
118
118
|
end
|
119
119
|
end
|
120
120
|
end
|
data/lib/write_xlsx/chart.rb
CHANGED
@@ -70,7 +70,7 @@ module Writexlsx
|
|
70
70
|
@gradient = gradient_properties(params[:gradient])
|
71
71
|
|
72
72
|
# Map deprecated Spreadsheet::WriteExcel fill colour.
|
73
|
-
fill = params[:color] ? { :
|
73
|
+
fill = params[:color] ? { color: params[:color] } : params[:fill]
|
74
74
|
@fill = fill_properties(fill)
|
75
75
|
|
76
76
|
# Pattern fill overrides solid fill.
|
@@ -90,13 +90,13 @@ module Writexlsx
|
|
90
90
|
|
91
91
|
# Map deprecated Spreadsheet::WriteExcel line_weight.
|
92
92
|
border = params[:border]
|
93
|
-
border = { :
|
93
|
+
border = { width: swe_line_weight(line_weight) } if line_weight
|
94
94
|
|
95
95
|
# Map deprecated Spreadsheet::WriteExcel line_pattern.
|
96
96
|
if params[:line_pattern]
|
97
97
|
pattern = swe_line_pattern(params[:line_pattern])
|
98
98
|
if pattern == 'none'
|
99
|
-
border = { :
|
99
|
+
border = { none: 1 }
|
100
100
|
else
|
101
101
|
border[:dash_type] = pattern
|
102
102
|
end
|
@@ -432,8 +432,8 @@ module Writexlsx
|
|
432
432
|
|
433
433
|
# Set the up and down bar properties.
|
434
434
|
@up_down_bars = {
|
435
|
-
:
|
436
|
-
:
|
435
|
+
_up: Chartline.new(params[:up]),
|
436
|
+
_down: Chartline.new(params[:down])
|
437
437
|
}
|
438
438
|
end
|
439
439
|
|
@@ -695,33 +695,33 @@ module Writexlsx
|
|
695
695
|
|
696
696
|
def x_axis_defaults
|
697
697
|
{
|
698
|
-
:
|
699
|
-
:
|
698
|
+
num_format: 'General',
|
699
|
+
major_gridlines: { visible: 0 }
|
700
700
|
}
|
701
701
|
end
|
702
702
|
|
703
703
|
def y_axis_defaults
|
704
704
|
{
|
705
|
-
:
|
706
|
-
:
|
705
|
+
num_format: 'General',
|
706
|
+
major_gridlines: { visible: 1 }
|
707
707
|
}
|
708
708
|
end
|
709
709
|
|
710
710
|
def x2_axis_defaults
|
711
711
|
{
|
712
|
-
:
|
713
|
-
:
|
714
|
-
:
|
715
|
-
:
|
712
|
+
num_format: 'General',
|
713
|
+
label_position: 'none',
|
714
|
+
crossing: 'max',
|
715
|
+
visible: 0
|
716
716
|
}
|
717
717
|
end
|
718
718
|
|
719
719
|
def y2_axis_defaults
|
720
720
|
{
|
721
|
-
:
|
722
|
-
:
|
723
|
-
:
|
724
|
-
:
|
721
|
+
num_format: 'General',
|
722
|
+
major_gridlines: { visible: 0 },
|
723
|
+
position: 'right',
|
724
|
+
visible: 1
|
725
725
|
}
|
726
726
|
end
|
727
727
|
|
@@ -803,8 +803,8 @@ module Writexlsx
|
|
803
803
|
# Write the c:layout element.
|
804
804
|
write_layout(@plotarea.layout, 'plot')
|
805
805
|
# Write the subclass chart type elements for primary and secondary axes.
|
806
|
-
write_chart_type(:
|
807
|
-
write_chart_type(:
|
806
|
+
write_chart_type(primary_axes: 1)
|
807
|
+
write_chart_type(primary_axes: 0)
|
808
808
|
|
809
809
|
# Configure a combined chart if present.
|
810
810
|
if second_chart
|
@@ -823,15 +823,15 @@ module Writexlsx
|
|
823
823
|
second_chart.series_index = @series_index
|
824
824
|
|
825
825
|
# Write the subclass chart type elements for combined chart.
|
826
|
-
second_chart.write_chart_type(:
|
827
|
-
second_chart.write_chart_type(:
|
826
|
+
second_chart.write_chart_type(primary_axes: 1)
|
827
|
+
second_chart.write_chart_type(primary_axes: 0)
|
828
828
|
end
|
829
829
|
|
830
830
|
# Write the category and value elements for the primary axes.
|
831
831
|
params = {
|
832
|
-
:
|
833
|
-
:
|
834
|
-
:
|
832
|
+
x_axis: @x_axis,
|
833
|
+
y_axis: @y_axis,
|
834
|
+
axis_ids: @axis_ids
|
835
835
|
}
|
836
836
|
|
837
837
|
if @date_category
|
@@ -844,9 +844,9 @@ module Writexlsx
|
|
844
844
|
|
845
845
|
# Write the category and value elements for the secondary axes.
|
846
846
|
params = {
|
847
|
-
:
|
848
|
-
:
|
849
|
-
:
|
847
|
+
x_axis: @x2_axis,
|
848
|
+
y_axis: @y2_axis,
|
849
|
+
axis_ids: @axis2_ids
|
850
850
|
}
|
851
851
|
|
852
852
|
write_val_axis(@x2_axis, @y2_axis, @axis2_ids)
|
@@ -855,9 +855,9 @@ module Writexlsx
|
|
855
855
|
if second_chart && second_chart.is_secondary?
|
856
856
|
|
857
857
|
params = {
|
858
|
-
:
|
859
|
-
:
|
860
|
-
:
|
858
|
+
x_axis: second_chart.x2_axis,
|
859
|
+
y_axis: second_chart.y2_axis,
|
860
|
+
axis_ids: second_chart.axis2_ids
|
861
861
|
}
|
862
862
|
|
863
863
|
second_chart.write_val_axis(
|
data/lib/write_xlsx/colors.rb
CHANGED
@@ -4,25 +4,25 @@
|
|
4
4
|
module Writexlsx
|
5
5
|
class Colors
|
6
6
|
COLORS = {
|
7
|
-
:
|
8
|
-
:
|
9
|
-
:
|
10
|
-
:
|
11
|
-
:
|
12
|
-
:
|
13
|
-
:
|
14
|
-
:
|
15
|
-
:
|
16
|
-
:
|
17
|
-
:
|
18
|
-
:
|
19
|
-
:
|
20
|
-
:
|
21
|
-
:
|
22
|
-
:
|
23
|
-
:
|
24
|
-
:
|
25
|
-
:
|
7
|
+
aqua: 0x0F,
|
8
|
+
cyan: 0x0F,
|
9
|
+
black: 0x08,
|
10
|
+
blue: 0x0C,
|
11
|
+
brown: 0x10,
|
12
|
+
magenta: 0x0E,
|
13
|
+
fuchsia: 0x0E,
|
14
|
+
gray: 0x17,
|
15
|
+
grey: 0x17,
|
16
|
+
green: 0x11,
|
17
|
+
lime: 0x0B,
|
18
|
+
navy: 0x12,
|
19
|
+
orange: 0x35,
|
20
|
+
pink: 0x21,
|
21
|
+
purple: 0x14,
|
22
|
+
red: 0x0A,
|
23
|
+
silver: 0x16,
|
24
|
+
white: 0x09,
|
25
|
+
yellow: 0x0D
|
26
26
|
} # :nodoc:
|
27
27
|
|
28
28
|
###############################################################################
|
@@ -248,14 +248,14 @@ module Writexlsx
|
|
248
248
|
.gsub(/\]/, "']")
|
249
249
|
|
250
250
|
subtotals = {
|
251
|
-
:
|
252
|
-
:
|
253
|
-
:
|
254
|
-
:
|
255
|
-
:
|
256
|
-
:
|
257
|
-
:
|
258
|
-
:
|
251
|
+
average: 101,
|
252
|
+
countNums: 102,
|
253
|
+
count: 103,
|
254
|
+
max: 104,
|
255
|
+
min: 105,
|
256
|
+
stdDev: 107,
|
257
|
+
sum: 109,
|
258
|
+
var: 110
|
259
259
|
}
|
260
260
|
|
261
261
|
unless (func_num = subtotals[function.to_sym])
|
data/lib/write_xlsx/shape.rb
CHANGED
@@ -204,11 +204,11 @@ module Writexlsx
|
|
204
204
|
def auto_locate_connectors(shapes, shape_hash)
|
205
205
|
# Valid connector shapes.
|
206
206
|
connector_shapes = {
|
207
|
-
:
|
208
|
-
:
|
209
|
-
:
|
210
|
-
:
|
211
|
-
:
|
207
|
+
straightConnector: 1,
|
208
|
+
Connector: 1,
|
209
|
+
bentConnector: 1,
|
210
|
+
curvedConnector: 1,
|
211
|
+
line: 1
|
212
212
|
}
|
213
213
|
|
214
214
|
shape_base = @type.chop.to_sym # Remove the number of segments from end of type.
|
data/lib/write_xlsx/sheets.rb
CHANGED