excel export styling

This commit is contained in:
2026-01-22 20:36:43 +01:00
parent 95324a97cb
commit 35b87b5589
+24 -19
View File
@@ -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