2017-04-11 06:10:01 +00:00
|
|
|
# encoding: utf-8
|
|
|
|
|
|
|
|
wb = xlsx_package.workbook
|
2017-04-11 10:43:22 +00:00
|
|
|
wb.add_worksheet(name: "WorkSheet1") do |sheet|
|
2017-04-11 06:10:01 +00:00
|
|
|
|
|
|
|
row = []
|
|
|
|
survey_questions.each_with_index do |question, i|
|
|
|
|
if question.type == 2 or question.type == 3 or question.type == 4
|
|
|
|
question.survey_question_options.each do |option|
|
2021-07-08 13:31:27 +00:00
|
|
|
row << "#{i+1}. #{question.title} - #{option.name}"
|
2017-04-11 06:10:01 +00:00
|
|
|
end
|
|
|
|
elsif question.type == 5
|
|
|
|
question.survey_question_options.each do |option|
|
|
|
|
question.survey_question_radiogroups.each do |radiogroup|
|
2021-07-08 13:31:27 +00:00
|
|
|
row << "#{i+1}. #{question.title} - #{option.name} - #{radiogroup.name}"
|
2017-04-11 06:10:01 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
else
|
2021-07-08 13:31:27 +00:00
|
|
|
row << "#{i+1}. #{question.title}"
|
2017-04-11 06:10:01 +00:00
|
|
|
end
|
2021-07-08 13:31:27 +00:00
|
|
|
if question.custom_option_new_option
|
|
|
|
row << "#{i+1}. #{question.title} - #{t('survey_question.use_custom_option')}"
|
2017-04-11 06:10:01 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
sheet.add_row row
|
2021-07-08 13:31:27 +00:00
|
|
|
wrap = wb.styles.add_style alignment: {wrap_text: true}
|
2017-04-11 06:10:01 +00:00
|
|
|
survey_answers.each do |answer|
|
|
|
|
answer_row = []
|
|
|
|
|
2021-07-08 13:31:27 +00:00
|
|
|
sheet.add_row answer.values.flatten, style: wrap
|
2017-04-11 06:10:01 +00:00
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|