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的安装
watie的安装请查看 -> Ruby library的安装
# 使用Watir工具,需要在脚本中加上
require 'watir'
# 创建一个IE的实例
ie = Watir::IE.new
或者在创建的同时直接转到页面
ie = Watir::IE.start('http://www.text.com/')
Watir使用start方法 ......
Bignum
+ 加
- 减
* 乘
/ 除
** 指数操作2**2 意思是2的平方
<=> 大于, ......
1、安装ubuntu
一路next,记住安装英文版。待安装完毕后,首先选择“软件源”,系统--系统管理-软件源,国内一般选择的是:http://ubuntu.cn99.com/ubuntu;接着安装中文包,选择软件源就是为了下载软件的速度更快,安装完成后重启ubuntu,重启后会提示是否改变某些文件夹名称,选择“否”,防止系统对 ......
本文转自:
http://hi.baidu.com/24xinhui/blog/item/9f52dd34382e11325ab5f553.html
ruby-语法
2009年06月20日 星期六 上午 00:21
http://www.blogjava.net/xxllnnn/archive/2009/01/18/251762.html
http://www.cnblogs.com/cnblogsfans/archive/2009/01/24/1380804.html
__setobj__ (2009-7-14)
&nbs ......