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.
Files changed (80) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +5 -1
  3. data/Changes +3 -0
  4. data/README.md +1 -1
  5. data/examples/autofilter.rb +1 -1
  6. data/examples/chart_area.rb +12 -12
  7. data/examples/chart_bar.rb +12 -12
  8. data/examples/chart_clustered.rb +12 -12
  9. data/examples/chart_column.rb +12 -12
  10. data/examples/chart_combined.rb +25 -25
  11. data/examples/chart_data_labels.rb +99 -99
  12. data/examples/chart_data_table.rb +25 -25
  13. data/examples/chart_data_tools.rb +50 -50
  14. data/examples/chart_doughnut.rb +29 -29
  15. data/examples/chart_gauge.rb +18 -18
  16. data/examples/chart_line.rb +32 -32
  17. data/examples/chart_pareto.rb +16 -16
  18. data/examples/chart_pie.rb +17 -17
  19. data/examples/chart_radar.rb +38 -38
  20. data/examples/chart_scatter.rb +12 -12
  21. data/examples/chart_secondary_axis.rb +13 -13
  22. data/examples/chart_stock.rb +12 -12
  23. data/examples/chart_styles.rb +5 -5
  24. data/examples/colors.rb +11 -11
  25. data/examples/comments2.rb +15 -15
  26. data/examples/conditional_format.rb +74 -74
  27. data/examples/data_validate.rb +64 -64
  28. data/examples/date_time.rb +3 -3
  29. data/examples/demo.rb +14 -14
  30. data/examples/diag_border.rb +6 -6
  31. data/examples/dynamic_arrays.rb +2 -2
  32. data/examples/formats.rb +10 -10
  33. data/examples/hyperlink1.rb +4 -4
  34. data/examples/ignore_errors.rb +2 -2
  35. data/examples/indent.rb +2 -2
  36. data/examples/macros.rb +4 -4
  37. data/examples/merge1.rb +1 -1
  38. data/examples/merge2.rb +9 -9
  39. data/examples/merge3.rb +5 -5
  40. data/examples/merge4.rb +20 -20
  41. data/examples/merge5.rb +18 -18
  42. data/examples/merge6.rb +7 -7
  43. data/examples/outline.rb +1 -1
  44. data/examples/outline_collapsed.rb +1 -1
  45. data/examples/panes.rb +4 -4
  46. data/examples/properties.rb +9 -9
  47. data/examples/protection.rb +2 -2
  48. data/examples/rich_strings.rb +6 -6
  49. data/examples/shape1.rb +7 -7
  50. data/examples/shape2.rb +16 -16
  51. data/examples/shape3.rb +5 -5
  52. data/examples/shape4.rb +7 -7
  53. data/examples/shape5.rb +7 -7
  54. data/examples/shape6.rb +7 -7
  55. data/examples/shape7.rb +10 -10
  56. data/examples/shape8.rb +10 -10
  57. data/examples/shape_all.rb +4 -4
  58. data/examples/sparklines1.rb +11 -11
  59. data/examples/sparklines2.rb +76 -76
  60. data/examples/tables.rb +87 -87
  61. data/examples/watermark.rb +1 -1
  62. data/lib/write_xlsx/chart/bar.rb +4 -4
  63. data/lib/write_xlsx/chart/line.rb +1 -1
  64. data/lib/write_xlsx/chart/radar.rb +2 -2
  65. data/lib/write_xlsx/chart/scatter.rb +4 -4
  66. data/lib/write_xlsx/chart/series.rb +27 -27
  67. data/lib/write_xlsx/chart/stock.rb +5 -5
  68. data/lib/write_xlsx/chart.rb +30 -30
  69. data/lib/write_xlsx/colors.rb +19 -19
  70. data/lib/write_xlsx/package/conditional_format.rb +3 -3
  71. data/lib/write_xlsx/package/table.rb +8 -8
  72. data/lib/write_xlsx/shape.rb +5 -5
  73. data/lib/write_xlsx/sheets.rb +1 -1
  74. data/lib/write_xlsx/sparkline.rb +286 -286
  75. data/lib/write_xlsx/utility.rb +23 -23
  76. data/lib/write_xlsx/version.rb +1 -1
  77. data/lib/write_xlsx/workbook.rb +20 -20
  78. data/lib/write_xlsx/worksheet/cell_data.rb +1 -1
  79. data/lib/write_xlsx/worksheet.rb +28 -28
  80. metadata +2 -2
@@ -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
- { :image_center => File.join(dirname, 'watermark.png') }
23
+ { image_center: File.join(dirname, 'watermark.png') }
24
24
  )
25
25
 
26
26
  workbook.close
@@ -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] = { :visible => 1 }
89
+ @x_axis.defaults[:major_gridlines] = { visible: 1 }
90
90
  else
91
- @x_axis.defaults = { :major_gridlines => { :visible => 1 } }
91
+ @x_axis.defaults = { major_gridlines: { visible: 1 } }
92
92
  end
93
93
  if @y_axis.defaults
94
- @y_axis.defaults[:major_gridlines] = { :visible => 0 }
94
+ @y_axis.defaults[:major_gridlines] = { visible: 0 }
95
95
  else
96
- @y_axis.defaults = { :major_gridlines => { :visible => 0 } }
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
@@ -24,7 +24,7 @@ module Writexlsx
24
24
  def initialize(subtype)
25
25
  super(subtype)
26
26
  @subtype ||= 'standard'
27
- @default_marker = Marker.new(:type => 'none')
27
+ @default_marker = Marker.new(type: 'none')
28
28
  @smooth_allowed = 1
29
29
 
30
30
  # Override and reset the default axis values.
@@ -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(:type => 'none') if @subtype == 'marker'
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] = { :visible => 1 }
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(:primary_axes => 1)
127
- write_chart_type(:primary_axes => 0)
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(:width => 2.25, :none => 1, :_defined => 1) unless series.line_defined?
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(:type => 'none', :_defined => 1) unless ptrue?(series.marker)
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
- :exponential => 'exp',
81
- :linear => 'linear',
82
- :log => 'log',
83
- :moving_average => 'movingAvg',
84
- :polynomial => 'poly',
85
- :power => 'power'
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
- :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'
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
- :fixed => 'fixedVal',
159
- :percentage => 'percentage',
160
- :standard_deviation => 'stdDev',
161
- :standard_error => 'stdErr',
162
- :custom => 'cust'
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
- :_x_error_bars => x ? Errorbars.new(x) : nil,
265
- :_y_error_bars => y ? Errorbars.new(y) : nil
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
- :width => 2.25,
108
- :none => 1,
109
- :_defined => 1
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(:type => 'dot', :size => 3)
115
+ Marker.new(type: 'dot', size: 3)
116
116
  else
117
- Marker.new(:type => 'none')
117
+ Marker.new(type: 'none')
118
118
  end
119
119
  end
120
120
  end
@@ -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] ? { :color => params[:color] } : params[:fill]
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 = { :width => swe_line_weight(line_weight) } if line_weight
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 = { :none => 1 }
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
- :_up => Chartline.new(params[:up]),
436
- :_down => Chartline.new(params[:down])
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
- :num_format => 'General',
699
- :major_gridlines => { :visible => 0 }
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
- :num_format => 'General',
706
- :major_gridlines => { :visible => 1 }
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
- :num_format => 'General',
713
- :label_position => 'none',
714
- :crossing => 'max',
715
- :visible => 0
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
- :num_format => 'General',
722
- :major_gridlines => { :visible => 0 },
723
- :position => 'right',
724
- :visible => 1
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(:primary_axes => 1)
807
- write_chart_type(:primary_axes => 0)
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(:primary_axes => 1)
827
- second_chart.write_chart_type(:primary_axes => 0)
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
- :x_axis => @x_axis,
833
- :y_axis => @y_axis,
834
- :axis_ids => @axis_ids
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
- :x_axis => @x2_axis,
848
- :y_axis => @y2_axis,
849
- :axis_ids => @axis2_ids
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
- :x_axis => second_chart.x2_axis,
859
- :y_axis => second_chart.y2_axis,
860
- :axis_ids => second_chart.axis2_ids
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(
@@ -4,25 +4,25 @@
4
4
  module Writexlsx
5
5
  class Colors
6
6
  COLORS = {
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
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
  ###############################################################################
@@ -658,9 +658,9 @@ module Writexlsx
658
658
  # Set the default icon properties.
659
659
  total_icons.times do
660
660
  props << {
661
- :criteria => 0,
662
- :value => 0,
663
- :type => 'percent'
661
+ criteria: 0,
662
+ value: 0,
663
+ type: 'percent'
664
664
  }
665
665
  end
666
666
 
@@ -248,14 +248,14 @@ module Writexlsx
248
248
  .gsub(/\]/, "']")
249
249
 
250
250
  subtotals = {
251
- :average => 101,
252
- :countNums => 102,
253
- :count => 103,
254
- :max => 104,
255
- :min => 105,
256
- :stdDev => 107,
257
- :sum => 109,
258
- :var => 110
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])
@@ -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
- :straightConnector => 1,
208
- :Connector => 1,
209
- :bentConnector => 1,
210
- :curvedConnector => 1,
211
- :line => 1
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.
@@ -8,7 +8,7 @@ module Writexlsx
8
8
  class Sheets < DelegateClass(Array)
9
9
  include Writexlsx::Utility
10
10
 
11
- BASE_NAME = { :sheet => 'Sheet', :chart => 'Chart' } # :nodoc:
11
+ BASE_NAME = { sheet: 'Sheet', chart: 'Chart' } # :nodoc:
12
12
 
13
13
  def initialize
14
14
  super([])