SpreadsheetML 0.1
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/init.rb +1 -0
- data/lib/spreadsheetml.rb +54 -0
- metadata +55 -0
data/init.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), "lib", "rubing")
|
@@ -0,0 +1,54 @@
|
|
1
|
+
require "rexml/document"
|
2
|
+
|
3
|
+
class SpreadsheetML
|
4
|
+
attr_accessor :worksheets
|
5
|
+
|
6
|
+
def initialize(stream_or_string)
|
7
|
+
@worksheets = []
|
8
|
+
|
9
|
+
return if stream_or_string.nil?
|
10
|
+
|
11
|
+
doc = REXML::Document.new stream_or_string
|
12
|
+
|
13
|
+
doc.elements.each("Workbook/Worksheet") { |worksheet| @worksheets << Worksheet.new(worksheet) }
|
14
|
+
end
|
15
|
+
|
16
|
+
class Worksheet
|
17
|
+
attr_accessor :name, :tables
|
18
|
+
|
19
|
+
def initialize(xml)
|
20
|
+
@name = xml.attributes["ss:Name"]
|
21
|
+
@tables = xml.elements.collect("Table") { |table| Table.new(table) }
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
class Table
|
26
|
+
attr_accessor :rows
|
27
|
+
|
28
|
+
def initialize(xml)
|
29
|
+
@rows = xml.elements.collect("Row") { |row| Row.new(row) }
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
class Row
|
34
|
+
attr_accessor :cells
|
35
|
+
|
36
|
+
def initialize(xml)
|
37
|
+
@cells = xml.elements.collect("Cell") { |cell| Cell.new(cell) }
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
class Cell
|
42
|
+
attr_accessor :text
|
43
|
+
|
44
|
+
# ignoring style
|
45
|
+
def initialize(xml)
|
46
|
+
@text = ''
|
47
|
+
xml.each_element_with_text {|e| @text << e.text.strip }
|
48
|
+
end
|
49
|
+
|
50
|
+
def to_s
|
51
|
+
@text
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
metadata
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: SpreadsheetML
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease:
|
5
|
+
version: "0.1"
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Wesley Moxam
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
|
13
|
+
date: 2011-10-05 00:00:00 Z
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description: A VERY simple Ruby SpreadsheetML API
|
17
|
+
email: wesley.moxam@savvica.com
|
18
|
+
executables: []
|
19
|
+
|
20
|
+
extensions: []
|
21
|
+
|
22
|
+
extra_rdoc_files: []
|
23
|
+
|
24
|
+
files:
|
25
|
+
- lib/spreadsheetml.rb
|
26
|
+
- init.rb
|
27
|
+
homepage: http://github.com/wmoxam/SpreadsheetML
|
28
|
+
licenses: []
|
29
|
+
|
30
|
+
post_install_message:
|
31
|
+
rdoc_options: []
|
32
|
+
|
33
|
+
require_paths:
|
34
|
+
- lib
|
35
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
36
|
+
none: false
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 1.9.1
|
41
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
42
|
+
none: false
|
43
|
+
requirements:
|
44
|
+
- - ">="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: "0"
|
47
|
+
requirements: []
|
48
|
+
|
49
|
+
rubyforge_project:
|
50
|
+
rubygems_version: 1.8.8
|
51
|
+
signing_key:
|
52
|
+
specification_version: 3
|
53
|
+
summary: A Ruby wrapper for Bing search API
|
54
|
+
test_files: []
|
55
|
+
|