Ruby Ruportʵ¼ù—±¨±í²ÎÊýʵÏÖ
´ËÀý×ÓÔÚ Ruby Ruportʵ¼ù—¼òµ¥±¨±íϵͳ ¼° Ruby Ruportʵ¼ù—ÖÐÎÄPDF±¨±íÖ®PRAWN µÄ»ù´¡ÉϽøÐÐÍêÉÆ£¬Ìí¼ÓÁ˶Ա¨±í²ÎÊýµÄÉè¼Æ¼°ÊµÏÖ¡£
Ò»¡¢´´½¨Êý¾Ý±íreport_parameters
create table report_parameters
(report_parameter_id integer not null auto_increment,
report_execute_id integer not null,
parameter_name varchar(240),
parameter_value varchar(240),
primary key "report_parameter_id")
ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8
¶þ¡¢ÐÞ¸Äcontrollers/ReportExecutionsController.rb
½«report_parametersµÄ»ù±¾²Ù×÷Ìí¼Óµ½report_executions½çÃæ
class ReportExecutionsController < ApplicationController
# GET /report_executions
# GET /report_executions.xml
Ruport::Formatter::Template.create(:simple) do |format|
eval("format.page = {:layout => :landscape}
format.grouping = {:style => :separated}
format.text = {:font_size => 20,:justification => :center}
format.table = {:font_size => 10,:heading_font_size => 10,:maximum_width => 720,:width => 720}
format.column = {:alignment => :center}
format.heading = {:alignment => :center,:bold => true,:font_size=>10}")
end
def show_report_details
report_execution = ReportExecution.find_by_execute_code(params[:report_execute_code])
@report_execute_code = params[:report_execute_code]
puts "======================ÏÔʾ±¨±í²ÎÊý======================="
@report_params = ReportExecution.find_by_sql("SELECT * from report_parameters WHERE report_execute_id= #{report_execution.report_execute_id}")
@report_params.each do |t|
puts "#{t.parameter_name}: #{t.parameter_value}"
end
puts"========================================================"
render :action => "execute"
end
def output_report
puts "----------------------------Output Report Code: #{params[:execution_code]}"
report_execution = ReportExecution.find_by_execute_code(params[:execution_code])
rep
Ïà¹ØÎĵµ£º
http://www.robertsosinski.com/2008/12/21/understanding-ruby-blocks-procs-and-lambdas/
Understanding Ruby Blocks, Procs and Lambdas
Blocks, Procs and lambdas (referred to as closures
in Computer Science) are one of the most powerful aspects of Ruby, and
also one of the most misunderstood. This ......
Prepare
1. Download 'OCI 1.x.x.rb' (it's VERY important - execution MUST be *.rb)
2. Download 'oci8lib.so'
Install
1. Copy 'OCI8.rb' to .../ruby/lib/ruby/site_ruby/1.8/DBD/OCI8
2. Copy 'oci8.rb' to .../ruby/lib/ruby/site_ruby/1.8
3. Copy 'oci8lib.so' to .../ruby/lib/ruby/site_ruby/1.8/i386-msv ......
¿ª·¢»·¾³
OS:WindowsXP
Ruby:Ruby1.8.7
Rails:Rails2.3.5
Mysql:Mysql5.0.9
IDE:Rubymine2.0.1
×¼±¸¹¤×÷£º
°²×°ÒÔÏÂgem°ü
gem install ruport
gem install ruport-util
gem install acts_as_reportable
±¾ÀýÉè¼ÆµÄ±¨±íϵͳ¹¤×÷ÔÀíÈçͼ£¨´¿Êô¸öÈËÀí½â£©£¬ÒÔProducts±íΪÀý£º
½ÓÏÂÀ´ÊµÏÖµÄÀý×Ó½«ÀûÓÃeval·½·¨ÊµÏ ......
FPDFÄÜÖ§³ÖPDFµÄÖÐÎÄ´òÓ¡£¬È»¶øÈ´´æÔÚ²»ÉٵIJ»ÈçÒâÖ®´¦£¬¾ÝÎÒÄ¿Ç°µÄʹÓã¬×ܽá³ö¼¸µã£º
1£©FPDFÌṩµÄPdf_Chinese×ÖÌ壬½«GBÕâÖÖ×ÖÌåдÈëÁË´úÂëÖУ¬ÈôÎÒÃÇÏ£ÍûÒýÈëÆäËûµÄÖÐÎÄ×ÖÌ壬Ôò²»ÄÜ·½±ãµØʹÓÃ
2£©FPDFÊä³öµÄÊý×Ö²¢²»ÃÀ¹Û£¬²»ÈçRuport::Formatter::PDF×Ô´øµÄ×ÖÌå
3£©FPDFÌṩµÄ·½·¨²¢²»¶à£¬¶ÔÓÚÒ»°ãµÄ±¨±í´òÓ¡£¬Óõ ......