2012年8月20日

Ruby文件操作

摘要: 一、新建文件 f=File.new(File.join("C:","Test.txt"), "w+") f.puts("I am Jack") f.puts("Hello World")文件模式"r" :Read-only. Starts at beginning of file (default mode)."r+" :Read-write. Starts at beginning of file."w" :Write-only. T 阅读全文

posted @ 2012-08-20 14:08 张飞_ 阅读(17039) 评论(0) 推荐(0)

ruby操作excel文件

摘要: 使用ruby来操作excel文件首先需要在脚本里包含以下语句require 'win32ole'把win32ole包含进来后,就可以通过和windows下的excel api进行交互来对excel文件进行读写了.打开excel文件,对其中的sheet进行访问:excel = WIN32OLE::new('excel.Application')workbook = excel.Workbooks.Open('c:\examples\spreadsheet.xls')worksheet = workbook.Worksheets(1) #定位到第一个 阅读全文

posted @ 2012-08-20 12:09 张飞_ 阅读(5590) 评论(0) 推荐(0)

导航