Created
August 27, 2010 12:15
-
-
Save kirushik/553248 to your computer and use it in GitHub Desktop.
Работа с xls из Руби
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'roo' # Надо установить библиотеку `gem install roo` | |
# Мне потребовалось дорешать зависимости руками: `gem install bones builder zip nokogiri spreadsheet google-spreadsheet-ruby spreadsheet-excel` | |
xls = Excel.new('http://www.nalog.ru/html/docs/svot/1nm2010.xls') # Эта строка автоматом загрузит xls-файл из веба и распарсит его в структуру | |
14.upto(22) do |line| | |
3.upto(7) do |cell| | |
print "#{xls.cell(line, cell)}\t" # Выведет фрагмент документа - строки с 14 по 22, колонки с 3 по 7 | |
end | |
print "\n" | |
end | |
xls.to_csv('~/somedata.csv') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment