roo 1.10.1 → 1.10.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +2 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +38 -0
- data/History.txt +4 -4
- data/License.txt +20 -0
- data/Manifest.txt +68 -0
- data/README.markdown +109 -0
- data/Rakefile +5 -4
- data/bin/roo +0 -0
- data/examples/roo_soap_client.rb +53 -0
- data/examples/roo_soap_server.rb +29 -0
- data/examples/write_me.rb +33 -0
- data/lib/roo.rb +20 -61
- data/lib/roo/csv.rb +13 -11
- data/lib/roo/excel.rb +108 -219
- data/lib/roo/excel2003xml.rb +312 -0
- data/lib/roo/excelx.rb +205 -341
- data/lib/roo/generic_spreadsheet.rb +371 -268
- data/lib/roo/google.rb +64 -54
- data/lib/roo/openoffice.rb +101 -156
- data/lib/roo/roo_rails_helper.rb +5 -5
- data/lib/roo/worksheet.rb +18 -0
- data/roo.gemspec +43 -0
- data/scripts/txt2html +67 -0
- data/test/all_ss.rb +8 -10
- data/test/{1900_base.xls → files/1900_base.xls} +0 -0
- data/test/{1904_base.xls → files/1904_base.xls} +0 -0
- data/test/{Bibelbund.csv → files/Bibelbund.csv} +0 -0
- data/test/{Bibelbund.ods → files/Bibelbund.ods} +0 -0
- data/test/{Bibelbund.xls → files/Bibelbund.xls} +0 -0
- data/test/{Bibelbund.xlsx → files/Bibelbund.xlsx} +0 -0
- data/test/files/Bibelbund.xml +62518 -0
- data/test/{Bibelbund1.ods → files/Bibelbund1.ods} +0 -0
- data/test/{Pfand_from_windows_phone.xlsx → files/Pfand_from_windows_phone.xlsx} +0 -0
- data/test/files/bad_excel_date.xls +0 -0
- data/test/{bbu.ods → files/bbu.ods} +0 -0
- data/test/{bbu.xls → files/bbu.xls} +0 -0
- data/test/{bbu.xlsx → files/bbu.xlsx} +0 -0
- data/test/files/bbu.xml +152 -0
- data/test/{bode-v1.ods.zip → files/bode-v1.ods.zip} +0 -0
- data/test/{bode-v1.xls.zip → files/bode-v1.xls.zip} +0 -0
- data/test/{boolean.ods → files/boolean.ods} +0 -0
- data/test/{boolean.xls → files/boolean.xls} +0 -0
- data/test/{boolean.xlsx → files/boolean.xlsx} +0 -0
- data/test/files/boolean.xml +112 -0
- data/test/{borders.ods → files/borders.ods} +0 -0
- data/test/{borders.xls → files/borders.xls} +0 -0
- data/test/{borders.xlsx → files/borders.xlsx} +0 -0
- data/test/files/borders.xml +144 -0
- data/test/{bug-row-column-fixnum-float.xls → files/bug-row-column-fixnum-float.xls} +0 -0
- data/test/files/bug-row-column-fixnum-float.xml +127 -0
- data/test/{comments.ods → files/comments.ods} +0 -0
- data/test/{comments.xls → files/comments.xls} +0 -0
- data/test/{comments.xlsx → files/comments.xlsx} +0 -0
- data/test/{csvtypes.csv → files/csvtypes.csv} +0 -0
- data/test/{datetime.ods → files/datetime.ods} +0 -0
- data/test/{datetime.xls → files/datetime.xls} +0 -0
- data/test/{datetime.xlsx → files/datetime.xlsx} +0 -0
- data/test/files/datetime.xml +142 -0
- data/test/{datetime_floatconv.xls → files/datetime_floatconv.xls} +0 -0
- data/test/files/datetime_floatconv.xml +148 -0
- data/test/{dreimalvier.ods → files/dreimalvier.ods} +0 -0
- data/test/{emptysheets.ods → files/emptysheets.ods} +0 -0
- data/test/{emptysheets.xls → files/emptysheets.xls} +0 -0
- data/test/{emptysheets.xlsx → files/emptysheets.xlsx} +0 -0
- data/test/files/emptysheets.xml +105 -0
- data/test/files/excel2003.xml +21140 -0
- data/test/{false_encoding.xls → files/false_encoding.xls} +0 -0
- data/test/files/false_encoding.xml +132 -0
- data/test/{formula.ods → files/formula.ods} +0 -0
- data/test/{formula.xls → files/formula.xls} +0 -0
- data/test/{formula.xlsx → files/formula.xlsx} +0 -0
- data/test/files/formula.xml +134 -0
- data/test/files/formula_parse_error.xls +0 -0
- data/test/files/formula_parse_error.xml +1833 -0
- data/test/{formula_string_error.xlsx → files/formula_string_error.xlsx} +0 -0
- data/test/{html-escape.ods → files/html-escape.ods} +0 -0
- data/test/{matrix.ods → files/matrix.ods} +0 -0
- data/test/{matrix.xls → files/matrix.xls} +0 -0
- data/test/{named_cells.ods → files/named_cells.ods} +0 -0
- data/test/{named_cells.xls → files/named_cells.xls} +0 -0
- data/test/{named_cells.xlsx → files/named_cells.xlsx} +0 -0
- data/test/{no_spreadsheet_file.txt → files/no_spreadsheet_file.txt} +0 -0
- data/test/{numbers1.csv → files/numbers1.csv} +0 -0
- data/test/{numbers1.ods → files/numbers1.ods} +0 -0
- data/test/{numbers1.xls → files/numbers1.xls} +0 -0
- data/test/{numbers1.xlsx → files/numbers1.xlsx} +0 -0
- data/test/files/numbers1.xml +312 -0
- data/test/{only_one_sheet.ods → files/only_one_sheet.ods} +0 -0
- data/test/{only_one_sheet.xls → files/only_one_sheet.xls} +0 -0
- data/test/{only_one_sheet.xlsx → files/only_one_sheet.xlsx} +0 -0
- data/test/files/only_one_sheet.xml +67 -0
- data/test/{paragraph.ods → files/paragraph.ods} +0 -0
- data/test/{paragraph.xls → files/paragraph.xls} +0 -0
- data/test/{paragraph.xlsx → files/paragraph.xlsx} +0 -0
- data/test/files/paragraph.xml +127 -0
- data/test/{prova.xls → files/prova.xls} +0 -0
- data/test/{ric.ods → files/ric.ods} +0 -0
- data/test/{simple_spreadsheet.ods → files/simple_spreadsheet.ods} +0 -0
- data/test/{simple_spreadsheet.xls → files/simple_spreadsheet.xls} +0 -0
- data/test/{simple_spreadsheet.xlsx → files/simple_spreadsheet.xlsx} +0 -0
- data/test/files/simple_spreadsheet.xml +225 -0
- data/test/{simple_spreadsheet_from_italo.ods → files/simple_spreadsheet_from_italo.ods} +0 -0
- data/test/{simple_spreadsheet_from_italo.xls → files/simple_spreadsheet_from_italo.xls} +0 -0
- data/test/files/simple_spreadsheet_from_italo.xml +242 -0
- data/test/{so_datetime.csv → files/so_datetime.csv} +0 -0
- data/test/{style.ods → files/style.ods} +0 -0
- data/test/{style.xls → files/style.xls} +0 -0
- data/test/{style.xlsx → files/style.xlsx} +0 -0
- data/test/files/style.xml +154 -0
- data/test/{time-test.csv → files/time-test.csv} +0 -0
- data/test/{time-test.ods → files/time-test.ods} +0 -0
- data/test/{time-test.xls → files/time-test.xls} +0 -0
- data/test/{time-test.xlsx → files/time-test.xlsx} +0 -0
- data/test/files/time-test.xml +131 -0
- data/test/{type_excel.ods → files/type_excel.ods} +0 -0
- data/test/{type_excel.xlsx → files/type_excel.xlsx} +0 -0
- data/test/{type_excelx.ods → files/type_excelx.ods} +0 -0
- data/test/{type_excelx.xls → files/type_excelx.xls} +0 -0
- data/test/{type_openoffice.xls → files/type_openoffice.xls} +0 -0
- data/test/{type_openoffice.xlsx → files/type_openoffice.xlsx} +0 -0
- data/test/{whitespace.ods → files/whitespace.ods} +0 -0
- data/test/{whitespace.xls → files/whitespace.xls} +0 -0
- data/test/{whitespace.xlsx → files/whitespace.xlsx} +0 -0
- data/test/files/whitespace.xml +184 -0
- data/test/test_generic_spreadsheet.rb +257 -0
- data/test/test_helper.rb +167 -27
- data/test/test_roo.rb +1178 -930
- data/website/index.html +385 -0
- data/website/index.txt +423 -0
- data/website/javascripts/rounded_corners_lite.inc.js +285 -0
- data/website/stylesheets/screen.css +130 -0
- data/website/template.rhtml +48 -0
- metadata +151 -121
- data/README.txt +0 -110
- data/lib/roo/.csv.rb.swp +0 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
roo (1.10.1)
|
5
|
+
nokogiri (>= 1.5.2)
|
6
|
+
rubyzip (>= 0.9.6.1)
|
7
|
+
spreadsheet (> 0.6.4)
|
8
|
+
|
9
|
+
GEM
|
10
|
+
remote: http://rubygems.org/
|
11
|
+
specs:
|
12
|
+
bones (3.8.0)
|
13
|
+
little-plugger (~> 1.1.3)
|
14
|
+
loquacious (~> 1.9.1)
|
15
|
+
rake (>= 0.8.7)
|
16
|
+
little-plugger (1.1.3)
|
17
|
+
loquacious (1.9.1)
|
18
|
+
nokogiri (1.5.5)
|
19
|
+
nokogiri (1.5.5-java)
|
20
|
+
rake (0.9.2.2)
|
21
|
+
ruby-ole (1.2.11.4)
|
22
|
+
rubyzip (0.9.9)
|
23
|
+
shoulda (3.0.1)
|
24
|
+
shoulda-context (~> 1.0.0)
|
25
|
+
shoulda-matchers (~> 1.0.0)
|
26
|
+
shoulda-context (1.0.0)
|
27
|
+
shoulda-matchers (1.0.0)
|
28
|
+
spreadsheet (0.7.3)
|
29
|
+
ruby-ole (>= 1.0)
|
30
|
+
|
31
|
+
PLATFORMS
|
32
|
+
java
|
33
|
+
ruby
|
34
|
+
|
35
|
+
DEPENDENCIES
|
36
|
+
bones (>= 3.8.0)
|
37
|
+
roo!
|
38
|
+
shoulda (~> 3.0)
|
data/History.txt
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
* 2 bugfixes
|
4
4
|
* forgot dependency 'rubyzip'
|
5
|
-
* at least one external application does create xlsx-files with different internal file names which differ from the original file names of Excel. Solution: ignore lower-/upper case in file names.
|
5
|
+
* at least one external application does create xlsx-files with different internal file names which differ from the original file names of Excel. Solution: ignore lower-/upper case in file names.
|
6
6
|
|
7
7
|
== 1.10.0 2011-10-10
|
8
8
|
|
@@ -11,7 +11,7 @@
|
|
11
11
|
* Openoffice, Libreoffice: new method 'labels'
|
12
12
|
* Excelx: implemented all methods concerning labels
|
13
13
|
* Openoffice, Excelx: new methods concerning comments (comment, comment? and comments)
|
14
|
-
|
14
|
+
|
15
15
|
* 2 bugfixes
|
16
16
|
* XLSX: some cells were not recognized correctly from a spreadsheet file from a windows mobile phone.
|
17
17
|
* labels: Moved to a separate methode. There were problems if there was an access to a label before read_cells were called.
|
@@ -51,11 +51,11 @@
|
|
51
51
|
* 1 enhancement
|
52
52
|
* removed gem 'builder'. Functionality goes to gem 'nokogiri'.
|
53
53
|
* 3 bugfixes
|
54
|
-
* Excel: remove temporary files if spreadsheed-file is not an excel file
|
54
|
+
* Excel: remove temporary files if spreadsheed-file is not an excel file
|
55
55
|
and an exception was raised
|
56
56
|
* Excelx: a referenced cell with a string had the content 0.0 not the
|
57
57
|
correct string
|
58
|
-
* Fixed a problem with a date cell which was not recognized as a Date
|
58
|
+
* Fixed a problem with a date cell which was not recognized as a Date
|
59
59
|
object (see 2011-05-21 in excelx.rb)
|
60
60
|
|
61
61
|
== 1.9.3 2010-02-12
|
data/License.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2008-2011 Thomas Preymesser
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Manifest.txt
ADDED
@@ -0,0 +1,68 @@
|
|
1
|
+
History.txt
|
2
|
+
License.txt
|
3
|
+
Manifest.txt
|
4
|
+
README.txt
|
5
|
+
Rakefile
|
6
|
+
base64include.rb
|
7
|
+
examples/roo_soap_server.rb
|
8
|
+
examples/roo_soap_client.rb
|
9
|
+
examples/write_me.rb
|
10
|
+
lib/roo.rb
|
11
|
+
lib/roo/version.rb
|
12
|
+
lib/roo/generic_spreadsheet.rb
|
13
|
+
lib/roo/openoffice.rb
|
14
|
+
lib/roo/excel.rb
|
15
|
+
lib/roo/excelx.rb
|
16
|
+
lib/roo/google.rb
|
17
|
+
lib/roo/roo_rails_helper.rb
|
18
|
+
scripts/txt2html
|
19
|
+
setup.rb
|
20
|
+
test/false_encoding.xls
|
21
|
+
test/Bibelbund1.ods
|
22
|
+
test/Bibelbund.ods
|
23
|
+
test/Bibelbund.xls
|
24
|
+
test/Bibelbund.xlsx
|
25
|
+
test/Bibelbund.csv
|
26
|
+
test/bbu.xls
|
27
|
+
test/bbu.xlsx
|
28
|
+
test/bbu.ods
|
29
|
+
test/no_spreadsheet_file.txt
|
30
|
+
test/simple_spreadsheet.ods
|
31
|
+
test/simple_spreadsheet.xls
|
32
|
+
test/simple_spreadsheet.xlsx
|
33
|
+
test/simple_spreadsheet_from_italo.ods
|
34
|
+
test/simple_spreadsheet_from_italo.xls
|
35
|
+
test/test_helper.rb
|
36
|
+
test/test_roo.rb
|
37
|
+
test/time-test.ods
|
38
|
+
test/time-test.xls
|
39
|
+
test/time-test.xlsx
|
40
|
+
test/time-test.csv
|
41
|
+
test/numbers1.csv
|
42
|
+
test/numbers1_excel.csv
|
43
|
+
test/numbers1.ods
|
44
|
+
test/numbers1.xls
|
45
|
+
test/numbers1.xlsx
|
46
|
+
test/borders.ods
|
47
|
+
test/borders.xls
|
48
|
+
test/borders.xlsx
|
49
|
+
test/formula.ods
|
50
|
+
test/formula.xls
|
51
|
+
test/formula.xlsx
|
52
|
+
test/only_one_sheet.ods
|
53
|
+
test/only_one_sheet.xls
|
54
|
+
test/only_one_sheet.xlsx
|
55
|
+
test/bode-v1.xls.zip
|
56
|
+
test/bode-v1.ods.zip
|
57
|
+
test/ric.ods
|
58
|
+
test/bug-row-column-fixnum-float.xls
|
59
|
+
test/emptysheets.ods
|
60
|
+
test/emptysheets.xls
|
61
|
+
test/datetime.ods
|
62
|
+
test/datetime.xls
|
63
|
+
test/datetime.xlsx
|
64
|
+
website/index.html
|
65
|
+
website/index.txt
|
66
|
+
website/javascripts/rounded_corners_lite.inc.js
|
67
|
+
website/stylesheets/screen.css
|
68
|
+
website/template.rhtml
|
data/README.markdown
ADDED
@@ -0,0 +1,109 @@
|
|
1
|
+
# README for Roo
|
2
|
+
|
3
|
+
Roo implements read access for all spreadsheet types and read/write access for
|
4
|
+
Google spreadsheets. It can handle
|
5
|
+
* Openoffice
|
6
|
+
* Excel
|
7
|
+
* Google spreadsheets
|
8
|
+
* Excelx
|
9
|
+
* Libreoffice
|
10
|
+
* CSV
|
11
|
+
|
12
|
+
Using Roo to access Google spreadsheets requires you install the 'google-spreadsheet-ruby' gem separately.
|
13
|
+
|
14
|
+
Unless the underlying 'spreadsheet' gem supports formulas there is no support
|
15
|
+
for formulas in Roo for .xls files (you get the result of a formula in such a
|
16
|
+
file but not the formula itself)
|
17
|
+
|
18
|
+
## Usage:
|
19
|
+
|
20
|
+
require 'roo'
|
21
|
+
|
22
|
+
s = Openoffice.new("myspreadsheet.ods") # creates an Openoffice Spreadsheet instance
|
23
|
+
s = Excel.new("myspreadsheet.xls") # creates an Excel Spreadsheet instance
|
24
|
+
s = Google.new("myspreadsheetkey_at_google") # creates an Google Spreadsheet instance
|
25
|
+
s = Excelx.new("myspreadsheet.xlsx") # creates an Excel Spreadsheet instance for Excel .xlsx files
|
26
|
+
|
27
|
+
s.default_sheet = s.sheets.first # first sheet in the spreadsheet file will be used
|
28
|
+
|
29
|
+
# s.sheet is an array which holds the names of the sheets within
|
30
|
+
# a spreadsheet.
|
31
|
+
# you can also write
|
32
|
+
# s.default_sheet = s.sheets[3] or
|
33
|
+
# s.default_sheet = 'Sheet 3'
|
34
|
+
|
35
|
+
s.cell(1,1) # returns the content of the first row/first cell in the sheet
|
36
|
+
s.cell('A',1) # same cell
|
37
|
+
s.cell(1,'A') # same cell
|
38
|
+
s.cell(1,'A',s.sheets[0]) # same cell
|
39
|
+
|
40
|
+
# almost all methods have an optional argument 'sheet'.
|
41
|
+
# If this parameter is omitted, the default_sheet will be used.
|
42
|
+
|
43
|
+
s.info # prints infos about the spreadsheet file
|
44
|
+
|
45
|
+
s.first_row # the number of the first row
|
46
|
+
s.last_row # the number of the last row
|
47
|
+
s.first_column # the number of the first column
|
48
|
+
s.last_column # the number of the last column
|
49
|
+
|
50
|
+
# limited font information is available
|
51
|
+
|
52
|
+
s.font(1,1).bold?
|
53
|
+
s.font(1,1).italic?
|
54
|
+
s.font(1,1).underline?
|
55
|
+
|
56
|
+
|
57
|
+
see http://roo.rubyforge.org for a more complete tutorial
|
58
|
+
|
59
|
+
# Fork Changelog / New Features
|
60
|
+
|
61
|
+
# Spreadsheet.open can accept both files and paths
|
62
|
+
|
63
|
+
xls = Roo::Spreadsheet.open('./new_prices.xls')
|
64
|
+
|
65
|
+
# no more setting xls.default_sheet, just use this
|
66
|
+
|
67
|
+
xls.sheet('Info').row_count
|
68
|
+
xls.sheet(0).row_count
|
69
|
+
|
70
|
+
# excel likes to create random "Data01" sheets for macros
|
71
|
+
# use this to find the sheet with the most data to parse
|
72
|
+
|
73
|
+
xls.longest_sheet
|
74
|
+
|
75
|
+
# this excel file has multiple worksheets, let's iterate through each of them and process
|
76
|
+
|
77
|
+
xls.each_with_pagename do |name,sheet|
|
78
|
+
puts sheet.row_count
|
79
|
+
end
|
80
|
+
|
81
|
+
# pull out a hash of exclusive column data (get rid of useless columns and save memory)
|
82
|
+
|
83
|
+
xls.each(:id => 'UPC',:qty => 'ATS') {|hash| arr << hash}
|
84
|
+
#=> hash will appear like {:upc=>727880013358, :qty => 12}
|
85
|
+
|
86
|
+
# NOTE: .parse does the same as .each, except it returns an array (similar to each vs. map)
|
87
|
+
|
88
|
+
# not sure exactly what a column will be named? try a wildcard search with the character *
|
89
|
+
# regex characters are allowed ('^price\s')
|
90
|
+
# case insensitive
|
91
|
+
|
92
|
+
xls.parse(:id => 'UPC*SKU',:qty => 'ATS*\sATP\s*QTY$')
|
93
|
+
|
94
|
+
# if you need to locate the header row and assign the header names themselves,
|
95
|
+
# use the :header_search option
|
96
|
+
|
97
|
+
xls.parse(:header_search => ['UPC*SKU','ATS*\sATP\s*QTY$'])
|
98
|
+
#=> each element will appear in this fashion:
|
99
|
+
#=> {"UPC" => 123456789012, "STYLE" => "987B0", "COLOR" => "blue", "QTY" => 78}
|
100
|
+
|
101
|
+
# want to strip out annoying unicode characters and surrounding white space?
|
102
|
+
|
103
|
+
xls.parse(:clean => true)
|
104
|
+
|
105
|
+
# another bonus feature is a patch to prevent the Spreadsheet gem from parsing
|
106
|
+
# thousands and thousands of blank lines. i got fed up after watching my computer
|
107
|
+
# nearly catch fire for 4 hours for a spreadsheet with only 200 ACTUAL lines
|
108
|
+
# - located in lib/roo/worksheet.rb
|
109
|
+
|
data/Rakefile
CHANGED
@@ -12,8 +12,10 @@ task :default => 'test:run'
|
|
12
12
|
|
13
13
|
Bones {
|
14
14
|
name 'roo'
|
15
|
-
authors 'Thomas Preymesser'
|
15
|
+
authors 'Thomas Preymesser', 'Hugh McGowan', 'Ben Woosley'
|
16
16
|
email 'thopre@gmail.com'
|
17
|
+
summary "Roo can access the contents of various spreadsheet files."
|
18
|
+
description "Roo can access the contents of various spreadsheet files. It can handle\n* Openoffice\n* Excel\n* Google spreadsheets\n* Excelx\n* Libreoffice\n* CSV"
|
17
19
|
url 'http://roo.rubyforge.org/'
|
18
20
|
version Roo::VERSION
|
19
21
|
depend_on 'spreadsheet', '> 0.6.4'
|
@@ -26,9 +28,8 @@ Bones {
|
|
26
28
|
#depend_on 'febeling-rubyzip','>= 0.9.2' # meine aktuelle Version
|
27
29
|
#TODO: warum brauchen wir das? es lief doch auch vorher ohne dieses spezielle gem
|
28
30
|
depend_on 'rubyzip' # rubyzip wird benoetigt
|
29
|
-
depend_on 'google-spreadsheet-ruby'
|
30
|
-
depend_on 'choice'
|
31
|
-
depend_on 'todonotes'
|
31
|
+
# depend_on 'google-spreadsheet-ruby'
|
32
|
+
# depend_on 'choice'
|
32
33
|
}
|
33
34
|
|
34
35
|
# EOF
|
data/bin/roo
CHANGED
File without changes
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require 'soap/rpc/driver'
|
2
|
+
|
3
|
+
def ferien_fuer_region(proxy, region, year=nil)
|
4
|
+
proxy.first_row.upto(proxy.last_row) { |row|
|
5
|
+
if proxy.cell(row, 2) == region
|
6
|
+
jahr = proxy.cell(row,1).to_i
|
7
|
+
if year == nil || jahr == year
|
8
|
+
bis_datum = proxy.cell(row,5)
|
9
|
+
if DateTime.now > bis_datum
|
10
|
+
print '('
|
11
|
+
end
|
12
|
+
print jahr.to_s+" "
|
13
|
+
print proxy.cell(row,2)+" "
|
14
|
+
print proxy.cell(row,3)+" "
|
15
|
+
print proxy.cell(row,4).to_s+" "
|
16
|
+
print bis_datum.to_s+" "
|
17
|
+
print (proxy.cell(row,6) || '')+" "
|
18
|
+
if DateTime.now > bis_datum
|
19
|
+
print ')'
|
20
|
+
end
|
21
|
+
puts
|
22
|
+
end
|
23
|
+
end
|
24
|
+
}
|
25
|
+
end
|
26
|
+
|
27
|
+
proxy = SOAP::RPC::Driver.new("http://localhost:12321","spreadsheetserver")
|
28
|
+
proxy.add_method('cell','row','col')
|
29
|
+
proxy.add_method('officeversion')
|
30
|
+
proxy.add_method('last_row')
|
31
|
+
proxy.add_method('last_column')
|
32
|
+
proxy.add_method('first_row')
|
33
|
+
proxy.add_method('first_column')
|
34
|
+
proxy.add_method('sheets')
|
35
|
+
proxy.add_method('set_default_sheet','s')
|
36
|
+
proxy.add_method('ferien_fuer_region', 'region')
|
37
|
+
|
38
|
+
sheets = proxy.sheets
|
39
|
+
proxy.set_default_sheet(sheets.first)
|
40
|
+
|
41
|
+
puts "first row: #{proxy.first_row}"
|
42
|
+
puts "first column: #{proxy.first_column}"
|
43
|
+
puts "last row: #{proxy.last_row}"
|
44
|
+
puts "last column: #{proxy.last_column}"
|
45
|
+
puts "cell: #{proxy.cell('C',8)}"
|
46
|
+
puts "cell: #{proxy.cell('F',12)}"
|
47
|
+
puts "officeversion: #{proxy.officeversion}"
|
48
|
+
puts "Berlin:"
|
49
|
+
|
50
|
+
ferien_fuer_region(proxy, "Berlin")
|
51
|
+
|
52
|
+
|
53
|
+
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'roo'
|
3
|
+
require 'soap/rpc/standaloneServer'
|
4
|
+
|
5
|
+
NS = "spreadsheetserver" # name of your service = namespace
|
6
|
+
class Server2 < SOAP::RPC::StandaloneServer
|
7
|
+
|
8
|
+
def on_init
|
9
|
+
spreadsheet = Openoffice.new("./Ferien-de.ods")
|
10
|
+
add_method(spreadsheet, 'cell', 'row', 'col')
|
11
|
+
add_method(spreadsheet, 'officeversion')
|
12
|
+
add_method(spreadsheet, 'first_row')
|
13
|
+
add_method(spreadsheet, 'last_row')
|
14
|
+
add_method(spreadsheet, 'first_column')
|
15
|
+
add_method(spreadsheet, 'last_column')
|
16
|
+
add_method(spreadsheet, 'sheets')
|
17
|
+
#add_method(spreadsheet, 'default_sheet=', 's')
|
18
|
+
# method with '...=' did not work? alias method 'set_default_sheet' created
|
19
|
+
add_method(spreadsheet, 'set_default_sheet', 's')
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
|
24
|
+
PORT = 12321
|
25
|
+
puts "serving at port #{PORT}"
|
26
|
+
svr = Server2.new('Roo', NS, '0.0.0.0', PORT)
|
27
|
+
|
28
|
+
trap('INT') { svr.shutdown }
|
29
|
+
svr.start
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'roo'
|
3
|
+
|
4
|
+
#-- create a new spreadsheet within your google-spreadsheets and paste
|
5
|
+
#-- the 'key' parameter in the spreadsheet URL
|
6
|
+
MAXTRIES = 1000
|
7
|
+
print "what's your name? "
|
8
|
+
my_name = gets.chomp
|
9
|
+
print "where do you live? "
|
10
|
+
my_location = gets.chomp
|
11
|
+
print "your message? (if left blank, only your name and location will be inserted) "
|
12
|
+
my_message = gets.chomp
|
13
|
+
spreadsheet = Google.new('ptu6bbahNZpY0N0RrxQbWdw')
|
14
|
+
spreadsheet.default_sheet = 'Sheet1'
|
15
|
+
success = false
|
16
|
+
MAXTRIES.times do
|
17
|
+
col = rand(10)+1
|
18
|
+
row = rand(10)+1
|
19
|
+
if spreadsheet.empty?(row,col)
|
20
|
+
if my_message.empty?
|
21
|
+
text = Time.now.to_s+" "+"Greetings from #{my_name} (#{my_location})"
|
22
|
+
else
|
23
|
+
text = Time.now.to_s+" "+"#{my_message} from #{my_name} (#{my_location})"
|
24
|
+
end
|
25
|
+
spreadsheet.set_value(row,col,text)
|
26
|
+
puts "message written to row #{row}, column #{col}"
|
27
|
+
success = true
|
28
|
+
break
|
29
|
+
end
|
30
|
+
puts "Row #{row}, column #{col} already occupied, trying again..."
|
31
|
+
end
|
32
|
+
puts "no empty cell found within #{MAXTRIES} tries" if !success
|
33
|
+
|
data/lib/roo.rb
CHANGED
@@ -1,79 +1,38 @@
|
|
1
|
-
# require 'todo_gem'
|
2
|
-
|
3
1
|
module Roo
|
4
2
|
|
5
|
-
|
6
|
-
VERSION = '1.10.1'
|
7
|
-
LIBPATH = ::File.expand_path(::File.dirname(__FILE__)) + ::File::SEPARATOR
|
8
|
-
PATH = ::File.dirname(LIBPATH) + ::File::SEPARATOR
|
9
|
-
# :startdoc:
|
10
|
-
|
11
|
-
# Returns the version string for the library.
|
12
|
-
#
|
13
|
-
def self.version
|
14
|
-
VERSION
|
15
|
-
end
|
16
|
-
|
17
|
-
# Returns the library path for the module. If any arguments are given,
|
18
|
-
# they will be joined to the end of the libray path using
|
19
|
-
# <tt>File.join</tt>.
|
20
|
-
#
|
21
|
-
def self.libpath( *args )
|
22
|
-
args.empty? ? LIBPATH : ::File.join(LIBPATH, args.flatten)
|
23
|
-
end
|
24
|
-
|
25
|
-
# Returns the lpath for the module. If any arguments are given,
|
26
|
-
# they will be joined to the end of the path using
|
27
|
-
# <tt>File.join</tt>.
|
28
|
-
#
|
29
|
-
def self.path( *args )
|
30
|
-
args.empty? ? PATH : ::File.join(PATH, args.flatten)
|
31
|
-
end
|
32
|
-
|
33
|
-
# Utility method used to require all files ending in .rb that lie in the
|
34
|
-
# directory below this file that has the same name as the filename passed
|
35
|
-
# in. Optionally, a specific _directory_ name can be passed in such that
|
36
|
-
# the _filename_ does not have to be equivalent to the directory.
|
37
|
-
#
|
38
|
-
def self.require_all_libs_relative_to( fname, dir = nil )
|
39
|
-
dir ||= ::File.basename(fname, '.*')
|
40
|
-
search_me = ::File.expand_path(
|
41
|
-
::File.join(::File.dirname(fname), dir, '**', '*.rb'))
|
42
|
-
Dir.glob(search_me).sort.each {|rb|
|
43
|
-
puts "DEBUG: require #{rb}"
|
44
|
-
require rb}
|
45
|
-
end
|
3
|
+
VERSION = '1.10.2'
|
46
4
|
|
47
5
|
class Spreadsheet
|
48
6
|
class << self
|
49
7
|
def open(file)
|
8
|
+
file = File === file ? file.path : file
|
50
9
|
case File.extname(file)
|
51
10
|
when '.xls'
|
52
|
-
Excel.new(file)
|
11
|
+
Roo::Excel.new(file)
|
53
12
|
when '.xlsx'
|
54
|
-
Excelx.new(file)
|
13
|
+
Roo::Excelx.new(file)
|
55
14
|
when '.ods'
|
56
|
-
Openoffice.new(file)
|
15
|
+
Roo::Openoffice.new(file)
|
16
|
+
when '.xml'
|
17
|
+
Roo::Excel2003XML.new(file)
|
18
|
+
when ''
|
19
|
+
Roo::Google.new(file)
|
57
20
|
when '.csv'
|
58
|
-
Csv.new(file)
|
59
|
-
# when ''
|
21
|
+
Roo::Csv.new(file)
|
60
22
|
else
|
61
|
-
|
62
|
-
# else
|
63
|
-
# raise ArgumentError, "Don't know how to open file #{file}"
|
23
|
+
raise ArgumentError, "Don't know how to open file #{file}"
|
64
24
|
end
|
65
25
|
end
|
66
26
|
end
|
67
27
|
end
|
68
|
-
end # module Roo
|
69
|
-
|
70
|
-
require 'roo/generic_spreadsheet'
|
71
|
-
require 'roo/openoffice'
|
72
|
-
require 'roo/excel'
|
73
|
-
require 'roo/excelx'
|
74
|
-
require 'roo/google'
|
75
|
-
require 'roo/csv'
|
76
28
|
|
77
|
-
|
29
|
+
autoload :GenericSpreadsheet, 'roo/generic_spreadsheet'
|
30
|
+
autoload :Openoffice, 'roo/openoffice'
|
31
|
+
autoload :Excel, 'roo/excel'
|
32
|
+
autoload :Excelx, 'roo/excelx'
|
33
|
+
autoload :Google, 'roo/google'
|
34
|
+
autoload :Csv, 'roo/csv'
|
78
35
|
|
79
|
-
|
36
|
+
autoload :Excel2003XML, 'roo/excel2003xml'
|
37
|
+
autoload :RooRailsHelper, 'roo/roo_rails_helper'
|
38
|
+
end
|