# encoding: utf-8 wb = xlsx_package.workbook wb.add_worksheet(name: "Reservations") do |sheet| heading = sheet.styles.add_style(:b => true, :locked => true) type = sheet.styles.add_style(:i => true) wrap = sheet.styles.add_style alignment: {wrap_text: true} row = [ t("property_hire.hiring_person_name"), t("property_hire.hiring_person_number"), t("property_hire.hiring_person_email"), t("property_hire.period"), t("property_hire.recurring_interval"), t("property_hire.recurring_end_date"), t("property_hire.reason_for_hire"), t("property_hire.note_for_hire") ] fields_name = ["organization" ,"person_in_charge" , "tel_of_person_in_charge" , "department" , "contact_person" , "tel_of_contact_person" , "mobile_phone_of_contact_person" , "contact_person_Email" , "contact_person_department"] fields_name.each do |field_name| if(property[field_name]["enable"] == "1" rescue false) row << property.custom_text(field_name,"name") end end sheet.add_row row, :style => heading property.p_hires.asc(:created_at).each do |entry| row = [ entry.hirer_name, entry.hiring_person_number, entry.hiring_person_email, entry.period, entry.recurring_interval, entry.recurring_end_date, entry.reason_for_hire, entry.note_for_hire.html_safe ] entry.p_hire_field_values.each do |v| field_info = v.get_field_value rescue {} if field_info["title"].present? && !field_info["value"].nil? && !field_info["hint"] row << field_info["title"] + ": " + field_info["value"] end end sheet.add_row row, style: wrap end end