Class: LiquidXlsx::Workbook
- Inherits:
-
Object
- Object
- LiquidXlsx::Workbook
- Defined in:
- lib/liquid_xlsx/workbook.rb
Overview
Represents the workbook and orchestrates rendering across all sheets.
Constant Summary collapse
- MAX_SHEET_NAME_LENGTH =
Maximum sheet name length in Excel.
31- FORBIDDEN_SHEET_NAME_CHARS =
Characters forbidden in Excel sheet names.
%r{[:/\\\?\*\[\]]}- SHEET_NAME_DEDUP_MAX =
Maximum deduplication attempts before giving up.
9999
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#package ⇒ Object
readonly
Returns the value of attribute package.
-
#shared_strings ⇒ Object
readonly
Returns the value of attribute shared_strings.
Instance Method Summary collapse
-
#initialize(package, options = {}) ⇒ Workbook
constructor
A new instance of Workbook.
-
#render(data) ⇒ Package
Render all worksheets with the given data.
Constructor Details
#initialize(package, options = {}) ⇒ Workbook
Returns a new instance of Workbook.
8 9 10 11 12 |
# File 'lib/liquid_xlsx/workbook.rb', line 8 def initialize(package, = {}) @package = package @options = @shared_strings = SharedStrings.new(package.shared_strings_xml) end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
6 7 8 |
# File 'lib/liquid_xlsx/workbook.rb', line 6 def @options end |
#package ⇒ Object (readonly)
Returns the value of attribute package.
6 7 8 |
# File 'lib/liquid_xlsx/workbook.rb', line 6 def package @package end |
#shared_strings ⇒ Object (readonly)
Returns the value of attribute shared_strings.
6 7 8 |
# File 'lib/liquid_xlsx/workbook.rb', line 6 def shared_strings @shared_strings end |
Instance Method Details
#render(data) ⇒ Package
Render all worksheets with the given data.
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/liquid_xlsx/workbook.rb', line 18 def render(data) all_image_ops = [] if @options[:dynamic_sheets] render_with_dynamic_sheets(data, all_image_ops) else render_existing_sheets(data, all_image_ops) end # Phase: build drawings from collected image ops build_drawings(all_image_ops) # Handle recalculation if @options[:recalculate_formulas] package.remove_calc_chain if package.calc_chain_xml package.set_recalculation_flags end package end |