diff options
| author | Weston Ganger <[email protected]> | 2022-09-29 20:45:39 -0700 |
|---|---|---|
| committer | Weston Ganger <[email protected]> | 2022-09-29 20:45:39 -0700 |
| commit | fd8366970d9cb3f5fb431ba6c40a2a2ac2737615 (patch) | |
| tree | 4e7fc2f0520d3a5cd4485d101b60a8280e624bb7 /lib/axlsx/workbook/worksheet/worksheet.rb | |
| parent | bcc88ca556b3b8527ba0ad56424f93ef170b9c31 (diff) | |
| download | caxlsx-fd8366970d9cb3f5fb431ba6c40a2a2ac2737615.tar.gz caxlsx-fd8366970d9cb3f5fb431ba6c40a2a2ac2737615.zip | |
Merge axlsx_styler gem into caxlsx
Diffstat (limited to 'lib/axlsx/workbook/worksheet/worksheet.rb')
| -rw-r--r-- | lib/axlsx/workbook/worksheet/worksheet.rb | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/lib/axlsx/workbook/worksheet/worksheet.rb b/lib/axlsx/workbook/worksheet/worksheet.rb index 921687c8..527d2e71 100644 --- a/lib/axlsx/workbook/worksheet/worksheet.rb +++ b/lib/axlsx/workbook/worksheet/worksheet.rb @@ -1,4 +1,7 @@ # encoding: UTF-8 + +require_relative "border_creator" + module Axlsx # The Worksheet class represents a worksheet in the workbook. @@ -560,6 +563,41 @@ module Axlsx cells.each { |cell| cell.style = style } end + # Set the style for cells in a specific column + # @param [String|Array] cell references + # @param styles TODO: how to specify this + def add_style(cell_refs, *styles) + if !cell_refs.is_a?(Array) + cell_refs = [cell_refs] + end + + cell_refs.each do |cell_ref| + item = self[cell_ref] + + cells = item.is_a?(Array) ? item : [item] + + cells.each do |cell| + styles.each do |style| + cell.add_style(style) + end + end + end + end + + # Set the style for cells in a specific column + # @param [String|Array] cell references + # @param [Hash|Symbol] options TODO: describe this + def add_border(cell_refs, options = :all) ### TODO: will we support the :all argument + if !cell_refs.is_a?(Array) + cell_refs = [cell_refs] + end + + cell_refs.each do |cell_ref| + cells = self[cell_ref] + Axlsx::BorderCreator.new(self, cells, options).draw + end + end + # Returns a sheet node serialization for this sheet in the workbook. def to_sheet_node_xml_string(str='') add_autofilter_defined_name_to_workbook |
