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·½·¨ ......
%{String} ÓÃÓÚ´´½¨Ò»¸öʹÓÃË«ÒýºÅÀ¨ÆðÀ´µÄ×Ö·û´®
%Q{String} ÓÃÓÚ´´½¨Ò»¸öʹÓÃË«ÒýºÅÀ¨ÆðÀ´µÄ×Ö·û´®
%Q!Some String of “Characters”! <==> ” Some String of \”Characters\” “
%q{String} ÓÃÓÚ´´½¨Ò»¸öʹÓõ¥ÒýºÅÀ¨ÆðÀ´µÄ×Ö·û´®
%q!Som ......
¿ª·¢»·¾³
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·½·¨ÊµÏ ......
±¾ÀýÔÚ Ruby Ruportʵ¼ù—±¨±í²ÎÊýʵÏÖ µÄ»ù´¡ÉϽøÐиÄÔ죬ʵÏÖ±¨±íÖ´Ðж¨Òåʱ±¨±í²ÎÊýµÄÔö¡¢É¾¡¢¸Ä²Ù×÷
Ò»¡¢ÐÞ¸Äviews/report_executions/edit.html.erb
²»½öÏÔʾÔÚн¨±¨±íÖ´ÐÐʱ±£´æµÄ±¨±í²ÎÊý£¬»¹¿É¶¯Ì¬ÏÔʾʣÓàµÄ²ÎÊý£¨ÕâÀï¿ØÖƲÎÊý×î¶à¿É¶¨Òå5¸ö£©£¬ÕâÑù¿É±ÜÃâÒÅÍü¶¨Ò屨±í²ÎÊý»òÐèÒªÔö¼Ó±¨±í²ÎÊýµ ......