Class: ExcelWriter
- Inherits:
-
Object
- Object
- ExcelWriter
- Defined in:
- lib/makesheets/writer.rb
Overview
Container for Excel writing functionalities
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#data_shtcols ⇒ Object
readonly
Returns the value of attribute data_shtcols.
Instance Method Summary collapse
-
#initialize(filename, reader, shtcol, prefix) ⇒ ExcelWriter
constructor
:notnew:.
-
#write ⇒ Object
Executes Write action.
Constructor Details
#initialize(filename, reader, shtcol, prefix) ⇒ ExcelWriter
:notnew:
7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/makesheets/writer.rb', line 7 def initialize(filename, reader, shtcol, prefix) #:notnew: @filename = filename @data = reader.data @headers = reader.headers @data_shtcols = reader.data_shtcols @shtcol = shtcol @prefix = prefix @is_header_written = {} @wb = RubyXL::Workbook.new @main_sht = @wb.worksheets[0] end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
5 6 7 |
# File 'lib/makesheets/writer.rb', line 5 def data @data end |
#data_shtcols ⇒ Object (readonly)
Returns the value of attribute data_shtcols.
5 6 7 |
# File 'lib/makesheets/writer.rb', line 5 def data_shtcols @data_shtcols end |
Instance Method Details
#write ⇒ Object
Executes Write action
20 21 22 23 24 25 26 27 |
# File 'lib/makesheets/writer.rb', line 20 def write puts "[Info]: Writing headers in main sheet..." write_header(@main_sht) # Write header in main sheet puts "[Info]: Core data writing initiated" write_data @wb.write(@filename) puts "[Info]: Result file has been written to #{@filename}" end |