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

57 lines
1.5 KiB
Plaintext
Raw Permalink Normal View History

# 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"
2015-12-18 07:33:43 +00:00
@site_in_use_locales.sort.each do |locale|
row << column.title + " - " + t(locale.to_s)
row1 << column.key
row2 << column.type + "-#{locale}"
end
2022-02-25 06:49:00 +00:00
when "integer"
row << column.title
row1 << column.key
row2 << column.type
when "editor"
2015-12-18 07:33:43 +00:00
@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"
2024-07-21 07:26:48 +00:00
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