里程碑添加导出功能
This commit is contained in:
parent
bb250af86c
commit
d385123a93
|
@ -131,11 +131,11 @@ class VersionsController < ApplicationController
|
|||
# all
|
||||
}
|
||||
format.api
|
||||
# format.xls {
|
||||
# @issues = @version.fixed_issues.visible.includes(:status, :tracker, :priority).reorder("#{Tracker.table_name}.position, #{Issue.table_name}.id").all
|
||||
# filename = "#{@version.name.to_s}_#{l(:label_issue_list_xls)}.xls"
|
||||
# send_data(issue_list_xls(@issues), :type => 'application/octet-stream', :filename => filename_for_content_disposition(filename))
|
||||
# }
|
||||
format.xls {
|
||||
@issues = @version.fixed_issues.visible.includes(:status, :tracker, :priority).reorder("#{Tracker.table_name}.position, #{Issue.table_name}.id").all
|
||||
filename = "#{@version.name.to_s}_#{l(:label_issue_list_xls)}.xls"
|
||||
send_data(issue_list_xls(@issues), :type => 'application/octet-stream', :filename => filename_for_content_disposition(filename))
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -263,6 +263,33 @@ class VersionsController < ApplicationController
|
|||
end
|
||||
|
||||
private
|
||||
def issue_list_xls issues
|
||||
xls_report = StringIO.new
|
||||
book = Spreadsheet::Workbook.new
|
||||
sheet1 = book.create_worksheet :name => "issues"
|
||||
blue = Spreadsheet::Format.new :color => :blue, :weight => :bold, :size => 10
|
||||
sheet1.row(0).default_format = blue
|
||||
sheet1.row(0).concat([l(:issue_xls_id),l(:issue_xls_tracker_id),l(:issue_xls_title),l(:issue_xls_description),l(:issue_xls_status),l(:issue_xls_assign),l(:issue_xls_priority),l(:issue_xls_author),l(:issue_xls_created_at),l(:milestone),l(:issue_xls_start),l(:issue_xls_due),l(:issue_xls_ratio)])
|
||||
count_row = 1
|
||||
issues.each do |issue|
|
||||
sheet1[count_row,0] = issue.id
|
||||
sheet1[count_row,1] = issue_tracker_change(issue.tracker_id)
|
||||
sheet1[count_row,2] = issue.subject
|
||||
sheet1[count_row,3] = (issue.description.gsub(/<\/?.*?>/,"")).html_safe
|
||||
sheet1[count_row,4] = issue_status_change(issue.status_id)
|
||||
sheet1[count_row,5] = issue.assigned_to.try(:show_name)
|
||||
sheet1[count_row,6] = issue_priority_change(issue.priority_id)
|
||||
sheet1[count_row,7] = issue.author.show_name
|
||||
sheet1[count_row,8] = issue.created_on.nil? ? issue.created_on : issue.created_on.strftime('%Y-%m-%d %H:%M:%S')
|
||||
sheet1[count_row,9] = issue.fixed_version.try(:name)
|
||||
sheet1[count_row,10] = issue.start_date.nil? ? issue.start_date : issue.start_date.strftime('%Y-%m-%d')
|
||||
sheet1[count_row,11] = issue.due_date.nil? ? issue.due_date : issue.due_date.strftime('%Y-%m-%d')
|
||||
sheet1[count_row,12] = issue_ratio_change(issue.done_ratio, issue.status_id)
|
||||
count_row += 1
|
||||
end
|
||||
book.write xls_report
|
||||
xls_report.string
|
||||
end
|
||||
|
||||
def retrieve_selected_tracker_ids(selectable_trackers, default_trackers=nil)
|
||||
if ids = params[:tracker_ids]
|
||||
|
|
Loading…
Reference in New Issue