class FileWriter::Excel

Contains the functionalities of writing data in Excel

Public Class Methods

new(path, data, header) click to toggle source
Calls superclass method Connector::ExcelWriteConnector::new
# File lib/mylookup/writer.rb, line 10
def initialize(path, data, header)
    super(path)
    @data = data
    @header = header
end

Public Instance Methods

write() click to toggle source
# File lib/mylookup/writer.rb, line 16
def write
    puts "Writing Data in Excel"
    begin
        write_header
        write_data
    rescue StandardError => err
        puts "[Error]: Error occured while writing in Excel!!!"
        puts err
    end
end

Private Instance Methods

write_data() click to toggle source
# File lib/mylookup/writer.rb, line 31
def write_data
    @data.each_with_index do |d, i|
        @ws.add_cell(i+1, 0, d.to_s.upcase)
    end
    @wb.write(@path)
end
write_header() click to toggle source
# File lib/mylookup/writer.rb, line 27
def write_header
    @ws.add_cell(0, 0, @header)
end