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_
Ïà¹ØÎĵµ£º
%{String} ÓÃÓÚ´´½¨Ò»¸öʹÓÃË«ÒýºÅÀ¨ÆðÀ´µÄ×Ö·û´®
%Q{String} ÓÃÓÚ´´½¨Ò»¸öʹÓÃË«ÒýºÅÀ¨ÆðÀ´µÄ×Ö·û´®
%Q!Some String of “Characters”! <==> ” Some String of \”Characters\” “
%q{String} ÓÃÓÚ´´½¨Ò»¸öʹÓõ¥ÒýºÅÀ¨ÆðÀ´µÄ×Ö·û´®
%q!Som ......
Bignum
+ ¼Ó
- ¼õ
* ³Ë
/ ³ý
** Ö¸Êý²Ù×÷2**2 Òâ˼ÊÇ2µÄƽ·½
<=> ´óÓÚ, ......
¿ª·¢»·¾³
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·½·¨ÊµÏ ......
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 ......
RuportĿǰ×Ô´øÖ§³ÖPDF,HTML,CSV,TXT¸ñʽÊä³ö£¬Èç¹ûÏë´òÓ¡.xml£¬.bat±¨±íÔõô°ì£¿
±¾Àý½«ÒÔXML¸ñʽΪÀý£¬ÊµÏÖRuport::FormatterµÄÁíÒ»ÖÖ×Ô¶¨ÒåÓ¦Óá£
RuportµÄÓ¦Óòο¼£º Ruby Ruportʵ¼ù—¼òµ¥±¨±íϵͳ
×¢£ºÆäËû¸ñʽµÄ±¨±íÖ»ÐèÒªÐÞ¸Ärenders¶ÔÓ¦µÄÄÚÈÝ£¨ÈçÏ£Íû±£´æÎª.bat¸ñʽ£¬½«renders :xml¸ÄΪrenders :bat£©£¬ ......