rods 0.1.1 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README +54 -2
- data/Rakefile +2 -2
- data/lib/rods.rb +34 -1
- data/rods.gemspec +2 -2
- metadata +5 -5
data/README
CHANGED
@@ -14,6 +14,9 @@
|
|
14
14
|
Licensed under the same terms as Ruby. No warranty is provided.
|
15
15
|
|
16
16
|
= Changelog
|
17
|
+
* 0.5.0
|
18
|
+
* new performance-boosters for reading lots of rows (cf. chapter and second example-script below)
|
19
|
+
* getNextRow, getPreviousRow, getNextCell, getPreviousCell
|
17
20
|
* 0.1.1
|
18
21
|
* Bug-Fix: readCellFromRow() did not return value in some cases
|
19
22
|
* 0.1.0
|
@@ -42,6 +45,8 @@
|
|
42
45
|
* Ruby 1.9.1 and 1.8.7
|
43
46
|
|
44
47
|
= Howto
|
48
|
+
Please consider the hints in the next chapter to boost performance when walking
|
49
|
+
your way through many rows. But first the basics:
|
45
50
|
|
46
51
|
$ sudo gem install rods (root-privileges necessary)
|
47
52
|
|
@@ -266,11 +271,58 @@
|
|
266
271
|
puts("Read #{text1} of #{type1} and #{text2} of #{type2}
|
267
272
|
}
|
268
273
|
|
274
|
+
in spite of the fact that
|
275
|
+
getRow
|
276
|
+
even creates a row if it does not yet exist (returns the specified row in any case !), while
|
277
|
+
readCell
|
278
|
+
merely looks up exisiting rows and cells (returns nil,nil otherwise).
|
279
|
+
|
269
280
|
This difference hardly matters while dealing with small documents, but degrades performance significantly when you
|
270
281
|
move up or down a sheet with a lot of rows and process several cells on the same row !
|
271
282
|
|
272
|
-
|
273
|
-
|
283
|
+
Provided you just want to read exisiting cells and not write to at the user leven seemingly empty ones, but de facto
|
284
|
+
non-existent cells according to Open Document format, an absolute speed-booster compared to the above is the following
|
285
|
+
|
286
|
+
# coding: UTF-8
|
287
|
+
#
|
288
|
+
# Author: Dr. Heinz Breinlinger
|
289
|
+
#
|
290
|
+
require 'rubygems'
|
291
|
+
require 'rods'
|
292
|
+
|
293
|
+
mySheet=Rods.new("Konten.ods")
|
294
|
+
sum=0.0
|
295
|
+
i=0
|
296
|
+
row=mySheet.getRow(1)
|
297
|
+
#---------------------------------------------------------------------------------
|
298
|
+
# The routines
|
299
|
+
# - getNextRow(row)
|
300
|
+
# - getPreviousRow(row)
|
301
|
+
# - getNextCell(cell)
|
302
|
+
# - getPreviousCell(cell)
|
303
|
+
# allow the XML-Parser to just continue from the "adjacent" node) and
|
304
|
+
# return the previsous/next element without having to start from the top-node
|
305
|
+
# of the document over and over again !
|
306
|
+
#---------------------------------------------------------------------------------
|
307
|
+
while(row=mySheet.getNextRow(row))
|
308
|
+
i+=1
|
309
|
+
puts("#{i}")
|
310
|
+
confirmed,type=mySheet.readCellFromRow(row,1)
|
311
|
+
next if (! confirmed || confirmed.empty?())
|
312
|
+
account,type=mySheet.readCellFromRow(row,9)
|
313
|
+
next if (! account || account.empty?())
|
314
|
+
transfer,type=mySheet.readCellFromRow(row,7)
|
315
|
+
next if (! transfer || transfer.empty?())
|
316
|
+
if(confirmed.match(/x/i) && account.match(/Hauskonto/))
|
317
|
+
puts("#{i}: --> #{transfer} €")
|
318
|
+
sum+=transfer.to_f
|
319
|
+
end
|
320
|
+
end
|
321
|
+
puts("------------")
|
322
|
+
puts("Sum: #{sum}")
|
323
|
+
|
324
|
+
On the ATOM-Nettop I developed the gem, even the script above took just 2-3 seconds and on my Core-i7-Notebook it was finished so quickly
|
325
|
+
that I supposed it had halted on an immediate error, so: don't be concerned and just experiment :-).
|
274
326
|
|
275
327
|
= Standards
|
276
328
|
* Open Document Format for Office Applications (Open Document) v1.1 based on OpenOffice.org (OOo)
|
data/Rakefile
CHANGED
@@ -2,8 +2,8 @@ require 'rubygems'
|
|
2
2
|
require 'rake'
|
3
3
|
require 'echoe'
|
4
4
|
|
5
|
-
Echoe.new('rods', '0.
|
6
|
-
p.description = "OpenOffice.org oocalc:
|
5
|
+
Echoe.new('rods', '0.5.0') do |p|
|
6
|
+
p.description = "OpenOffice.org oocalc: Fast automated batch-processing of spreadsheets (*.ods) conforming to Open Document Format v1.1. used by e.g. OpenOffice.org and LibreOffice. Please see screenshot and Rdoc-Documentation at http://ruby.homelinux.com/ruby/rods/. You can contact me at rodsdotrubyatonlinedotde."
|
7
7
|
p.summary = "Automation of OpenOffice/LibreOffice by batch-processing of spreadsheets conforming to Open Document v1.1"
|
8
8
|
p.url = "http://ruby.homelinux.com/ruby/rods/"
|
9
9
|
p.author = "Dr. Heinz Breinlinger"
|
data/lib/rods.rb
CHANGED
@@ -2457,6 +2457,38 @@ class Rods
|
|
2457
2457
|
puts(" color")
|
2458
2458
|
end
|
2459
2459
|
##########################################################################
|
2460
|
+
# Fast Routine to get the previous row, because XML-Parser does not have
|
2461
|
+
# to start from top-node of document to find row !
|
2462
|
+
# Returns previous row as a REXML::Element or nil if no element exists.
|
2463
|
+
#------------------------------------------------------------------------
|
2464
|
+
def getPreviousRow(row)
|
2465
|
+
return row.previous_sibling
|
2466
|
+
end
|
2467
|
+
##########################################################################
|
2468
|
+
# Fast Routine to get the next cell, because XML-Parser does not have
|
2469
|
+
# to start from top-node of row to find cell !
|
2470
|
+
# Returns next cell as a REXML::Element or nil if no element exists
|
2471
|
+
#------------------------------------------------------------------------
|
2472
|
+
def getNextCell(cell)
|
2473
|
+
return cell.next_sibling
|
2474
|
+
end
|
2475
|
+
##########################################################################
|
2476
|
+
# Fast Routine to get the previous cell, because XML-Parser does not have
|
2477
|
+
# to start from top-node of row to find cell !
|
2478
|
+
# Returns previous cell as a REXML::Element or nil if no element exists
|
2479
|
+
#------------------------------------------------------------------------
|
2480
|
+
def getPreviousCell(cell)
|
2481
|
+
return cell.previous_sibling
|
2482
|
+
end
|
2483
|
+
##########################################################################
|
2484
|
+
# Fast Routine to get the next row, because XML-Parser does not have
|
2485
|
+
# to start from top-node of document to find row !
|
2486
|
+
# Returns next row as a REXML::Element or nil if no element exists
|
2487
|
+
#------------------------------------------------------------------------
|
2488
|
+
def getNextRow(row)
|
2489
|
+
return row.next_sibling
|
2490
|
+
end
|
2491
|
+
##########################################################################
|
2460
2492
|
# Oeffnet zip-Datei und erzeugt diese, wenn nicht existent
|
2461
2493
|
#-------------------------------------------------------------------------
|
2462
2494
|
def open(file)
|
@@ -2475,7 +2507,8 @@ class Rods
|
|
2475
2507
|
public :setDateFormat, :writeGetCell, :writeCell, :writeGetCellFromRow, :writeCellFromRow,
|
2476
2508
|
:getCellFromRow, :getCell, :getRow, :renameTable, :setCurrentTable,
|
2477
2509
|
:insertTable, :deleteTable, :readCellFromRow, :readCell, :setAttributes, :writeStyleAbbr,
|
2478
|
-
:setStyle, :printOfficeStyles, :printAutoStyles,
|
2510
|
+
:setStyle, :printOfficeStyles, :printAutoStyles, :getNextRow, :getPreviousRow,
|
2511
|
+
:getNextCell, :getPreviousCell,
|
2479
2512
|
:writeComment, :save, :saveAs, :initialize, :writeText
|
2480
2513
|
|
2481
2514
|
private :tell, :die, :createCell, :createRow, :getChildByIndex, :createElement, :setRepetition, :initHousekeeping,
|
data/rods.gemspec
CHANGED
@@ -2,12 +2,12 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{rods}
|
5
|
-
s.version = "0.
|
5
|
+
s.version = "0.5.0"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Dr. Heinz Breinlinger"]
|
9
9
|
s.date = %q{2011-01-07}
|
10
|
-
s.description = %q{OpenOffice.org oocalc:
|
10
|
+
s.description = %q{OpenOffice.org oocalc: Fast automated batch-processing of spreadsheets (*.ods) conforming to Open Document Format v1.1. used by e.g. OpenOffice.org and LibreOffice. Please see screenshot and Rdoc-Documentation at http://ruby.homelinux.com/ruby/rods/. You can contact me at rodsdotrubyatonlinedotde.}
|
11
11
|
s.email = %q{rods.ruby@online.de}
|
12
12
|
s.extra_rdoc_files = ["README", "lib/example.rb", "lib/rods.rb"]
|
13
13
|
s.files = ["Manifest", "README", "Rakefile", "lib/example.rb", "lib/rods.rb", "rods.gemspec"]
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rods
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 11
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
-
|
10
|
-
version: 0.
|
8
|
+
- 5
|
9
|
+
- 0
|
10
|
+
version: 0.5.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Dr. Heinz Breinlinger
|
@@ -19,7 +19,7 @@ date: 2011-01-07 00:00:00 +01:00
|
|
19
19
|
default_executable:
|
20
20
|
dependencies: []
|
21
21
|
|
22
|
-
description: "OpenOffice.org oocalc:
|
22
|
+
description: "OpenOffice.org oocalc: Fast automated batch-processing of spreadsheets (*.ods) conforming to Open Document Format v1.1. used by e.g. OpenOffice.org and LibreOffice. Please see screenshot and Rdoc-Documentation at http://ruby.homelinux.com/ruby/rods/. You can contact me at rodsdotrubyatonlinedotde."
|
23
23
|
email: rods.ruby@online.de
|
24
24
|
executables: []
|
25
25
|
|