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(&
相关文档:
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) ......
过程如下:
1、ruby下载一键安装:
http://rubyforge.org/frs/download.php/29263/ruby186-26.exe
ruby -v 显示版本,安装成功
2、下载rubygems安装:
http://rubyforge.org/frs/download.php/60719/rubygems-1.3.5.zip
解压,ruby setup.rb
gem -v 显示版本,安装成功
3、下载rails的 gem 安装(gem install ......
#include < ruby.h > //
static int id_sum;
int Values[] = {5, 10 ,15,-1,20,0};
static VALUE wrap_sum(VALUE args)
{
VALUE * values = (VALUE *) args;
VALUE summer = values[0];
VALUE max = values[1];
return rb_funcall(summer,id_sum,1,max);
}
static VALUE ......
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 ......