Syntax error, unexpected keyword_ensure, expecting keyword_end

#1

in my report.xlsx.axlsx file contains below code
wb = xlsx_package.workbook

headers = [“Index No”, “Cus/Sup Name”, “Short Name”, “Account Number”, “Customer Code”, “Industry Type”, “Organization Type” , “VAT Number”, “SVAT Number”, “Account Manager”, “Business Reg. No”, “Address Type”, “Address”, “Active”, “Goodwill Status” , “Credit Allow” , “Credit Period Days” , “Website” , “Description” , “Created At” , “Created By”]

wb.add_worksheet(name: “Customer Supplier Report”) do |sheet|
sheet.add_row headers

@customer_reports.each_with_index do |db, index|
customer_supplier_array =

customer_supplier_array = [ (index+1), db.name, db.short_name, db.account.account_no, db.code, db.account.industry_name, db.org_name , db.account.vat_number, db.account.svat_no, db.account.get_account_manager, db.account.business_registration_no, db.address.addressable_type , db.address.try(:full_address) ,db.account.active , db.account.goodwill_status , db.account.credit_allow , db.account.credit_period_day, db.web_site, db.description , db.account.created_at.to_datetime.strftime(INOCRM_CONFIG[“short_date_format”]), db.account.created_user.full_name]

if db.addresses.any?{|a| a.primary_address.present? }
db.addresses.each do |address|
if address.primary_address
customer_supplier_array << address.addressable_type
customer_supplier_array << address.try(:full_address)
else
customer_supplier_array << " "
customer_supplier_array << " "

customer_supplier_array << db.account.active
customer_supplier_array << db.account.goodwill_status
customer_supplier_array << db.account.credit_allow
customer_supplier_array << db.account.credit_period_day
customer_supplier_array << db.web_site
customer_supplier_array << db.description
customer_supplier_array << db.account.created_at.to_datetime.strftime(INOCRM_CONFIG[“short_date_format”])
customer_supplier_array << db.account.created_user.full_name

sheet.add_row customer_supplier_array
end
end

Actual result displaying:
Completed 500 Internal Server Error in 60ms (ActiveRecord: 26.3ms)

SyntaxError (/home/anuja/Inova_projects/customer_supplier_report.xlsx.axlsx:38: syntax error, unexpected keyword_ensure, expecting keyword_end

Please help Thank u

#2
wb = xlsx_package.workbook

headers = ['Index No', 'Cus/Sup Name', 'Short Name', 'Account Number', 'Customer Code', 'Industry Type', 'Organization Type', 'VAT Number', 'SVAT Number', 'Account Manager', 'Business Reg. No', 'Address Type', 'Address', 'Active', 'Goodwill Status', 'Credit Allow', 'Credit Period Days', 'Website', 'Description', 'Created At', 'Created By']

wb.add_worksheet(name: 'Customer Supplier Report') do |sheet|
  sheet.add_row headers

  @customer_reports.each_with_index do |db, index|
    customer_supplier_array =

      customer_supplier_array = [(index + 1), db.name, db.short_name, db.account.account_no, db.code, db.account.industry_name, db.org_name, db.account.vat_number, db.account.svat_no, db.account.get_account_manager, db.account.business_registration_no, db.address.addressable_type, db.address.try(:full_address), db.account.active, db.account.goodwill_status, db.account.credit_allow, db.account.credit_period_day, db.web_site, db.description, db.account.created_at.to_datetime.strftime(INOCRM_CONFIG['short_date_format']), db.account.created_user.full_name]

    next unless db.addresses.any? {|a| a.primary_address.present?}
    db.addresses.each do |address|
      if address.primary_address
        customer_supplier_array << address.addressable_type
        customer_supplier_array << address.try(:full_address)
      else
        customer_supplier_array << ' '
        customer_supplier_array << ' '

        customer_supplier_array << db.account.active
        customer_supplier_array << db.account.goodwill_status
        customer_supplier_array << db.account.credit_allow
        customer_supplier_array << db.account.credit_period_day
        customer_supplier_array << db.web_site
        customer_supplier_array << db.description
        customer_supplier_array << db.account.created_at.to_datetime.strftime(INOCRM_CONFIG['short_date_format'])
        customer_supplier_array << db.account.created_user.full_name

        sheet.add_row customer_supplier_array
      end
    end
  end
end