donibuchanan-roo 1.3.12

Sign up to get free protection for your applications and to get access to all the features.
Files changed (78) hide show
  1. data/History.txt +225 -0
  2. data/README.markdown +55 -0
  3. data/examples/roo_soap_client.rb +53 -0
  4. data/examples/roo_soap_server.rb +29 -0
  5. data/examples/write_me.rb +33 -0
  6. data/lib/roo/excel.rb +468 -0
  7. data/lib/roo/excel2003xml.rb +411 -0
  8. data/lib/roo/excelx.rb +602 -0
  9. data/lib/roo/generic_spreadsheet.rb +628 -0
  10. data/lib/roo/google.rb +379 -0
  11. data/lib/roo/openoffice.rb +451 -0
  12. data/lib/roo/roo_rails_helper.rb +82 -0
  13. data/lib/roo/version.rb +9 -0
  14. data/lib/roo.rb +32 -0
  15. data/test/1900_base.xls +0 -0
  16. data/test/1904_base.xls +0 -0
  17. data/test/Bibelbund.csv +3741 -0
  18. data/test/Bibelbund.ods +0 -0
  19. data/test/Bibelbund.xls +0 -0
  20. data/test/Bibelbund.xlsx +0 -0
  21. data/test/Bibelbund1.ods +0 -0
  22. data/test/bad_excel_date.xls +0 -0
  23. data/test/bbu.ods +0 -0
  24. data/test/bbu.xls +0 -0
  25. data/test/bbu.xlsx +0 -0
  26. data/test/bode-v1.ods.zip +0 -0
  27. data/test/bode-v1.xls.zip +0 -0
  28. data/test/boolean.ods +0 -0
  29. data/test/boolean.xls +0 -0
  30. data/test/boolean.xlsx +0 -0
  31. data/test/borders.ods +0 -0
  32. data/test/borders.xls +0 -0
  33. data/test/borders.xlsx +0 -0
  34. data/test/bug-row-column-fixnum-float.xls +0 -0
  35. data/test/datetime.ods +0 -0
  36. data/test/datetime.xls +0 -0
  37. data/test/datetime.xlsx +0 -0
  38. data/test/datetime_floatconv.xls +0 -0
  39. data/test/emptysheets.ods +0 -0
  40. data/test/emptysheets.xls +0 -0
  41. data/test/excel2003.xml +21140 -0
  42. data/test/false_encoding.xls +0 -0
  43. data/test/formula.ods +0 -0
  44. data/test/formula.xls +0 -0
  45. data/test/formula.xlsx +0 -0
  46. data/test/formula_parse_error.xls +0 -0
  47. data/test/html-escape.ods +0 -0
  48. data/test/no_spreadsheet_file.txt +1 -0
  49. data/test/numbers1.csv +18 -0
  50. data/test/numbers1.ods +0 -0
  51. data/test/numbers1.xls +0 -0
  52. data/test/numbers1.xlsx +0 -0
  53. data/test/only_one_sheet.ods +0 -0
  54. data/test/only_one_sheet.xls +0 -0
  55. data/test/only_one_sheet.xlsx +0 -0
  56. data/test/paragraph.ods +0 -0
  57. data/test/paragraph.xls +0 -0
  58. data/test/paragraph.xlsx +0 -0
  59. data/test/ric.ods +0 -0
  60. data/test/simple_spreadsheet.ods +0 -0
  61. data/test/simple_spreadsheet.xls +0 -0
  62. data/test/simple_spreadsheet.xlsx +0 -0
  63. data/test/simple_spreadsheet_from_italo.ods +0 -0
  64. data/test/simple_spreadsheet_from_italo.xls +0 -0
  65. data/test/skipped_tests.rb +789 -0
  66. data/test/style.ods +0 -0
  67. data/test/style.xls +0 -0
  68. data/test/style.xlsx +0 -0
  69. data/test/test_helper.rb +19 -0
  70. data/test/test_roo.rb +1834 -0
  71. data/test/time-test.csv +2 -0
  72. data/test/time-test.ods +0 -0
  73. data/test/time-test.xls +0 -0
  74. data/test/time-test.xlsx +0 -0
  75. data/test/whitespace.ods +0 -0
  76. data/test/whitespace.xls +0 -0
  77. data/test/whitespace.xlsx +0 -0
  78. metadata +185 -0
data/History.txt ADDED
@@ -0,0 +1,225 @@
1
+ == 1.2.3 2009-01-04
2
+
3
+ * bugfix
4
+ * fixed encoding in #cell at exported Google-spreadsheets (.xls)
5
+
6
+ == 1.2.2 2008-12-14
7
+
8
+ * 2 enhancements
9
+ * added celltype :datetime in Excelx
10
+ * added celltype :datetime in Google
11
+
12
+ == 1.2.1 2008-11-13
13
+
14
+ * 1 enhancement
15
+ * added celltype :datetime in Openoffice and Excel
16
+
17
+ == 1.2.0 2008-08-24
18
+ * 3 major enhancements
19
+ * Excelx: improved the detection of cell type and conversion into roo types
20
+ * All: to_csv: changed boundaries from first_row,1..last_row,last_column to 1,1..last_row,last_column
21
+ * All: Environment variable "ROO_TMP" indicate where temporary directories will be created (if not set the default is the current working directory)
22
+ * 2 bugfixes
23
+ * Excel: improved the detection of last_row/last_column (parseexcel-gem bug?)
24
+ * Excel/Excelx/Openoffice: temporary directories were not removed at opening a file of the wrong type
25
+ == 1.1.0 2008-07-26
26
+ * 2 major enhancements
27
+ * Excel: speed improvements
28
+ * Changed the behavior of reading files with the wrong type
29
+ * 3 bugfixes
30
+ * Google: added normalize in set_value method
31
+ * Excel: last_row in Excel class did not work properly under some circumstances
32
+ * all: fixed a bug in #to_xml if there is an empty sheet
33
+ == 1.0.2 2008-07-04
34
+ * 2 bugfixes
35
+ * Excelx: fixed a bug when there are .xml.rels files in the XLSX archive
36
+ * Excelx: fixed a bug with celltype recognition (see comment with "2008-07-03")
37
+ == 1.0.1 2008-06-30
38
+ * 1 bugfix
39
+ * Excel: row/column method Fixnum/Float confusion
40
+ == 1.0.0 2008-05-28
41
+ * 2 major enhancements
42
+ * support of Excel's new .xlsx file format
43
+ * method #to_xml for exporting a spreadsheet to an xml representation
44
+ * 1 bugfix
45
+ * fixed a bug with excel-spreadsheet character conversion under Macintosh Darwin
46
+ == 0.9.4 2008-04-22
47
+ * 1 bugfix
48
+ * fixed a bug with excel-spreadsheet character conversion under Solaris
49
+ == 0.9.3 2008-03-25
50
+ * 1 bugfix
51
+ * no more tmp directories if an invalid spreadsheet file was openend
52
+ == 0.9.2 2008-03-24
53
+ * 1 enhancement
54
+ * new celltype :time
55
+ * 1 bugfix
56
+ * time values like '23:15' are handled as seconds from midnight
57
+ == 0.9.1 2008-03-23
58
+ * 1 enhancement
59
+ * additional 'sheet' parameter in Google#set_value
60
+ * 1 bugfix
61
+ * fixed a bug within Google#set_value. thanks to davecahill <dpcahill@gmail.com> for the patch.
62
+ == 0.9.0 2008-01-24
63
+ * 1 enhancement:
64
+ * better support of roo spreadsheets in rails views
65
+ == 0.8.5 2008-01-16
66
+ * 1 bugfix
67
+ * fixed a bug within #to_cvs and explicit call of a sheet
68
+ == 0.8.4 2008-01-01
69
+ * 1 bugfix
70
+ * fixed 'find_by_condition' for excel sheets (header_line= --> GenericSpredsheet)
71
+ == 0.8.3 2007-12-31
72
+ * 2 bugfixes
73
+ * another fix for the encoding issue in excel sheet-names
74
+ * reactived the Excel#find method which has been disappeared in the last restructoring, moved to GenericSpreadsheet
75
+ == 0.8.2 2007-12-28
76
+ * 1 enhancement:
77
+ * basename() only in method #info
78
+ * 2 bugfixes
79
+ * changed logging-method to mysql-database in test code with AR, table column 'class' => 'class_name'
80
+ * reactived the Excel#to_csv method which has been disappeared in the last restructoring
81
+ == 0.8.1 2007-12-22
82
+ * 3 bugfixes
83
+ * fixed a bug with first/last-row/column in empty sheet
84
+ * #info prints now '- empty -' if a sheet within a document is empty
85
+ * tried to fix the iconv conversion problem
86
+ == 0.8.0 2007-12-15
87
+ * 2 enhancements:
88
+ * Google online spreadsheets were implemented
89
+ * some methods common to more than one class were factored out to the GenericSpreadsheet (virtual) class
90
+ == 0.7.0 2007-11-23
91
+ * 6 enhancements:
92
+ * Openoffice/Excel: the most methods can be called with an option 'sheet'
93
+ parameter which will be used instead of the default sheet
94
+ * Excel: improved the speed of CVS output
95
+ * Openoffice/Excel: new method #column
96
+ * Openoffice/Excel: new method #find
97
+ * Openoffice/Excel: new method #info
98
+ * better exception if a spreadsheet file does not exist
99
+ == 0.6.1 2007-10-06
100
+ * 2 enhancements:
101
+ * Openoffice: percentage-values are now treated as numbers (not strings)
102
+ * Openoffice: refactoring
103
+ * 1 bugfix
104
+ * Openoffice: repeating date-values in a line are now handled correctly
105
+ == 0.6.0 2007-10-06
106
+ * 1 enhancement:
107
+ * csv-output to stdout or file
108
+ == 0.5.4 2007-08-27
109
+ * 1 bugfix
110
+ * Openoffice: fixed a bug with internal representation of a spreadsheet (thanks to Ric Kamicar for the patch)
111
+ == 0.5.3 2007-08-26
112
+ * 2 enhancements:
113
+ * Openoffice: can now read zip-ed files
114
+ * Openoffice: can now read files from http://-URL over the net
115
+ == 0.5.2 2007-08-26
116
+ * 1 bugfix
117
+ * excel: removed debugging output
118
+ == 0.5.1 2007-08-26
119
+ * 4 enhancements:
120
+ * Openoffice: Exception if an illegal sheet-name is selected
121
+ * Openoffice/Excel: no need to set a default_sheet if there is only one in
122
+ the document
123
+ * Excel: can now read zip-ed files
124
+ * Excel: can now read files from http://-URL over the net
125
+
126
+ == 0.5.0 2007-07-20
127
+ * 3 enhancements:
128
+ * Excel-objects: the methods default_sheet= and sheets can now handle names instead of numbers
129
+ * changed the celltype methods to return symbols, not strings anymore (possible values are :formula, :float, :string, :date, :percentage (if you need strings you can convert it with .to_s)
130
+ * tests can now run on the client machine (not only my machine), if there are not public released files involved these tests are skipped
131
+
132
+ == 0.4.1 2007-06-27
133
+ * 1 bugfix
134
+ * there was ONE false require-statement which led to misleading error messageswhen this gem was used
135
+
136
+ == 0.4.0 2007-06-27
137
+ * 7 enhancements:
138
+ * robustness: Exception if no default_sheet was set
139
+ * new method reload() implemented
140
+ * about 15 % more method documentation
141
+ * optimization: huge increase of speed (no need to use fixed borders anymore)
142
+ * added the method 'formulas' which gives you all formulas in a spreadsheet
143
+ * added the method 'set' which can set cells to a certain value
144
+ * added the method 'to_yaml' which can produce output for importing in a (rails) database
145
+ * 4 bugfixes
146
+ * ..row_as_letter methods were nonsense - removed
147
+ * @cells_read should be reset if the default_sheet is changed
148
+ * error in excel-part: strings are now converted to utf-8 (the parsexcel-gem gave me an error with my test data, which could not converted to .to_s using latin1 encoding)
149
+ * fixed bug when default_sheet is changed
150
+
151
+ == 0.3.0 2007-06-20
152
+ * 1 enhancement:
153
+ * Openoffice: formula support
154
+
155
+ == 0.2.7 2007-06-20
156
+ * 1 bugfix:
157
+ * Excel: float-numbers were truncated to integer
158
+
159
+ == 0.2.6 2007-06-19
160
+ * 1 bugfix:
161
+ * Openoffice: two or more consecutive cells with string content failed
162
+
163
+ == 0.2.5 2007-06-17
164
+
165
+ * 2 enhancements:
166
+ * Excel: row method implemented
167
+ * more tests
168
+ * 1 bugfix:
169
+ * Openoffice: row method fixed
170
+
171
+ == 0.2.4 2007-06-16
172
+ * 1 bugfix:
173
+ * ID 11605 Two cols with same value: crash roo (openoffice version only)
174
+
175
+ == 0.2.3 2007-06-02
176
+ * 3 enhancements:
177
+ * more robust call att Excel#default_sheet= when called with a name
178
+ * new method empty?
179
+ * refactoring
180
+ * 1 bugfix:
181
+ * bugfix in Excel#celltype
182
+ * bugfix (running under windows only) in closing the temp file before removing it
183
+
184
+ == 0.2.2 2007-06-01
185
+ * 1 bugfix:
186
+ * correct pathname for running with windows
187
+
188
+
189
+ == 0.2.2 2007-06-01
190
+ * 1 bugfix:
191
+ * incorrect dependencies fixed
192
+
193
+ == 0.2.0 2007-06-01
194
+ * 1 major enhancement:
195
+ * support for MS-Excel Spreadsheets
196
+
197
+ == 0.1.2 2007-05-31
198
+ * 1 major enhancement:
199
+ * cells with more than one character, like 'AA' can now be handled
200
+
201
+ == 0.1.1 2007-05-31
202
+ * 1 Bugfix
203
+ * Bugfix in first/last methods
204
+
205
+ == 0.1.0 2007-05-31
206
+
207
+ * 1 major enhancement:
208
+ * new methods first/last row/column
209
+ * new method officeversion
210
+
211
+ == 0.0.3 2007-05-30
212
+
213
+ * 1 minor enhancement:
214
+ * new method row()
215
+
216
+ == 0.0.2 2007-05-30
217
+
218
+ * 2 major enhancement:
219
+ * fixed some bugs
220
+ * more ways to access a cell
221
+
222
+ == 0.0.1 2007-05-25
223
+
224
+ * 1 major enhancement:
225
+ * Initial release
data/README.markdown ADDED
@@ -0,0 +1,55 @@
1
+ # README for Roo
2
+
3
+ Roo is available here and on Rubyforge. You can install the official release with 'gem install roo' or refer to the installation instructions below for the latest development gem.
4
+
5
+
6
+ ## Installation
7
+
8
+ # Run the following if you haven't done so before:
9
+ gem sources -a http://gems.github.com/
10
+
11
+ # Install the gem:
12
+ sudo gem install hmcgowan-roo
13
+
14
+ ## Usage:
15
+
16
+ require 'rubygems'
17
+ require 'roo'
18
+
19
+ s = Openoffice.new("myspreadsheet.ods") # creates an Openoffice Spreadsheet instance
20
+ s = Excel.new("myspreadsheet.xls") # creates an Excel Spreadsheet instance
21
+ s = Google.new("myspreadsheetkey_at_google") # creates an Google Spreadsheet instance
22
+ s = Excelx.new("myspreadsheet.xlsx") # creates an Excel Spreadsheet instance for Excel .xlsx files
23
+
24
+ s.default_sheet = s.sheets.first # first sheet in the spreadsheet file will be used
25
+
26
+ # s.sheet is an array which holds the names of the sheets within
27
+ # a spreadsheet.
28
+ # you can also write
29
+ # s.default_sheet = s.sheets[3] or
30
+ # s.default_sheet = 'Sheet 3'
31
+
32
+ s.cell(1,1) # returns the content of the first row/first cell in the sheet
33
+ s.cell('A',1) # same cell
34
+ s.cell(1,'A') # same cell
35
+ s.cell(1,'A',s.sheets[0]) # same cell
36
+
37
+ # almost all methods have an optional argument 'sheet'.
38
+ # If this parameter is omitted, the default_sheet will be used.
39
+
40
+ s.info # prints infos about the spreadsheet file
41
+
42
+ s.first_row # the number of the first row
43
+ s.last_row # the number of the last row
44
+ s.first_column # the number of the first column
45
+ s.last_column # the number of the last column
46
+
47
+ # limited font information is available
48
+
49
+ s.font(1,1).bold?
50
+ s.font(1,1).italic?
51
+ s.font(1,1).underline?
52
+
53
+
54
+ see http://roo.rubyforge.org for a more complete tutorial
55
+
@@ -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
+