Class: SentimentInsights::Export::ExcelExporter
- Inherits:
-
BaseExporter
- Object
- BaseExporter
- SentimentInsights::Export::ExcelExporter
- Defined in:
- lib/sentiment_insights/export/excel_exporter.rb
Instance Attribute Summary
Attributes inherited from BaseExporter
#analysis_type, #options, #result
Instance Method Summary collapse
Methods inherited from BaseExporter
Constructor Details
This class inherits a constructor from SentimentInsights::Export::BaseExporter
Instance Method Details
#export(filename = nil) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/sentiment_insights/export/excel_exporter.rb', line 13 def export(filename = nil) raise "rubyXL gem is required for Excel export" unless defined?(RubyXL) filename ||= generate_filename("xlsx") # Apply filters if specified filtered_result = apply_filters(@result) workbook = RubyXL::Workbook.new # Remove the default worksheet workbook.worksheets.delete_at(0) # Create worksheets based on analysis type and options create_responses_sheet(workbook, filtered_result) create_summary_sheet(workbook) if [:include_summary] create_segments_sheet(workbook) if [:include_segments] case analysis_type when :entities create_entities_sheet(workbook, filtered_result) when :key_phrases create_phrases_sheet(workbook, filtered_result) end workbook.write(filename) filename end |