Sha256: 1580f90c86f71cbab846ff0c99a2cf4745cd5bfee9f94bbfec3dd6bd1335e11d

Contents?: true

Size: 702 Bytes

Versions: 7

Compression:

Stored size: 702 Bytes

Contents

require 'writeexcel'

module Mondrian::REST::Formatters
  module XLS
    def self.call(result, env)
      qh = env['rack.request.query_hash']
      add_parents = qh['parents'] == 'true'
      debug = qh['debug'] == 'true'
      properties = qh['properties'] || []

      out = StringIO.new
      book = WriteExcel.new(out)
      sheet = book.add_worksheet

      Mondrian::REST::Formatters
        .tidy(result,
              add_parents: add_parents,
              debug: debug,
              properties: properties)
        .each_with_index do |row, i|
        row.each_with_index { |cell, j|
          sheet.write(i, j, cell)
        }
      end

      book.close
      out.string
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
mondrian-rest-0.7.6-java lib/mondrian_rest/formatters/excel.rb
mondrian-rest-0.7.5-java lib/mondrian_rest/formatters/excel.rb
mondrian-rest-0.7.4-java lib/mondrian_rest/formatters/excel.rb
mondrian-rest-0.7.3-java lib/mondrian_rest/formatters/excel.rb
mondrian-rest-0.7.2-java lib/mondrian_rest/formatters/excel.rb
mondrian-rest-0.7.1-java lib/mondrian_rest/formatters/excel.rb
mondrian-rest-0.7.0-java lib/mondrian_rest/formatters/excel.rb