我想在rails上使用ruby生成Excel和PDF报告,但我在两个报告中都显示了24,278个条目,因此显示错误。如何解决这个错误。 控制器代码 - (适用于excel)
def from_date_wise_xls
@start = params[:day]
@end = params[:to_date]
@present = params[:present]
@employee_attendances = EmployeeAttendance.where(present: @present,day: @start..@end)
respond_to do |format|
format.xls {render template: 'employee_attendances/from_date_wise_xls.xls.erb'}
end
end
(对于PDF) -
def from_date_wise_pdf
@start = params[:day]
@end = params[:to_date]
@present = params[:present]
@employee_attendances = EmployeeAttendance.where(present: @present,day: @start..@end)
respond_to do |format|
format.html
format.pdf do
render :pdf => 'from_date_wise_pdf',
layout: '/layouts/pdf.html.erb',
:template => 'employee_attendances/from_date_wise_pdf.pdf.erb',
:orientation => 'Landscape', # default , Landscape
:page_height => 1000,
:dpi => '300',
:margin => {:top => 10, # default 10 (mm)
:bottom => 10,
:left => 20,
:right => 20},
:show_as_html => params[:debug].present?
end
end
end