simple-spreadsheet-extractor 0.2.2 → 0.2.3
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.rdoc +8 -3
- data/lib/simple-spreadsheet-extractor.rb +28 -20
- metadata +20 -5
data/README.rdoc
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
= Simple Spreadsheet Extractor
|
2
2
|
|
3
3
|
Authors:: Stuart Owen
|
4
|
-
Version:: 0.2.
|
4
|
+
Version:: 0.2.3
|
5
5
|
Contact:: mailto:stuart.owen@manchester.ac.uk
|
6
6
|
Licence:: BSD (See LICENCE or http://www.opensource.org/licenses/bsd-license.php)
|
7
7
|
Copyright:: (c) 2010 The University of Manchester, UK
|
@@ -9,7 +9,7 @@ Copyright:: (c) 2010 The University of Manchester, UK
|
|
9
9
|
|
10
10
|
== Synopsis
|
11
11
|
|
12
|
-
This is a simple gem that provides a facility to read
|
12
|
+
This is a simple gem that provides a facility to read an XLS or XLSX Excel spreadsheet document and produce an XML representation of its content.
|
13
13
|
|
14
14
|
Internally it uses Apache POI, using the sister [http://github.com/myGrid/simple-spreadsheet-extractor] tool.
|
15
15
|
|
@@ -26,6 +26,7 @@ Java 1.6 (JRE) is required.
|
|
26
26
|
* require 'simple-spreadsheet-extractor'
|
27
27
|
* include the module SysMODB::SpreadsheetExtractor
|
28
28
|
* pass an IO object to the method spreedsheet_to_xml which responds with the XML for the contents of the sheet.
|
29
|
+
* if something goes wrong with the extraction then a SysMODB::SpreadsheetExtractionException will be thrown
|
29
30
|
|
30
31
|
e.g.
|
31
32
|
|
@@ -35,4 +36,8 @@ e.g.
|
|
35
36
|
include SysMODB::SpreadsheetExtractor
|
36
37
|
|
37
38
|
f=open("/tmp/test-spreadsheet.xls")
|
38
|
-
|
39
|
+
begin
|
40
|
+
puts spreadsheet_to_xml f
|
41
|
+
rescue SysMODB::SpreadsheetExtractionException=>e
|
42
|
+
puts "Something went wrong #{e.message}"
|
43
|
+
end
|
@@ -1,32 +1,40 @@
|
|
1
|
-
require '
|
1
|
+
require 'rubygems'
|
2
|
+
require 'open4'
|
2
3
|
|
3
4
|
module SysMODB
|
5
|
+
|
6
|
+
class SpreadsheetExtractionException < Exception
|
7
|
+
end
|
8
|
+
|
4
9
|
module SpreadsheetExtractor
|
5
10
|
|
6
11
|
JAR_PATH = File.dirname(__FILE__) + "/../jars"
|
7
12
|
|
8
13
|
def spreadsheet_to_xml spreadsheet_data
|
9
14
|
command = "java -jar #{JAR_PATH}/simple-spreadsheet-extractor-0.2.jar"
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
15
|
+
output = ""
|
16
|
+
err_message = ""
|
17
|
+
status = Open4::popen4(command) do |pid, stdin, stdout, stderr|
|
18
|
+
while ((line = spreadsheet_data.gets) != nil) do
|
19
|
+
stdin << line
|
20
|
+
end
|
21
|
+
stdin.close
|
22
|
+
|
23
|
+
while ((line = stdout.gets) != nil) do
|
24
|
+
output << line
|
25
|
+
end
|
26
|
+
stdout.close
|
27
|
+
|
28
|
+
while ((line=stderr.gets)!= nil) do
|
29
|
+
err_message << line
|
30
|
+
end
|
31
|
+
stderr.close
|
32
|
+
end
|
33
|
+
|
34
|
+
if status.to_i != 0
|
35
|
+
raise SpreadsheetExtractionException.new(err_message)
|
14
36
|
end
|
15
|
-
|
16
|
-
|
17
|
-
# if !(line=stderr.gets).nil?
|
18
|
-
# msg=line
|
19
|
-
# while ((line=stderr.gets)!= nil) do
|
20
|
-
# msg << line
|
21
|
-
# end
|
22
|
-
# raise Exception.new(msg)
|
23
|
-
# end
|
24
|
-
|
25
|
-
output = ""
|
26
|
-
while ((line = stdout.gets) != nil) do
|
27
|
-
output << line
|
28
|
-
end
|
29
|
-
|
37
|
+
|
30
38
|
return output
|
31
39
|
end
|
32
40
|
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: simple-spreadsheet-extractor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 17
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 0.2.
|
9
|
+
- 3
|
10
|
+
version: 0.2.3
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Stuart Owen
|
@@ -17,8 +17,23 @@ cert_chain: []
|
|
17
17
|
|
18
18
|
date: 2010-07-23 00:00:00 +01:00
|
19
19
|
default_executable:
|
20
|
-
dependencies:
|
21
|
-
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
name: open4
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - "="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
hash: 21
|
30
|
+
segments:
|
31
|
+
- 1
|
32
|
+
- 0
|
33
|
+
- 1
|
34
|
+
version: 1.0.1
|
35
|
+
type: :runtime
|
36
|
+
version_requirements: *id001
|
22
37
|
description: Takes a stream to a spreadsheet file and produces and XML representation of its contents
|
23
38
|
email: stuart.owen@manchester.ac.uk
|
24
39
|
executables: []
|