excel export styling
This commit is contained in:
@@ -1,33 +1,38 @@
|
||||
workbook = xlsx_package.workbook
|
||||
styles = workbook.styles
|
||||
|
||||
border_style = styles.add_style(
|
||||
border: { style: :thin, color: "000000", edges: [ :top, :bottom, :left, :right ] },
|
||||
alignment: { wrap_text: true, vertical: :top },
|
||||
sz: 10,
|
||||
name: "Arial"
|
||||
)
|
||||
|
||||
header_style = styles.add_style(
|
||||
b: true,
|
||||
border: { style: :thin, color: "000000", edges: [ :top, :bottom, :left, :right ] },
|
||||
alignment: { wrap_text: true, vertical: :top, horizontal: :center },
|
||||
bg_color: "EEEEEE",
|
||||
sz: 10,
|
||||
name: "Arial"
|
||||
)
|
||||
|
||||
workbook.add_worksheet(name: "Entries") do |sheet|
|
||||
sheet.add_row [
|
||||
"Category",
|
||||
"Finnish (fi)",
|
||||
"English (en)",
|
||||
"Swedish (sv)",
|
||||
"Norwegian (no)",
|
||||
"Russian (ru)",
|
||||
"German (de)",
|
||||
"Notes",
|
||||
"Verified",
|
||||
"Created At",
|
||||
"Updated At"
|
||||
]
|
||||
"Finnish", "English", "Swedish", "Norwegian", "Russian", "German"
|
||||
], style: header_style
|
||||
|
||||
@entries.find_each do |entry|
|
||||
sheet.add_row [
|
||||
entry.category,
|
||||
entry.fi,
|
||||
entry.en,
|
||||
entry.sv,
|
||||
entry.no,
|
||||
entry.ru,
|
||||
entry.de,
|
||||
entry.notes,
|
||||
entry.verified? ? "Yes" : "No",
|
||||
entry.created_at&.to_date,
|
||||
entry.updated_at&.to_date
|
||||
]
|
||||
entry.de
|
||||
], style: border_style
|
||||
end
|
||||
|
||||
sheet.column_widths 21.4, 21.4, 21.4, 21.4, 21.4, 21.4
|
||||
sheet.auto_filter = sheet.dimension.sqref
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user