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

ruby xml excel

require 'win32ole'
fns = Dir.glob("*.xls")
application = WIN32OLE.new("excel.application") 
application.visible = TRUE
f = File.new('errorCauseEN.xml','w')
f.puts('<?xml version="1.0" encoding="utf-8"?>')
f.puts('<!-- edited with XMLSPY v5 U (http://www.xmlspy.com) by et8 (et8) -->')
f.puts('<Category>')
fns.each do |file|
 workbook = application.WorkBooks.Open(Dir.pwd + '/' + file)
 sheet = workbook.WorkSheets(2)
 sheet.Activate
 i = 2
 
 loop do
  break if !sheet.Range('A'+ i.to_s).Value
  
  break if !sheet.Range('C'+ i.to_s).Value
  
  errname = sheet.Range('A'+ i.to_s).Value.to_s.hex.to_i.to_s.strip
  
  valuename = sheet.Range('C'+ i.to_s).Value.strip
  
  valuename.gsub!(/\"/,'\'')
  
  f.puts(' '*4 + '<ErrorCode name="' + errname + '" value="' + valuename +'"/>')
   
  i = i + 1
 end
 
 puts file.to_s + ' is OK!'
 workbook.close(0)
end
f.puts('</Category>')
f.close
application.Quit()
#workbook = application.WorkBooks.Open('D:/ErrorCase/TR_ErrCode.xls')
--------------------------------------------------------------------------
require 'win32ole'
require 'rexml/document'
include REXML
include REXML::
#fns = Dir.glob("*.xls")
#
application = WIN32OLE.new("excel.application") 
#
application.visible = TRUE
#
#fns.each do |file|
# workbook = application.WorkBooks.Open(Dir.pwd + '/' + file)

#end
#
f = File.new('errorC.xml','w')
doc = Document.new('<Category />')
workbook = application.WorkBooks.Open('D:/ErrorCase/TR_ErrCode.xls')
sheet = workbook.WorkSheets(2)
sheet.Activate
i = 2
loop do
 break if !sheet.Range('A'+ i.to_s).Value
 
 ec = Element.new('ErrorCode')
 
 ec.add_attribute('name',sheet.Range('A'+ i.to_s).Value.to_s.hex.to_


相关文档:

Watir 语法(Web Application Testing in Ruby)

Watir 语法(Web Application Testing in Ruby)
# watir的安装
watie的安装请查看 -> Ruby library的安装
# 使用Watir工具,需要在脚本中加上
require 'watir'
# 创建一个IE的实例
ie = Watir::IE.new
或者在创建的同时直接转到页面
ie = Watir::IE.start('http://www.text.com/')
Watir使用start方法 ......

RUBY实践—Ruby Report之Ruport简单应用

Ruport官方网站:http://www.rubyreports.org/
本例中将介绍Ruby报表的简单开发
开发环境
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
二、创建数据库
  datab ......

ruby 字符串 理解 "" ''

ruby中单引号和双引号的意义有所不同,双引号包围的字符作变量替换,单引号包围的变量不做替换
也可以使用 %q 和 %Q 来生成字符串对象。%q 相当于单引号,%Q相当于双引号。
举例如下:
irb(main):010:0> "show trsult: #{1*3}"
=> "show trsult: 3"
irb(main):011:0> 'show trsult: #{1*3}'
=> "show trs ......

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实践—Ruport::Formatter应用扩展

Ruport目前自带支持PDF,HTML,CSV,TXT格式输出,如果想打印.xml,.bat报表怎么办?
本例将以XML格式为例,实现Ruport::Formatter的另一种自定义应用。
Ruport的应用参考: Ruby Ruport实践—简单报表系统
注:其他格式的报表只需要修改renders对应的内容(如希望保存为.bat格式,将renders :xml改为renders :bat), ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号