summaryrefslogtreecommitdiffhomepage
path: root/lib
diff options
context:
space:
mode:
authorWeston Ganger <[email protected]>2022-10-09 14:40:24 -0700
committerWeston Ganger <[email protected]>2022-10-09 14:40:24 -0700
commit03bad903f474fecccc7dacdc14ef17605d9e2aa2 (patch)
treee0a88df15105a6c2d5dfda5c9178a428b280e6bf /lib
parent99b25655ef0e5c953007ff81b5bc08058831da8c (diff)
downloadcaxlsx-03bad903f474fecccc7dacdc14ef17605d9e2aa2.tar.gz
caxlsx-03bad903f474fecccc7dacdc14ef17605d9e2aa2.zip
Improvements
Diffstat (limited to 'lib')
-rw-r--r--lib/axlsx.rb11
-rw-r--r--lib/axlsx/workbook/workbook.rb17
-rw-r--r--lib/axlsx/workbook/worksheet/cell.rb2
-rw-r--r--lib/caxlsx.rb10
4 files changed, 14 insertions, 26 deletions
diff --git a/lib/axlsx.rb b/lib/axlsx.rb
index c30fcf26..e02256e6 100644
--- a/lib/axlsx.rb
+++ b/lib/axlsx.rb
@@ -28,8 +28,19 @@ require 'zip'
#core dependencies
require 'bigdecimal'
+require 'set'
require 'time'
+begin
+ require "axlsx_styler"
+
+ if defined?(AxlsxStyler)
+ raise StandardError.new("Please remove `axlsx_styler` from your Gemfile, the associated functionality is now built-in to `caxlsx` directly.")
+ end
+rescue LoadError
+ # Do nothing, all good
+end
+
# xlsx generation with charts, images, automated column width, customizable styles
# and full schema validation. Axlsx excels at helping you generate beautiful
# Office Open XML Spreadsheet documents without having to understand the entire
diff --git a/lib/axlsx/workbook/workbook.rb b/lib/axlsx/workbook/workbook.rb
index 417e15a3..ef56debd 100644
--- a/lib/axlsx/workbook/workbook.rb
+++ b/lib/axlsx/workbook/workbook.rb
@@ -188,7 +188,9 @@ require 'axlsx/workbook/worksheet/selection.rb'
end
# An array that holds all cells with styles
- attr_accessor :styled_cells
+ def styled_cells
+ @styled_cells ||= Set.new
+ end
# Checks if styles are indexed to make it work for pre 0.1.5 version
# users that still explicitly call @workbook.apply_styles
@@ -418,18 +420,5 @@ require 'axlsx/workbook/worksheet/selection.rb'
str << '</workbook>'
end
- private
-
- # Utility method for performing a deep merge on a Hash
- def hash_deep_merge(first_hash, second_hash)
- first_hash.merge(second_hash) do |key, this_val, other_val|
- if this_val.is_a?(Hash) && other_val.is_a?(Hash)
- this_val.deep_merge(other_val, &block)
- else
- other_val
- end
- end
- end
-
end
end
diff --git a/lib/axlsx/workbook/worksheet/cell.rb b/lib/axlsx/workbook/worksheet/cell.rb
index 9ab93e61..125ca051 100644
--- a/lib/axlsx/workbook/worksheet/cell.rb
+++ b/lib/axlsx/workbook/worksheet/cell.rb
@@ -87,7 +87,6 @@ module Axlsx
# The index of the cellXfs item to be applied to this cell.
# @param [Hash] styles
# @see Axlsx::Styles
- require 'set' ### TODO: move to appropriate place
def add_style(style)
self.raw_style ||= {}
@@ -106,7 +105,6 @@ module Axlsx
wb = row.worksheet.workbook
- wb.styled_cells ||= Set.new
wb.styled_cells << self
end
diff --git a/lib/caxlsx.rb b/lib/caxlsx.rb
index 1dcc6005..a82d49fb 100644
--- a/lib/caxlsx.rb
+++ b/lib/caxlsx.rb
@@ -1,12 +1,2 @@
# encoding: UTF-8
require 'axlsx.rb'
-
-begin
- require "axlsx_styler"
-
- if defined?(AxlsxStyler)
- raise StandardError.new("Please remove `axlsx_styler` from your Gemfile, the associated functionality is now built-in to `caxlsx` directly.")
- end
-rescue LoadError
- # Do nothing, all good
-end