Sha256: 253c1cc2899a90ff8c6b39678464c6eb7dbb4f163b4f0f8ff34af17ad4908b56

Contents?: true

Size: 798 Bytes

Versions: 5

Compression:

Stored size: 798 Bytes

Contents

require 'axlsx'
module DocParser
  # The XLSXOutput class generates Microsoft Excel compatible .xlsx files
  # using the great axslx library
  # @see Output
  class XLSXOutput < Output
    # @!visibility private
    def open_file
      @package = Axlsx::Package.new
      @package.workbook.date1904 = false # Fix for OS X
      @sheet = @package.workbook.add_worksheet
      @file.close
    end

    def header
      write_row @header
    end

    def write_row(row)
      @sheet.add_row row
    end

    def footer
      unless @header.nil?
        @sheet.add_table "A1:#{@sheet.cells.last.r}", name: 'Data'
      end
      @package.serialize @filename
    end

    def rowcount
      if @header.nil?
        @sheet.rows.length
      else
        @sheet.rows.length - 1
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
docparser-0.1.4 lib/docparser/output/xlsx_output.rb
docparser-0.1.3 lib/docparser/output/xlsx_output.rb
docparser-0.1.2 lib/docparser/output/xlsx_output.rb
docparser-0.1.1 lib/docparser/output/xlsx_output.rb
docparser-0.1.0 lib/docparser/output/xlsx_output.rb