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(&
相关文档:
def delVss(path)
if File.directory?(path)
for f in d = Dir.open(path)
fpath = File.join(path, f)
if(f!="."&&f!="..")
......
While looking for information on the subject, I looked into the ONLamp article Extending Ruby with C by Garrett Rooney, the Extending Ruby chapter in the Pickaxe, README.EXT (located at /usr/share/doc/ruby1.8-dev/README.EXT.gz on my Ubuntu system) and got some help from Kjetil.
The resulting file c ......
最近在看John E.Hopcroft,Rajeev Motwani,Jeffrey D.Ullman 三巨头写的Introduction to Automata Theory,Language,and Computation,想写一个Turing 机验证一下自己写的状态转移函数对不对。懒得很,网上搜了几个不错的。但Ruby Quiz 上的这个最简单。
162 Turing 机
问题描述
Quiz
description by James Edward Gray ......
<!--
/* Font Definitions */
@font-face
{font-family:宋体;
panose-1:2 1 6 0 3 1 1 1 1 1;
mso-font-alt:SimSun;
mso-font-charset:134;
mso-generic-font-family:auto;
mso-font-pitch:variable;
mso-font-signature:3 680460288 22 0 262145 0;}
@font-face
{font-family:"Cambria Mat ......