personal-project/app/views/admin/projects/excel_format.xlsx.axlsx

105 lines
2.3 KiB
Plaintext
Raw Normal View History

2015-12-15 08:10:46 +00:00
# encoding: utf-8
wb = xlsx_package.workbook
wb.add_worksheet(name: "Project") do |sheet|
heading = sheet.styles.add_style(:b => true, :locked => true)
example = sheet.styles.add_style(:i => true)
row = ["user_id"]
row1 = [""]
row2 = [""]
row << "name"
row1 << ""
row2 << ""
row << t("personal_project.project_title") + " - " + t("en")
row1 << "textfield"
row2 << ""
row << t("personal_project.project_title") + " - " + t("zh_tw")
row1 << "textfield"
row2 << ""
row << t("personal_project.job_title") + " - " + t("en")
row1 << "textfield"
row2 << ""
row << t("personal_project.job_title") + " - " + t("zh_tw")
row1 << "textfield"
row2 << ""
row << t("personal_project.participator") + " - " + t("en")
row1 << "textfield"
row2 << ""
row << t("personal_project.participator") + " - " + t("zh_tw")
row1 << "textfield"
row2 << ""
row << t("personal_project.unit") + " - " + t("en")
row1 << "textfield"
row2 << ""
row << t("personal_project.unit") + " - " + t("zh_tw")
row1 << "textfield"
row2 << ""
row << t("personal_project.year")
row1 << "number"
row2 << "Example : 2015 or 2014 or 1987"
row << t("personal_project.language")
row1 << "select"
row2 << "en -> English, zh_tw -> Chinese"
row << t("personal_project.project_category")
row1 << "select"
t = ""
ProjectType.asc(:created_at).each_with_index do |jl,i|
2020-07-27 07:43:40 +00:00
next if jl.title.blank?
2015-12-15 08:10:46 +00:00
t = t + "#{i}" + " -> " + jl.title + ", "
end
if ProjectType.count > 0
t = t + " Example : 0"
else
t = "Leave this field blank"
end
row2 << t
row << t("personal_project.start_date")
row1 << "date"
row2 << "Format: YYYY/MM, Example: 2014/12"
row << t("personal_project.end_date")
row1 << "date"
row2 << "Format: YYYY/MM, Example: 2015/12"
row << t("personal_project.url")
row1 << "textfield"
row2 << "http://domain.com/path"
row << t("personal_project.keywords")
row1 << "textfield"
row2 << "Example: keyword1,keyword2"
row << t("personal_project.abstract")
row1 << "textarea"
row2 << ""
row << t("personal_project.note")
row1 << "textarea"
row2 << ""
sheet.add_row row, :style => heading
sheet.add_row row1
sheet.add_row row2, :style => example
User.where(:user_name.ne => "rulingcom").each do |user|
r = [user.user_name]
r << user.name
sheet.add_row r
end
end