易截截图软件、单文件、免安装、纯绿色、仅160KB

Ruby Ruport实践—Ruport::Formatter应用扩展

Ruport目前自带支持PDF,HTML,CSV,TXT格式输出,如果想打印.xml,.bat报表怎么办?
本例将以XML格式为例,实现Ruport::Formatter的另一种自定义应用。
Ruport的应用参考: Ruby Ruport实践—简单报表系统
注:其他格式的报表只需要修改renders对应的内容(如希望保存为.bat格式,将renders :xml改为renders :bat),模板输出内容均用
"output<<"方法进行输出即可
一、在ReportOutputController中添加xml格式
class ReportXml < Ruport::Formatter
renders :xml, :for => ReportOutputController
build :data_sheet do
eval(options[:outputContent])
end
end 
二、report_templates中定义为如下内容的模板
output<<"<products>"
data.each do |d|
output<<"<product>"
output<<"<title>#{d.title}</title><type>#{d.description}</type><price>#{d.price}</price>"
output<<"</product>"
end
output<<"</products>" 
注:为了测试方便,可将 "eval(options[:outputContent])"直接替换成模板内容
演示效果:


相关文档:

Ruby下解决oci8安装错误的问题

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 ......

Ruby中%的用法(百分号的用法)

%{String}  用于创建一个使用双引号括起来的字符串 
%Q{String} 用于创建一个使用双引号括起来的字符串 
%Q!Some String of “Characters”! <==> ” Some String of \”Characters\” “
%q{String} 用于创建一个使用单引号括起来的字符串 
%q!Som ......

ruby和watir学习常用网站整理

转自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 ......

Installing Ruby 1.8.6 from Source on Ubuntu

Installing Ruby from source is my preferred method, although in Ubuntu Feisty you can supposedly install it with apt-get install ruby
now. Here’s the essential packages needed to get a source build working right though and the process I just went through:
sudo apt-get install build-essentia ......

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, ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号