write_xlsx 1.10.0 → 1.10.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.
Files changed (81) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +10 -0
  3. data/Changes +9 -0
  4. data/README.md +2 -2
  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 +18 -7
  71. data/lib/write_xlsx/package/table.rb +33 -24
  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 +32 -31
  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/data_validation.rb +13 -1
  80. data/lib/write_xlsx/worksheet.rb +486 -246
  81. metadata +3 -3
@@ -53,7 +53,12 @@ module Writexlsx
53
53
 
54
54
  def xl_col_to_name(col, col_absolute)
55
55
  col_str = ColName.instance.col_str(col)
56
- "#{absolute_char(col_absolute)}#{col_str}"
56
+ if col_absolute
57
+ "#{absolute_char(col_absolute)}#{col_str}"
58
+ else
59
+ # Do not allocate new string
60
+ col_str
61
+ end
57
62
  end
58
63
 
59
64
  def xl_range(row_1, row_2, col_1, col_2,
@@ -252,12 +257,8 @@ module Writexlsx
252
257
  end
253
258
 
254
259
  # Check for a cell reference in A1 notation and substitute row and column
255
- def row_col_notation(args) # :nodoc:
256
- if args[0].to_s =~ /^\D/
257
- substitute_cellref(*args)
258
- else
259
- args
260
- end
260
+ def row_col_notation(row_or_a1) # :nodoc:
261
+ substitute_cellref(row_or_a1) if row_or_a1.to_s =~ /^\D/
261
262
  end
262
263
 
263
264
  #
@@ -267,7 +268,7 @@ module Writexlsx
267
268
  # Ex: ("A4", "Hello") is converted to (3, 0, "Hello").
268
269
  #
269
270
  def substitute_cellref(cell, *args) # :nodoc:
270
- return [*args] if cell.respond_to?(:coerce) # Numeric
271
+ # return [*args] if cell.respond_to?(:coerce) # Numeric
271
272
 
272
273
  normalized_cell = cell.upcase
273
274
 
@@ -683,7 +684,7 @@ module Writexlsx
683
684
  end
684
685
 
685
686
  def line_fill_properties(params)
686
- return { :_defined => 0 } unless params
687
+ return { _defined: 0 } unless params
687
688
 
688
689
  ret = params.dup
689
690
  ret[:dash_type] = yield if block_given? && ret[:dash_type]
@@ -693,17 +694,17 @@ module Writexlsx
693
694
 
694
695
  def dash_types
695
696
  {
696
- :solid => 'solid',
697
- :round_dot => 'sysDot',
698
- :square_dot => 'sysDash',
699
- :dash => 'dash',
700
- :dash_dot => 'dashDot',
701
- :long_dash => 'lgDash',
702
- :long_dash_dot => 'lgDashDot',
703
- :long_dash_dot_dot => 'lgDashDotDot',
704
- :dot => 'dot',
705
- :system_dash_dot => 'sysDashDot',
706
- :system_dash_dot_dot => 'sysDashDotDot'
697
+ solid: 'solid',
698
+ round_dot: 'sysDot',
699
+ square_dot: 'sysDash',
700
+ dash: 'dash',
701
+ dash_dot: 'dashDot',
702
+ long_dash: 'lgDash',
703
+ long_dash_dot: 'lgDashDot',
704
+ long_dash_dot_dot: 'lgDashDotDot',
705
+ dot: 'dot',
706
+ system_dash_dot: 'sysDashDot',
707
+ system_dash_dot_dot: 'sysDashDotDot'
707
708
  }
708
709
  end
709
710
 
@@ -766,16 +767,16 @@ module Writexlsx
766
767
 
767
768
  def params_to_font(params)
768
769
  {
769
- :_name => params[:name],
770
- :_color => params[:color],
771
- :_size => params[:size],
772
- :_bold => params[:bold],
773
- :_italic => params[:italic],
774
- :_underline => params[:underline],
775
- :_pitch_family => params[:pitch_family],
776
- :_charset => params[:charset],
777
- :_baseline => params[:baseline] || 0,
778
- :_rotation => params[:rotation]
770
+ _name: params[:name],
771
+ _color: params[:color],
772
+ _size: params[:size],
773
+ _bold: params[:bold],
774
+ _italic: params[:italic],
775
+ _underline: params[:underline],
776
+ _pitch_family: params[:pitch_family],
777
+ _charset: params[:charset],
778
+ _baseline: params[:baseline] || 0,
779
+ _rotation: params[:rotation]
779
780
  }
780
781
  end
781
782
 
@@ -862,7 +863,7 @@ module Writexlsx
862
863
 
863
864
  if !latin_attributes.empty? || has_color
864
865
  @writer.tag_elements(tag, style_attributes) do
865
- write_a_solid_fill(:color => font[:_color]) if has_color
866
+ write_a_solid_fill(color: font[:_color]) if has_color
866
867
  write_a_latin(latin_attributes) unless latin_attributes.empty?
867
868
  end
868
869
  else
@@ -1,3 +1,3 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- WriteXLSX_VERSION = "1.10.0"
3
+ WriteXLSX_VERSION = "1.10.2"
@@ -95,18 +95,18 @@ module Writexlsx
95
95
 
96
96
  if @excel2003_style
97
97
  add_format(default_formats.merge(
98
- :xf_index => 0,
99
- :font_family => 0,
100
- :font => 'Arial',
101
- :size => 10,
102
- :theme => -1
98
+ xf_index: 0,
99
+ font_family: 0,
100
+ font: 'Arial',
101
+ size: 10,
102
+ theme: -1
103
103
  ))
104
104
  else
105
- add_format(default_formats.merge(:xf_index => 0))
105
+ add_format(default_formats.merge(xf_index: 0))
106
106
  end
107
107
 
108
108
  # Add a default URL format.
109
- @default_url_format = add_format(:hyperlink => 1)
109
+ @default_url_format = add_format(hyperlink: 1)
110
110
 
111
111
  set_color_palette
112
112
  end
@@ -273,7 +273,7 @@ module Writexlsx
273
273
  #
274
274
  def add_format(property_hash = {})
275
275
  properties = {}
276
- properties.update(:font => 'Arial', :size => 10, :theme => -1) if @excel2003_style
276
+ properties.update(font: 'Arial', size: 10, theme: -1) if @excel2003_style
277
277
  properties.update(property_hash)
278
278
 
279
279
  format = Format.new(@formats, properties)
@@ -376,18 +376,18 @@ module Writexlsx
376
376
 
377
377
  # List of valid input parameters.
378
378
  valid = {
379
- :title => 1,
380
- :subject => 1,
381
- :author => 1,
382
- :keywords => 1,
383
- :comments => 1,
384
- :last_author => 1,
385
- :created => 1,
386
- :category => 1,
387
- :manager => 1,
388
- :company => 1,
389
- :status => 1,
390
- :hyperlink_base => 1
379
+ title: 1,
380
+ subject: 1,
381
+ author: 1,
382
+ keywords: 1,
383
+ comments: 1,
384
+ last_author: 1,
385
+ created: 1,
386
+ category: 1,
387
+ manager: 1,
388
+ company: 1,
389
+ status: 1,
390
+ hyperlink_base: 1
391
391
  }
392
392
 
393
393
  # Check for valid input parameters.
@@ -64,7 +64,7 @@ module Writexlsx
64
64
  end
65
65
 
66
66
  def data
67
- { :sst_id => token }
67
+ { sst_id: token }
68
68
  end
69
69
 
70
70
  TYPE_STR_ATTRS = %w[t s].freeze
@@ -13,7 +13,19 @@ module Writexlsx
13
13
 
14
14
  def initialize(*args)
15
15
  # Check for a cell reference in A1 notation and substitute row and column.
16
- row1, col1, row2, col2, options = row_col_notation(args)
16
+ if (row_col_array = row_col_notation(args.first))
17
+ case row_col_array.size
18
+ when 2
19
+ row1, col1 = row_col_array
20
+ row2, col2, options = args[1..-1]
21
+ when 4
22
+ row1, col1, row2, col2 = row_col_array
23
+ options = args[1]
24
+ end
25
+ else
26
+ row1, col1, row2, col2, options = args
27
+ end
28
+
17
29
  if row2.respond_to?(:keys)
18
30
  options_to_instance_variable(row2.dup)
19
31
  row2 = row1