caxlsx 4.1.0 → 4.3.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.
Files changed (95) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +28 -12
  3. data/README.md +7 -1
  4. data/Rakefile +2 -9
  5. data/lib/axlsx/content_type/abstract_content_type.rb +2 -2
  6. data/lib/axlsx/content_type/content_type.rb +3 -3
  7. data/lib/axlsx/drawing/area_chart.rb +3 -3
  8. data/lib/axlsx/drawing/area_series.rb +2 -2
  9. data/lib/axlsx/drawing/ax_data_source.rb +1 -1
  10. data/lib/axlsx/drawing/axes.rb +1 -1
  11. data/lib/axlsx/drawing/axis.rb +1 -1
  12. data/lib/axlsx/drawing/bar_3D_chart.rb +14 -4
  13. data/lib/axlsx/drawing/bar_chart.rb +14 -4
  14. data/lib/axlsx/drawing/bar_series.rb +2 -2
  15. data/lib/axlsx/drawing/bubble_chart.rb +2 -2
  16. data/lib/axlsx/drawing/bubble_series.rb +2 -2
  17. data/lib/axlsx/drawing/cat_axis.rb +3 -3
  18. data/lib/axlsx/drawing/chart.rb +1 -0
  19. data/lib/axlsx/drawing/d_lbls.rb +5 -4
  20. data/lib/axlsx/drawing/drawing.rb +50 -50
  21. data/lib/axlsx/drawing/hyperlink.rb +1 -1
  22. data/lib/axlsx/drawing/line_3D_chart.rb +3 -3
  23. data/lib/axlsx/drawing/line_chart.rb +3 -3
  24. data/lib/axlsx/drawing/line_series.rb +2 -2
  25. data/lib/axlsx/drawing/num_val.rb +1 -1
  26. data/lib/axlsx/drawing/pic.rb +4 -4
  27. data/lib/axlsx/drawing/pie_3D_chart.rb +2 -2
  28. data/lib/axlsx/drawing/pie_chart.rb +2 -2
  29. data/lib/axlsx/drawing/pie_series.rb +2 -2
  30. data/lib/axlsx/drawing/scatter_chart.rb +2 -2
  31. data/lib/axlsx/drawing/scatter_series.rb +2 -2
  32. data/lib/axlsx/drawing/ser_axis.rb +3 -3
  33. data/lib/axlsx/drawing/two_cell_anchor.rb +1 -1
  34. data/lib/axlsx/drawing/val_axis.rb +2 -2
  35. data/lib/axlsx/drawing/vml_shape.rb +1 -1
  36. data/lib/axlsx/package.rb +10 -12
  37. data/lib/axlsx/rels/relationship.rb +2 -2
  38. data/lib/axlsx/rels/relationships.rb +2 -2
  39. data/lib/axlsx/stylesheet/border_pr.rb +2 -1
  40. data/lib/axlsx/stylesheet/cell_alignment.rb +1 -1
  41. data/lib/axlsx/stylesheet/cell_style.rb +1 -1
  42. data/lib/axlsx/stylesheet/color.rb +2 -2
  43. data/lib/axlsx/stylesheet/font.rb +1 -1
  44. data/lib/axlsx/stylesheet/gradient_fill.rb +1 -1
  45. data/lib/axlsx/stylesheet/pattern_fill.rb +1 -0
  46. data/lib/axlsx/stylesheet/styles.rb +27 -31
  47. data/lib/axlsx/stylesheet/xf.rb +2 -1
  48. data/lib/axlsx/util/accessors.rb +1 -1
  49. data/lib/axlsx/util/buffered_zip_output_stream.rb +2 -2
  50. data/lib/axlsx/util/constants.rb +2 -2
  51. data/lib/axlsx/util/serialized_attributes.rb +2 -2
  52. data/lib/axlsx/util/simple_typed_list.rb +26 -14
  53. data/lib/axlsx/util/storage.rb +3 -3
  54. data/lib/axlsx/util/validators.rb +2 -2
  55. data/lib/axlsx/version.rb +1 -1
  56. data/lib/axlsx/workbook/defined_name.rb +2 -1
  57. data/lib/axlsx/workbook/shared_strings_table.rb +3 -3
  58. data/lib/axlsx/workbook/workbook.rb +61 -61
  59. data/lib/axlsx/workbook/worksheet/auto_filter/auto_filter.rb +4 -4
  60. data/lib/axlsx/workbook/worksheet/auto_filter/filter_column.rb +1 -1
  61. data/lib/axlsx/workbook/worksheet/auto_filter/filters.rb +4 -4
  62. data/lib/axlsx/workbook/worksheet/auto_filter/sort_condition.rb +1 -1
  63. data/lib/axlsx/workbook/worksheet/auto_filter/sort_state.rb +2 -2
  64. data/lib/axlsx/workbook/worksheet/border_creator.rb +4 -4
  65. data/lib/axlsx/workbook/worksheet/cell.rb +10 -10
  66. data/lib/axlsx/workbook/worksheet/cell_serializer.rb +1 -1
  67. data/lib/axlsx/workbook/worksheet/col.rb +23 -9
  68. data/lib/axlsx/workbook/worksheet/comment.rb +2 -2
  69. data/lib/axlsx/workbook/worksheet/comments.rb +1 -1
  70. data/lib/axlsx/workbook/worksheet/conditional_formatting.rb +1 -1
  71. data/lib/axlsx/workbook/worksheet/conditional_formatting_rule.rb +1 -1
  72. data/lib/axlsx/workbook/worksheet/conditional_formattings.rb +2 -2
  73. data/lib/axlsx/workbook/worksheet/data_validation.rb +1 -1
  74. data/lib/axlsx/workbook/worksheet/data_validations.rb +2 -2
  75. data/lib/axlsx/workbook/worksheet/date_time_converter.rb +2 -2
  76. data/lib/axlsx/workbook/worksheet/dimension.rb +1 -1
  77. data/lib/axlsx/workbook/worksheet/header_footer.rb +1 -1
  78. data/lib/axlsx/workbook/worksheet/icon_set.rb +1 -1
  79. data/lib/axlsx/workbook/worksheet/outline_pr.rb +1 -1
  80. data/lib/axlsx/workbook/worksheet/page_setup.rb +2 -2
  81. data/lib/axlsx/workbook/worksheet/pane.rb +1 -0
  82. data/lib/axlsx/workbook/worksheet/pivot_table.rb +30 -6
  83. data/lib/axlsx/workbook/worksheet/print_options.rb +1 -0
  84. data/lib/axlsx/workbook/worksheet/rich_text_run.rb +1 -1
  85. data/lib/axlsx/workbook/worksheet/sheet_calc_pr.rb +1 -0
  86. data/lib/axlsx/workbook/worksheet/sheet_pr.rb +1 -1
  87. data/lib/axlsx/workbook/worksheet/table_style_info.rb +2 -1
  88. data/lib/axlsx/workbook/worksheet/worksheet.rb +10 -12
  89. data/lib/axlsx/workbook/worksheet/worksheet_comments.rb +4 -4
  90. data/lib/axlsx/workbook/worksheet/worksheet_drawing.rb +1 -1
  91. data/lib/axlsx/workbook/worksheet/worksheet_hyperlink.rb +2 -1
  92. data/lib/axlsx/workbook/worksheet/worksheet_hyperlinks.rb +1 -1
  93. data/lib/axlsx.rb +44 -30
  94. data/lib/caxlsx.rb +1 -1
  95. metadata +7 -10
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Axlsx
4
- # A simple, self serializing class for storing conditional formattings
4
+ # A simple, self serializing class for storing conditional formatting
5
5
  class ConditionalFormattings < SimpleTypedList
6
6
  # creates a new Tables object
7
7
  def initialize(worksheet)
@@ -15,7 +15,7 @@ module Axlsx
15
15
  # @return [Worksheet]
16
16
  attr_reader :worksheet
17
17
 
18
- # serialize the conditional formattings
18
+ # serialize the conditional formatting
19
19
  def to_xml_string(str = +'')
20
20
  return if empty?
21
21
 
@@ -278,7 +278,7 @@ module Axlsx
278
278
 
279
279
  str << '<dataValidation '
280
280
  h.each_with_index do |key_value, index|
281
- str << ' ' unless index.zero?
281
+ str << ' ' unless index == 0
282
282
  str << key_value.first << '="' << Axlsx.booleanize(key_value.last).to_s << '"'
283
283
  end
284
284
  str << '>'
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Axlsx
4
- # A simple, self serializing class for storing conditional formattings
4
+ # A simple, self serializing class for storing conditional formatting
5
5
  class DataValidations < SimpleTypedList
6
6
  # creates a new Tables object
7
7
  def initialize(worksheet)
@@ -15,7 +15,7 @@ module Axlsx
15
15
  # @return [Worksheet]
16
16
  attr_reader :worksheet
17
17
 
18
- # serialize the conditional formattings
18
+ # serialize the conditional formatting
19
19
  def to_xml_string(str = +'')
20
20
  return if empty?
21
21
 
@@ -3,9 +3,9 @@
3
3
  require "date"
4
4
 
5
5
  module Axlsx
6
- # The DateTimeConverter class converts both data and time types to their apprpriate Excel serializations
6
+ # The DateTimeConverter class converts both data and time types to their appropriate Excel serializations
7
7
  class DateTimeConverter
8
- # The date_to_serial method converts Date objects to the equivelant Excel serialized forms
8
+ # The date_to_serial method converts Date objects to the equivalent Excel serialized forms
9
9
  # @param [Date] date the date to be serialized
10
10
  # @return [Numeric]
11
11
  def self.date_to_serial(date)
@@ -28,7 +28,7 @@ module Axlsx
28
28
 
29
29
  attr_reader :worksheet
30
30
 
31
- # the full refernece for this dimension
31
+ # the full reference for this dimension
32
32
  # @return [String]
33
33
  def sqref
34
34
  "#{first_cell_reference}:#{last_cell_reference}"
@@ -7,7 +7,7 @@ module Axlsx
7
7
  # of plain text and control characters. A fairly comprehensive list of control
8
8
  # characters can be found here:
9
9
  # https://github.com/randym/axlsx/blob/master/notes_on_header_footer.md
10
- #     
10
+ #
11
11
  # @note The recommended way of managing header/footers is via Worksheet#header_footer
12
12
  # @see Worksheet#initialize
13
13
  class HeaderFooter
@@ -99,7 +99,7 @@ module Axlsx
99
99
 
100
100
  private
101
101
 
102
- # Initalize the simple typed list of value objects
102
+ # Initialize the simple typed list of value objects
103
103
  def initialize_value_objects
104
104
  @value_objects = SimpleTypedList.new Cfvo
105
105
  @interpolationPoints.each { |point| @value_objects << Cfvo.new(type: :percent, val: point) }
@@ -13,7 +13,7 @@ module Axlsx
13
13
  :apply_styles
14
14
 
15
15
  # These attributes are all boolean so I'm doing a bit of a hand
16
- # waving magic show to set up the attriubte accessors
16
+ # waving magic show to set up the attribute accessors
17
17
  boolean_attr_accessor :summary_below,
18
18
  :summary_right,
19
19
  :apply_styles
@@ -38,13 +38,13 @@ module Axlsx
38
38
  # * verticalDpi
39
39
 
40
40
  # Number of vertical pages to fit on.
41
- # @note PageSetup#fit_to is the recomended way to manage page fitting as only specifying one of fit_to_width/fit_to_height will result in the counterpart
41
+ # @note PageSetup#fit_to is the recommended way to manage page fitting as only specifying one of fit_to_width/fit_to_height will result in the counterpart
42
42
  # being set to 1.
43
43
  # @return [Integer]
44
44
  attr_reader :fit_to_height
45
45
 
46
46
  # Number of horizontal pages to fit on.
47
- # @note PageSetup#fit_to is the recomended way to manage page fitting as only specifying one of width/height will result in the counterpart
47
+ # @note PageSetup#fit_to is the recommended way to manage page fitting as only specifying one of width/height will result in the counterpart
48
48
  # being set to 1.
49
49
  # @return [Integer]
50
50
  attr_reader :fit_to_width
@@ -8,6 +8,7 @@ module Axlsx
8
8
  class Pane
9
9
  include Axlsx::OptionsParser
10
10
  include Axlsx::SerializedAttributes
11
+
11
12
  # Creates a new {Pane} object
12
13
  # @option options [Symbol] active_pane Active Pane
13
14
  # @option options [Symbol] state Split State
@@ -26,6 +26,7 @@ module Axlsx
26
26
  @pages = []
27
27
  @subtotal = nil
28
28
  @no_subtotals_on_headers = []
29
+ @grand_totals = :both
29
30
  @sort_on_headers = {}
30
31
  @style_info = {}
31
32
  parse_options options
@@ -51,6 +52,19 @@ module Axlsx
51
52
  @sort_on_headers = headers
52
53
  end
53
54
 
55
+ # Defines which Grand Totals are to be shown.
56
+ # @return [Symbol] The row and/or column Grand Totals that are to be shown.
57
+ # Defaults to `:both` to show both row & column grand totals.
58
+ # Set to `:row_only`, `:col_only`, or `:none` to hide one or both Grand Totals.
59
+ attr_reader :grand_totals
60
+
61
+ # (see #grand_totals)
62
+ def grand_totals=(value)
63
+ RestrictionValidator.validate "PivotTable.grand_totals", [:both, :row_only, :col_only, :none], value
64
+
65
+ @grand_totals = value
66
+ end
67
+
54
68
  # Style info for the pivot table
55
69
  # @return [Hash]
56
70
  attr_accessor :style_info
@@ -114,7 +128,8 @@ module Axlsx
114
128
  @columns = v
115
129
  end
116
130
 
117
- # The data
131
+ # The data as an array of either headers (String) or hashes or mix of the two.
132
+ # Hash in format of { ref: header, num_fmt: numFmts, subtotal: subtotal }, where header is String, numFmts is Integer, and subtotal one of %w[sum count average max min product countNums stdDev stdDevp var varp]; leave subtotal blank to sum values
118
133
  # @return [Array]
119
134
  attr_reader :data
120
135
 
@@ -188,7 +203,11 @@ module Axlsx
188
203
  def to_xml_string(str = +'')
189
204
  str << '<?xml version="1.0" encoding="UTF-8"?>'
190
205
 
191
- str << '<pivotTableDefinition xmlns="' << XML_NS << '" name="' << name << '" cacheId="' << cache_definition.cache_id.to_s << '"' << (data.size <= 1 ? ' dataOnRows="1"' : '') << ' applyNumberFormats="0" applyBorderFormats="0" applyFontFormats="0" applyPatternFormats="0" applyAlignmentFormats="0" applyWidthHeightFormats="1" dataCaption="Data" showMultipleLabel="0" showMemberPropertyTips="0" useAutoFormatting="1" indent="0" compact="0" compactData="0" gridDropZones="1" multipleFieldFilters="0">'
206
+ str << '<pivotTableDefinition xmlns="' << XML_NS << '" name="' << name << '" cacheId="' << cache_definition.cache_id.to_s << '"'
207
+ str << ' dataOnRows="1"' if data.size <= 1
208
+ str << ' rowGrandTotals="0"' if grand_totals == :col_only || grand_totals == :none
209
+ str << ' colGrandTotals="0"' if grand_totals == :row_only || grand_totals == :none
210
+ str << ' applyNumberFormats="0" applyBorderFormats="0" applyFontFormats="0" applyPatternFormats="0" applyAlignmentFormats="0" applyWidthHeightFormats="1" dataCaption="Data" showMultipleLabel="0" showMemberPropertyTips="0" useAutoFormatting="1" indent="0" compact="0" compactData="0" gridDropZones="1" multipleFieldFilters="0">'
192
211
 
193
212
  str << '<location firstDataCol="1" firstDataRow="1" firstHeaderRow="1" ref="' << ref << '"/>'
194
213
  str << '<pivotFields count="' << header_cells_count.to_s << '">'
@@ -244,8 +263,9 @@ module Axlsx
244
263
  unless data.empty?
245
264
  str << "<dataFields count=\"#{data.size}\">"
246
265
  data.each do |datum_value|
247
- # The correct name prefix in ["Sum","Average", etc...]
248
- str << "<dataField name='#{datum_value[:subtotal] || ''} of #{datum_value[:ref]}' fld='#{header_index_of(datum_value[:ref])}' baseField='0' baseItem='0'"
266
+ subtotal_name = datum_value[:subtotal] || 'sum'
267
+ subtotal_name = 'count' if name == 'countNums' # both count & countNums are labelled as count
268
+ str << "<dataField name='#{subtotal_name.capitalize} of #{datum_value[:ref]}' fld='#{header_index_of(datum_value[:ref])}' baseField='0' baseItem='0'"
249
269
  str << " numFmtId='#{datum_value[:num_fmt]}'" if datum_value[:num_fmt]
250
270
  str << " subtotal='#{datum_value[:subtotal]}' " if datum_value[:subtotal]
251
271
  str << "/>"
@@ -311,7 +331,11 @@ module Axlsx
311
331
  elsif columns.include? cell_ref
312
332
  attributes << 'axis="axisCol"'
313
333
  attributes << "sortType=\"#{sorttype == :descending ? 'descending' : 'ascending'}\"" if sorttype
314
- include_items_tag = true
334
+ if subtotal
335
+ include_items_tag = true
336
+ else
337
+ attributes << 'defaultSubtotal="0"'
338
+ end
315
339
  elsif pages.include? cell_ref
316
340
  attributes << 'axis="axisPage"'
317
341
  include_items_tag = true
@@ -319,7 +343,7 @@ module Axlsx
319
343
  attributes << 'dataField="1"'
320
344
  end
321
345
 
322
- "<pivotField #{attributes.join(' ')}>#{include_items_tag ? items_tag : nil}</pivotField>"
346
+ "<pivotField #{attributes.join(' ')}>#{items_tag if include_items_tag}</pivotField>"
323
347
  end
324
348
 
325
349
  def data_refs
@@ -10,6 +10,7 @@ module Axlsx
10
10
  include Axlsx::OptionsParser
11
11
  include Axlsx::SerializedAttributes
12
12
  include Axlsx::Accessors
13
+
13
14
  # Creates a new PrintOptions object
14
15
  # @option options [Boolean] grid_lines Whether grid lines should be printed
15
16
  # @option options [Boolean] headings Whether row and column headings should be printed
@@ -143,7 +143,7 @@ module Axlsx
143
143
  # It must be one of :none, :single, :double, :singleAccounting, :doubleAccounting, true
144
144
  # @return [Boolean]
145
145
  # @return [String]
146
- # @note true is for backwards compatability and is reassigned to :single
146
+ # @note true is for backwards compatibility and is reassigned to :single
147
147
  attr_reader :u
148
148
 
149
149
  # @see u
@@ -7,6 +7,7 @@ module Axlsx
7
7
  include Axlsx::OptionsParser
8
8
  include Axlsx::SerializedAttributes
9
9
  include Axlsx::Accessors
10
+
10
11
  # creates a new SheetCalcPr
11
12
  # @param [Hash] options Options for this object
12
13
  # @option [Boolean] full_calc_on_load @see full_calc_on_load
@@ -18,7 +18,7 @@ module Axlsx
18
18
  :sync_ref
19
19
 
20
20
  # These attributes are all boolean so I'm doing a bit of a hand
21
- # waving magic show to set up the attriubte accessors
21
+ # waving magic show to set up the attribute accessors
22
22
  boolean_attr_accessor :sync_horizontal,
23
23
  :sync_vertical,
24
24
  :transition_evaluation,
@@ -7,6 +7,7 @@ module Axlsx
7
7
  include Axlsx::OptionsParser
8
8
  include Axlsx::SerializedAttributes
9
9
  include Axlsx::Accessors
10
+
10
11
  # creates a new TableStyleInfo instance
11
12
  # @param [Hash] options
12
13
  # @option [Boolean] show_first_column indicates if the first column should
@@ -41,7 +42,7 @@ module Axlsx
41
42
  # The name of the table style.
42
43
  attr_accessor :name
43
44
 
44
- # seralizes this object to an xml string
45
+ # serializes this object to an xml string
45
46
  # @param [String] str the string to contact this objects serialization to.
46
47
  def to_xml_string(str = +'')
47
48
  serialized_tag('tableStyleInfo', str)
@@ -31,7 +31,7 @@ module Axlsx
31
31
 
32
32
  serializable_attributes :sheet_id, :state
33
33
 
34
- # Initalizes page margin, setup and print options
34
+ # Initializes page margin, setup and print options
35
35
  # @param [Hash] options Options passed in from the initializer
36
36
  def initialize_page_options(options)
37
37
  @page_margins = PageMargins.new options[:page_margins] if options[:page_margins]
@@ -181,7 +181,7 @@ module Axlsx
181
181
  @auto_filter ||= AutoFilter.new self
182
182
  end
183
183
 
184
- # Indicates if the worksheet will be fit by witdh or height to a specific number of pages.
184
+ # Indicates if the worksheet will be fit by width or height to a specific number of pages.
185
185
  # To alter the width or height for page fitting, please use page_setup.fit_to_widht or page_setup.fit_to_height.
186
186
  # If you want the worksheet to fit on more pages (e.g. 2x2), set {PageSetup#fit_to_width} and {PageSetup#fit_to_height} accordingly.
187
187
  # @return Boolean
@@ -421,7 +421,7 @@ module Axlsx
421
421
  # @option options [Array] values
422
422
  # @option options [Array, Symbol] types
423
423
  # @option options [Array, Integer] style
424
- # @option options [Array] widths each member of the widths array will affect how auto_fit behavies.
424
+ # @option options [Array] widths each member of the widths array will affect how auto_fit behaves.
425
425
  # @option options [Float] height the row's height (in points)
426
426
  # @option options [Integer] offset - add empty columns before values
427
427
  # @option options [Array, Boolean] escape_formulas - Whether to treat a value starting with an equal
@@ -666,12 +666,11 @@ module Axlsx
666
666
  # @return [Relationships]
667
667
  def relationships
668
668
  r = Relationships.new
669
- r + [tables.relationships,
670
- worksheet_comments.relationships,
671
- hyperlinks.relationships,
672
- worksheet_drawing.relationship,
673
- pivot_tables.relationships].flatten.compact || []
674
- r
669
+ r.concat [tables.relationships,
670
+ worksheet_comments.relationships,
671
+ hyperlinks.relationships,
672
+ worksheet_drawing.relationship,
673
+ pivot_tables.relationships].flatten.compact
675
674
  end
676
675
 
677
676
  # Returns the cell or cells defined using Excel style A1:B3 references.
@@ -728,7 +727,7 @@ module Axlsx
728
727
  end
729
728
 
730
729
  # shortcut level to specify the outline level for a series of rows
731
- # Oulining is what lets you add collapse and expand to a data set.
730
+ # Outlining is what lets you add collapse and expand to a data set.
732
731
  # @param [Integer] start_index The zero based index of the first row of outlining.
733
732
  # @param [Integer] end_index The zero based index of the last row to be outlined
734
733
  # @param [integer] level The level of outline to apply
@@ -738,7 +737,7 @@ module Axlsx
738
737
  end
739
738
 
740
739
  # shortcut level to specify the outline level for a series of columns
741
- # Oulining is what lets you add collapse and expand to a data set.
740
+ # Outlining is what lets you add collapse and expand to a data set.
742
741
  # @param [Integer] start_index The zero based index of the first column of outlining.
743
742
  # @param [Integer] end_index The zero based index of the last column to be outlined
744
743
  # @param [integer] level The level of outline to apply
@@ -855,7 +854,6 @@ module Axlsx
855
854
  cells.each_with_index do |cell, index|
856
855
  width = widths ? widths[index] : nil
857
856
  col = find_or_create_column_info(index)
858
- next if width == :ignore
859
857
 
860
858
  col.update_width(cell, width, workbook.use_autowidth)
861
859
  end
@@ -1,11 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Axlsx
4
- # A wraper class for comments that defines its on worksheet
5
- # serailization
4
+ # A wrapper class for comments that defines its on worksheet
5
+ # serialization
6
6
  class WorksheetComments
7
7
  # Creates a new WorksheetComments object
8
- # param [Worksheet] worksheet The worksheet comments in thes object belong to
8
+ # param [Worksheet] worksheet The worksheet to which the comments belong
9
9
  def initialize(worksheet)
10
10
  raise ArugumentError, 'You must provide a worksheet' unless worksheet.is_a?(Worksheet)
11
11
 
@@ -37,7 +37,7 @@ module Axlsx
37
37
 
38
38
  # Helper method to tell us if there are comments in the comments collection
39
39
  # @return [Boolean]
40
- def has_comments? # rubocop:disable Naming/PredicateName
40
+ def has_comments? # rubocop:disable Naming/PredicatePrefix
41
41
  !comments.empty?
42
42
  end
43
43
 
@@ -42,7 +42,7 @@ module Axlsx
42
42
 
43
43
  # helper method to tell us if the drawing has something in it or not
44
44
  # @return [Boolean]
45
- def has_drawing? # rubocop:disable Naming/PredicateName
45
+ def has_drawing? # rubocop:disable Naming/PredicatePrefix
46
46
  @drawing.is_a? Drawing
47
47
  end
48
48
 
@@ -6,6 +6,7 @@ module Axlsx
6
6
  include Axlsx::OptionsParser
7
7
  include Axlsx::Accessors
8
8
  include Axlsx::SerializedAttributes
9
+
9
10
  # Creates a new hyperlink object.
10
11
  # @note the preferred way to add hyperlinks to your worksheet is the Worksheet#add_hyperlink method
11
12
  # @param [Worksheet] worksheet the Worksheet that owns this hyperlink
@@ -55,7 +56,7 @@ module Axlsx
55
56
  Relationship.new(self, HYPERLINK_R, location, target_mode: :External)
56
57
  end
57
58
 
58
- # Seralize the object
59
+ # Serialize the object
59
60
  # @param [String] str
60
61
  # @return [String]
61
62
  def to_xml_string(str = +'')
@@ -27,7 +27,7 @@ module Axlsx
27
27
  map(&:relationship)
28
28
  end
29
29
 
30
- # seralize the collection of hyperlinks
30
+ # serialize the collection of hyperlinks
31
31
  # @return [String]
32
32
  def to_xml_string(str = +'')
33
33
  return if empty?
data/lib/axlsx.rb CHANGED
@@ -1,38 +1,39 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require_relative 'axlsx/version'
4
+
5
+ # gemspec dependencies
3
6
  require 'htmlentities'
4
- require 'axlsx/version'
5
7
  require 'marcel'
6
-
7
- require 'axlsx/util/simple_typed_list'
8
- require 'axlsx/util/constants'
9
- require 'axlsx/util/validators'
10
- require 'axlsx/util/accessors'
11
- require 'axlsx/util/serialized_attributes'
12
- require 'axlsx/util/options_parser'
13
- require 'axlsx/util/mime_type_utils'
14
- require 'axlsx/util/buffered_zip_output_stream'
15
- require 'axlsx/util/zip_command'
16
-
17
- require 'axlsx/stylesheet/styles'
18
-
19
- require 'axlsx/doc_props/app'
20
- require 'axlsx/doc_props/core'
21
- require 'axlsx/content_type/content_type'
22
- require 'axlsx/rels/relationships'
23
-
24
- require 'axlsx/drawing/drawing'
25
- require 'axlsx/workbook/workbook'
26
- require 'axlsx/package'
27
- # required gems
28
8
  require 'nokogiri'
29
9
  require 'zip'
30
10
 
31
- # core dependencies
32
- require 'bigdecimal'
11
+ # Ruby core dependencies
33
12
  require 'cgi'
34
13
  require 'set'
35
14
  require 'time'
15
+ require 'uri'
16
+
17
+ require_relative 'axlsx/util/simple_typed_list'
18
+ require_relative 'axlsx/util/constants'
19
+ require_relative 'axlsx/util/validators'
20
+ require_relative 'axlsx/util/accessors'
21
+ require_relative 'axlsx/util/serialized_attributes'
22
+ require_relative 'axlsx/util/options_parser'
23
+ require_relative 'axlsx/util/mime_type_utils'
24
+ require_relative 'axlsx/util/buffered_zip_output_stream'
25
+ require_relative 'axlsx/util/zip_command'
26
+
27
+ require_relative 'axlsx/stylesheet/styles'
28
+
29
+ require_relative 'axlsx/doc_props/app'
30
+ require_relative 'axlsx/doc_props/core'
31
+ require_relative 'axlsx/content_type/content_type'
32
+ require_relative 'axlsx/rels/relationships'
33
+
34
+ require_relative 'axlsx/drawing/drawing'
35
+ require_relative 'axlsx/workbook/workbook'
36
+ require_relative 'axlsx/package'
36
37
 
37
38
  if Gem.loaded_specs.key?("axlsx_styler")
38
39
  raise StandardError, "Please remove `axlsx_styler` from your Gemfile, the associated functionality is now built-in to `caxlsx` directly."
@@ -88,12 +89,10 @@ module Axlsx
88
89
  letters_str = name[/[A-Z]+/]
89
90
 
90
91
  # capitalization?!?
91
- v = letters_str.reverse.chars.reduce({ base: 1, i: 0 }) do |val, c|
92
+ v = letters_str.reverse.chars.each_with_object({ base: 1, i: 0 }) do |c, val|
92
93
  val[:i] += ((c.bytes.first - 64) * val[:base])
93
94
 
94
95
  val[:base] *= 26
95
-
96
- next val
97
96
  end
98
97
 
99
98
  col_index = (v[:i] - 1)
@@ -154,7 +153,7 @@ module Axlsx
154
153
  end
155
154
  end
156
155
 
157
- # performs the increadible feat of changing snake_case to CamelCase
156
+ # performs the incredible feat of changing snake_case to CamelCase
158
157
  # @param [String] s The snake case string to camelize
159
158
  # @return [String]
160
159
  def self.camel(s = "", all_caps = true)
@@ -163,7 +162,7 @@ module Axlsx
163
162
  s.gsub(/_(.)/) { ::Regexp.last_match(1).upcase }
164
163
  end
165
164
 
166
- # returns the provided string with all invalid control charaters
165
+ # returns the provided string with all invalid control characters
167
166
  # removed.
168
167
  # @param [String] str The string to process
169
168
  # @return [String]
@@ -229,4 +228,19 @@ module Axlsx
229
228
  Axlsx.validate_boolean(value)
230
229
  @escape_formulas = value
231
230
  end
231
+
232
+ # Returns a URI parser instance, preferring RFC2396_PARSER if available,
233
+ # otherwise falling back to DEFAULT_PARSER. This method ensures consistent
234
+ # URI parsing across different Ruby versions.
235
+ # This method can be removed when dropping compatibility for Ruby < 3.4
236
+ # See https://github.com/ruby/uri/pull/114 for details.
237
+ # @return [Object]
238
+ def self.uri_parser
239
+ @uri_parser ||=
240
+ if defined?(URI::RFC2396_PARSER)
241
+ URI::RFC2396_PARSER
242
+ else
243
+ URI::DEFAULT_PARSER
244
+ end
245
+ end
232
246
  end
data/lib/caxlsx.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'axlsx'
3
+ require_relative 'axlsx'
metadata CHANGED
@@ -1,15 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: caxlsx
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.1.0
4
+ version: 4.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Randy Morgan
8
8
  - Jurriaan Pruis
9
- autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2024-02-28 00:00:00.000000000 Z
11
+ date: 1980-01-02 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: htmlentities
@@ -71,20 +70,20 @@ dependencies:
71
70
  requirements:
72
71
  - - ">="
73
72
  - !ruby/object:Gem::Version
74
- version: 1.3.0
73
+ version: '2.4'
75
74
  - - "<"
76
75
  - !ruby/object:Gem::Version
77
- version: '3'
76
+ version: '4'
78
77
  type: :runtime
79
78
  prerelease: false
80
79
  version_requirements: !ruby/object:Gem::Requirement
81
80
  requirements:
82
81
  - - ">="
83
82
  - !ruby/object:Gem::Version
84
- version: 1.3.0
83
+ version: '2.4'
85
84
  - - "<"
86
85
  - !ruby/object:Gem::Version
87
- version: '3'
86
+ version: '4'
88
87
  description: 'xlsx spreadsheet generation with charts, images, automated column width,
89
88
  customizable styles and full schema validation. Axlsx helps you create beautiful
90
89
  Office Open XML Spreadsheet documents (Excel, Google Spreadsheets, Numbers, LibreOffice)
@@ -297,7 +296,6 @@ metadata:
297
296
  changelog_uri: https://github.com/caxlsx/caxlsx/blob/master/CHANGELOG.md
298
297
  source_code_uri: https://github.com/caxlsx/caxlsx
299
298
  rubygems_mfa_required: 'true'
300
- post_install_message:
301
299
  rdoc_options: []
302
300
  require_paths:
303
301
  - lib
@@ -312,8 +310,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
312
310
  - !ruby/object:Gem::Version
313
311
  version: '0'
314
312
  requirements: []
315
- rubygems_version: 3.2.3
316
- signing_key:
313
+ rubygems_version: 3.6.9
317
314
  specification_version: 4
318
315
  summary: Excel OOXML (xlsx) with charts, styles, images and autowidth columns.
319
316
  test_files: []