rods 0.5.1 → 0.6.0
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/README +32 -17
- data/Rakefile +2 -2
- data/lib/rods.rb +10 -6
- data/rods.gemspec +2 -2
- metadata +5 -5
data/README
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
manipulates the XML-files in the zipped *.ods-container.
|
6
6
|
|
7
7
|
On my website http://ruby.homelinux.com/ruby/rods/ you can see the output of the script below.
|
8
|
-
You can contact me at rodsdotrubyatonlinedotde.
|
8
|
+
You can contact me at rodsdotrubyatonlinedotde (and drop me a line, if you like it ;-).
|
9
9
|
|
10
10
|
link:images/Rods.jpg
|
11
11
|
|
@@ -14,6 +14,11 @@
|
|
14
14
|
Licensed under the same terms as Ruby. No warranty is provided.
|
15
15
|
|
16
16
|
= Changelog
|
17
|
+
* 0.5.2
|
18
|
+
* changed interface from
|
19
|
+
* getNextRow, getPreviousRow, getNextCell, getPreviousCell to
|
20
|
+
* getNextExistentRow, getPreviousExistentRow, getNextExistentCell, getPreviousExistentCell
|
21
|
+
See explanation below
|
17
22
|
* 0.5.1
|
18
23
|
* made readCellFromRow() more user-friendly by returning defaults for text and type where
|
19
24
|
till recently error-messages were thrown due to missing values
|
@@ -47,10 +52,26 @@
|
|
47
52
|
* OpenOffice.org 3.0 (German)
|
48
53
|
* Ruby 1.9.1 and 1.8.7
|
49
54
|
|
55
|
+
= What you must know
|
56
|
+
When you open a (new) spreadsheet in an application like OpenOffice.org, you'll see an infinity of empty cells and
|
57
|
+
might be tempted to assume that all these cells actually "exist" in the underlying file format/XML-structure.
|
58
|
+
This is not the case ! A "newly born" spreadsheet does not contain even a single cell ! They're created on demand along
|
59
|
+
with all other cells of lesser x- or y-coordinate.
|
60
|
+
That is: If you write a cell with coordinates (10,10) all cells from (1,1) to (10,10)
|
61
|
+
spring into existence or vice versa: If the cell farthest down the sheet and farthest to the right
|
62
|
+
having a visible value has coordinates (90,87), then all cells from row 1-90 and column 1-87 exist,
|
63
|
+
but no cell out of this virutal rectangle is "alive".
|
64
|
+
This is very important for using the interface appropriately: All routines matching 'Existent' merely return "living"
|
65
|
+
cells, while all other routines bearing a "get|Get" create a row or cell if necessary (and implicitly all other cells
|
66
|
+
within the new boundaries).
|
67
|
+
In other words: Use
|
68
|
+
* getNextExistentRow, getPreviousExistentRow, getNextExistentCell, getPreviousExistentCell
|
69
|
+
whenever you just want to read values you already have (seemlessly skipping visibly emtpy lines and columns) and
|
70
|
+
* getCell, writeGetCell and writeGetCellFromRow whenever you want a cell to be created if it does not exist (which
|
71
|
+
is undoubtedly the case, when you want to write to it or assign it a style) !
|
72
|
+
The first return nil, if an element does not exist yet, the second always return the desired element.
|
73
|
+
|
50
74
|
= Howto
|
51
|
-
Please consider the hints in the next chapter to boost performance when walking
|
52
|
-
your way through many rows. But first the basics:
|
53
|
-
|
54
75
|
$ sudo gem install rods (root-privileges necessary)
|
55
76
|
|
56
77
|
# coding: UTF-8
|
@@ -274,17 +295,10 @@
|
|
274
295
|
puts("Read #{text1} of #{type1} and #{text2} of #{type2}
|
275
296
|
}
|
276
297
|
|
277
|
-
in spite of the fact that
|
278
|
-
getRow
|
279
|
-
even creates a row if it does not yet exist (returns the specified row in any case !), while
|
280
|
-
readCell
|
281
|
-
merely looks up exisiting rows and cells (returns nil,nil otherwise).
|
282
|
-
|
283
298
|
This difference hardly matters while dealing with small documents, but degrades performance significantly when you
|
284
299
|
move up or down a sheet with a lot of rows and process several cells on the same row !
|
285
300
|
|
286
|
-
Provided you just want to read exisiting cells
|
287
|
-
non-existent cells according to Open Document format, an absolute speed-booster compared to the above is the following
|
301
|
+
Provided you just want to read exisiting cells (i.e. cells with "visible values"), the following is a real speed-buster.
|
288
302
|
|
289
303
|
# coding: UTF-8
|
290
304
|
#
|
@@ -299,15 +313,16 @@
|
|
299
313
|
row=mySheet.getRow(1)
|
300
314
|
#---------------------------------------------------------------------------------
|
301
315
|
# The routines
|
302
|
-
# -
|
303
|
-
# -
|
304
|
-
# -
|
305
|
-
# -
|
316
|
+
# - getNextExistentRow(row)
|
317
|
+
# - getPreviousExistentRow(row)
|
318
|
+
# - getNextExistentCell(cell)
|
319
|
+
# - getPreviousExistentCell(cell)
|
306
320
|
# allow the XML-Parser to just continue from the "adjacent" node and
|
307
321
|
# return the previsous/next element without having to start from the top-node
|
308
322
|
# of the document over and over again !
|
323
|
+
#
|
309
324
|
#---------------------------------------------------------------------------------
|
310
|
-
while(row=mySheet.
|
325
|
+
while(row=mySheet.getNextExistentRow(row))
|
311
326
|
i+=1
|
312
327
|
puts("#{i}")
|
313
328
|
confirmed,type=mySheet.readCellFromRow(row,1)
|
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: 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
|
5
|
+
Echoe.new('rods', '0.6.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 (and drop me a line, if you like it ;-)"
|
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
@@ -2460,32 +2460,36 @@ class Rods
|
|
2460
2460
|
# Fast Routine to get the previous row, because XML-Parser does not have
|
2461
2461
|
# to start from top-node of document to find row !
|
2462
2462
|
# Returns previous row as a REXML::Element or nil if no element exists.
|
2463
|
+
# Cf. explanation in README !
|
2463
2464
|
#------------------------------------------------------------------------
|
2464
|
-
def
|
2465
|
+
def getPreviousExistentRow(row)
|
2465
2466
|
return row.previous_sibling
|
2466
2467
|
end
|
2467
2468
|
##########################################################################
|
2468
2469
|
# Fast Routine to get the next cell, because XML-Parser does not have
|
2469
2470
|
# to start from top-node of row to find cell !
|
2470
2471
|
# Returns next cell as a REXML::Element or nil if no element exists
|
2472
|
+
# Cf. explanation in README !
|
2471
2473
|
#------------------------------------------------------------------------
|
2472
|
-
def
|
2474
|
+
def getNextExistentCell(cell)
|
2473
2475
|
return cell.next_sibling
|
2474
2476
|
end
|
2475
2477
|
##########################################################################
|
2476
2478
|
# Fast Routine to get the previous cell, because XML-Parser does not have
|
2477
2479
|
# to start from top-node of row to find cell !
|
2478
2480
|
# Returns previous cell as a REXML::Element or nil if no element exists
|
2481
|
+
# Cf. explanation in README !
|
2479
2482
|
#------------------------------------------------------------------------
|
2480
|
-
def
|
2483
|
+
def getPreviousExistentCell(cell)
|
2481
2484
|
return cell.previous_sibling
|
2482
2485
|
end
|
2483
2486
|
##########################################################################
|
2484
2487
|
# Fast Routine to get the next row, because XML-Parser does not have
|
2485
2488
|
# to start from top-node of document to find row !
|
2486
2489
|
# Returns next row as a REXML::Element or nil if no element exists
|
2490
|
+
# Cf. explanation in README !
|
2487
2491
|
#------------------------------------------------------------------------
|
2488
|
-
def
|
2492
|
+
def getNextExistentRow(row)
|
2489
2493
|
return row.next_sibling
|
2490
2494
|
end
|
2491
2495
|
##########################################################################
|
@@ -2507,8 +2511,8 @@ class Rods
|
|
2507
2511
|
public :setDateFormat, :writeGetCell, :writeCell, :writeGetCellFromRow, :writeCellFromRow,
|
2508
2512
|
:getCellFromRow, :getCell, :getRow, :renameTable, :setCurrentTable,
|
2509
2513
|
:insertTable, :deleteTable, :readCellFromRow, :readCell, :setAttributes, :writeStyleAbbr,
|
2510
|
-
:setStyle, :printOfficeStyles, :printAutoStyles, :
|
2511
|
-
:
|
2514
|
+
:setStyle, :printOfficeStyles, :printAutoStyles, :getNextExistentRow, :getPreviousExistentRow,
|
2515
|
+
:getNextExistentCell, :getPreviousExistentCell,
|
2512
2516
|
:writeComment, :save, :saveAs, :initialize, :writeText
|
2513
2517
|
|
2514
2518
|
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.6.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: 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
|
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 (and drop me a line, if you like it ;-)}
|
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: 7
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
-
|
10
|
-
version: 0.
|
8
|
+
- 6
|
9
|
+
- 0
|
10
|
+
version: 0.6.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: 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
|
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 (and drop me a line, if you like it ;-)"
|
23
23
|
email: rods.ruby@online.de
|
24
24
|
executables: []
|
25
25
|
|