Class: Xport::Xlsxtream::Formatter
- Inherits:
-
Object
- Object
- Xport::Xlsxtream::Formatter
- Defined in:
- lib/xport/formatters/xlsxtream.rb
Instance Attribute Summary collapse
-
#export ⇒ Object
readonly
Returns the value of attribute export.
-
#workbook ⇒ Object
readonly
Returns the value of attribute workbook.
Instance Method Summary collapse
- #add_row(worksheet, row) ⇒ Object (also: #add_header_row)
- #add_worksheet(&block) ⇒ Object
- #column_widths(worksheet, *widths) ⇒ Object
-
#initialize(export) ⇒ Formatter
constructor
A new instance of Formatter.
- #merge_header_cells(worksheet, range) ⇒ Object
- #to_file ⇒ Object
Constructor Details
#initialize(export) ⇒ Formatter
Returns a new instance of Formatter.
21 22 23 24 25 |
# File 'lib/xport/formatters/xlsxtream.rb', line 21 def initialize(export) @io = StringIO.new @workbook = ::Xlsxtream::Workbook.new(@io) @io.rewind end |
Instance Attribute Details
#export ⇒ Object (readonly)
Returns the value of attribute export.
17 18 19 |
# File 'lib/xport/formatters/xlsxtream.rb', line 17 def export @export end |
#workbook ⇒ Object (readonly)
Returns the value of attribute workbook.
17 18 19 |
# File 'lib/xport/formatters/xlsxtream.rb', line 17 def workbook @workbook end |
Instance Method Details
#add_row(worksheet, row) ⇒ Object Also known as: add_header_row
37 38 39 40 |
# File 'lib/xport/formatters/xlsxtream.rb', line 37 def add_row(worksheet, row) values = row.map { |v| v.is_a?(Xport::Cell) ? v.value : v } worksheet << values end |
#add_worksheet(&block) ⇒ Object
33 34 35 |
# File 'lib/xport/formatters/xlsxtream.rb', line 33 def add_worksheet(&block) workbook.write_worksheet('Sheet1', use_shared_strings: true, &block) end |
#column_widths(worksheet, *widths) ⇒ Object
44 |
# File 'lib/xport/formatters/xlsxtream.rb', line 44 def column_widths(worksheet, *widths); end |
#merge_header_cells(worksheet, range) ⇒ Object
43 |
# File 'lib/xport/formatters/xlsxtream.rb', line 43 def merge_header_cells(worksheet, range); end |
#to_file ⇒ Object
27 28 29 30 31 |
# File 'lib/xport/formatters/xlsxtream.rb', line 27 def to_file workbook.close @io.rewind @io end |