universal_table/app/views/admin/universal_tables/export_structure.xlsx.axlsx

57 lines
1.5 KiB
Plaintext

# encoding: utf-8
wb = xlsx_package.workbook
wb.add_worksheet(name: "Structure") do |sheet|
heading = sheet.styles.add_style(:b => true, :locked => true)
type = sheet.styles.add_style(:i => true)
row = []
row1 = []
row2 = []
@table.table_columns.asc(:order).each do |column|
case column.type
when "text"
@site_in_use_locales.sort.each do |locale|
row << column.title + " - " + t(locale.to_s)
row1 << column.key
row2 << column.type + "-#{locale}"
end
when "integer"
row << column.title
row1 << column.key
row2 << column.type
when "editor"
@site_in_use_locales.sort.each do |locale|
row << column.title + " - " + t(locale.to_s)
row1 << column.key
row2 << column.type + "-#{locale}"
end
when "image"
row << column.title
row1 << column.key
row2 << "Please leave this column blank. Upload the image manually."
when "date"
row << column.title
row1 << column.key
row2 << column.type + " : " + column.date_format.upcase
when "period"
row << column.title + "-From"
row1 << column.key
row2 << column.type + " : " + column.date_format.upcase + "-period_from"
row << column.title + "-To"
row1 << column.key
row2 << column.type + " : " + column.date_format.upcase + "-period_to"
when "file"
row << column.title
row1 << column.key
row2 << "Please leave this column blank. Upload the files manually."
end
end
sheet.add_row row, :style => heading
sheet.add_row row1
sheet.add_row row2, :style => type
end