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.cnblogs.com/watir/archive/2009/04/25/1443440.html
ruby文件从命令行中接收参数
在命令行方法执行ruby文件时,需要从命令行中传入参数,可以使用全局变量:ARGV
如有ruby 文件test.rb,内容如下:
1 def hello(a)
2 puts a
3 end
4
5 ......
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 ......
转自51testing.com, 原见:http://bbs.51testing.com/thread-171535-1-1.html http://swik.net/Watir+Programming
http://www.pragprog.com/ #很多好的源码哦
http://docs.rubygems.org/ #rubygems
http://www.fxruby.org/ #fxruby
http://groups.google.com/group/watir-general/topics #goog ......
Update: This post is outdated. All in one installer for 1.9
is ready now, you should use it if you need 1.9 on windows. Get it here
http://rubyforge.org/frs/?group_id=167
Ruby has “all-in-one” installer for Windows, but it is outdated. As
of May 2009, Ruby 1.9.1 is released, ......
1. 安装Cygwin
运行Cygwin的安装程序。从文见包的的列表中,在DEV里面,确定要选择
• Ruby
• gcc
• subversion
你需要使用gcc来建立Cygwin版本的MySQL.
2. 在windows上面安装MYSQL:
download MySQL 5.0 Windows Installer
3. & ......