rubyµÄExcel²Ù×÷
require 'win32ole'
excel = WIN32OLE::new('excel.Application')
workbook = excel.Workbooks.Open('E:\RubyApp\bmk.xls')
worksheet = workbook.Worksheets(1) #get hold of the first worksheet
worksheet.Select #bring it to the front -need sometimes to run macros, not for working with a worksheet from ruby
#excel['Visible'] = true #make visible, set to false to make invisible again. Don't need it to be visible for script to work
#value1=worksheet.Range('a12')['Value'] #get value of single cell
#puts value1
#data = worksheet.Range('a1:c12')['Value'] #read into 2D array
#data.each do |data1|
#data1.each do |data2|
#puts data2
#end
#end
line = '1'
while worksheet.Range("c#{line}")['Value']
line.succ!
end #line now holds row number of first empty row
puts line
#i=3
#puts worksheet.cells(i-1,1).text[8,16].to_i+1
#´¦Àí×¼¿¼Ö¤ºÅ£¬ÈÃËü×Ô¶¯Ôö¼Ó
#while i < line.to_i
for i in 3...line.to_i
worksheet.cells(i,1).value="00320501"+(worksheet.cells(i-1,1).text[8,15].to_i + 1).to_s
worksheet.cells(i,2).value="320501"+(worksheet.cells(i-1,2).text[6,13].to_i + 1).to_s
if worksheet.cells(i,7).text.length==18
worksheet.cells(i,5).value=worksheet.cells(i,7).text[6,8]
else
worksheet.cells(i,5).value="19"+worksheet.cells(i,7).text[6,6]
end
worksheet.range("h#{i}").value=worksheet.range("h#{i-1}").value.to_s
worksheet.range("i#{i}").value=worksheet.range("i#{i-1}").value.to_s
worksheet.range("k#{i}").value=worksheet.range("k#{i-1}").value.to_s
worksheet.range("l#{i}").value=worksheet.range("l#{i-1}").value.to_s
worksheet.range("o#{i}").value=worksheet.range("o#{i-1}").value.to_s
worksheet.range("p#{i}").value=worksheet.range("p#{i-1}").value.to_s
worksheet.range("q#{i}").value=worksheet.range(&
Ïà¹ØÎĵµ£º
ÓÃrubyн¨Ò»¸öexcelÎļþ£¬²¢ÇÒÉèÖÃһЩֵ¡£
require 'win32ole'
excel = WIN32OLE.new("excel.application")
excel.Visible = true
excel.WorkBooks.Open("d:\\test.xls")
excel.WorkSheets("sheet1").Activate
excel.Cells(2,3).value = "ÕÅÈý"
exce ......
±¾ÎĽéÉÜÁËRuby on RailsµÄÏêϸ°²×°²½Öè¡£ÎÄÖÐʹÓõÄRuby on Rails°æ±¾ÊÇ1.8.6-26¡£°²×°RubyÖ®ºó°²×°Rails£¬È»ºó¾Í¿ÉÒÔ´´½¨WebÓ¦Ó㬲¢ÔÚ±¾µØ²âÊÔÁË¡£
1¡¢°²×°ruby
²»ÓÃ˵ ÊÇÏÂÔØ°²×°°ü£ºhttp://rubyforge.org/frs/?group_id=167£¬×¢Òâ°æ±¾---º¦È˲»Ç³£¬ºóÃæ»á˵µ½£¬ÎÒϵÄÊÇ1.8.6-26
×°Íêºó£¬¿ÉÒÔÓÃruby -v ²âÊÔÊÇ·ñ° ......
¶©µ¥´¦Öã¬Ê×ÏÈÒªÓÐÒ»¸ö¶©µ¥µÄÏêϸÁÐ±í£¨°üÀ¨ÊýÁ¿£¬¼ÛǮɶµÄ£©ºÍÒ»¸ö¶ÔÓÚ¸öÈ˵ÄһЩÐÅÏ¢µÄÒ»¸ö±í¡£Òò¶øÎÒÃÇ´´ÔìÁ½¸öÄ£ÐÍ£¬line_item(ÁбíÏî),order(Áбí)£¬Æäºó±àÕßÈç´Î
/db/migrate xxx_create_order xxx_line_item
Ruby´úÂë
Ò».class CreateOrders < ActiveRecord::Migration
¶þ.def self.up
3. create_tabl ......
Ò»£¬Ruby°²×°£º
http://rubyforge.org/frs/download.php/29263/ruby186-26.exe
¹Ù·½ÍøÕ¾ÏÂÔØruby186-26(for windows)£¬Ä¬Èϰ²×°ruby£»
·¾¶c:\ruby
¶þ£¬railsÏÂÔØ°²×°£º
http://rubyforge.org/frs/download.php/29361/rails-2.0.2.zip
ÏÂÔØrails2.0.2.zip£¬½«ÆäcopyÖÁruby°²×°Â·¾¶£¬²¢¸ÄÃûΪrails.zip£»
³¢ÊÔ²»½âÑ¹Ö ......