rubyXL 1.0.7 → 1.0.8
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +18 -1
- data/VERSION +1 -1
- data/lib/parser.rb +8 -8
- data/lib/writer/styles_writer.rb +10 -11
- data/rubyXL.gemspec +2 -2
- metadata +18 -18
data/README.rdoc
CHANGED
@@ -9,18 +9,35 @@
|
|
9
9
|
=== Parsing
|
10
10
|
workbook = RubyXL::Parser.parse("path/to/Excel/file.xlsx")
|
11
11
|
|
12
|
+
|
12
13
|
=== Creating
|
13
14
|
workbook = RubyXL::Workbook.new
|
15
|
+
|
16
|
+
|
17
|
+
=== Modifying
|
18
|
+
|
19
|
+
==== Adding Worksheets
|
20
|
+
workbook.worksheets << Worksheet.new('Sheet2')
|
21
|
+
|
22
|
+
==== Adding Cells
|
14
23
|
workbook.worksheets[0].add_cell(0,0,'A1') #sets A1 to string "A1"
|
15
24
|
workbook.worksheets[0].add_cell(0,1,'','A1') #sets A2 to value of A1
|
16
25
|
|
17
|
-
|
26
|
+
==== Changing Fonts
|
18
27
|
workbook.worksheets[0].sheet_data[0][0].change_font_bold(true) #sets A1 to bold
|
19
28
|
workbook.worksheets[0].change_row_font_italics(0,true) #makes first row italicized
|
29
|
+
workbook.worksheets[0].change_column_font_name(0,'Verdana')
|
30
|
+
|
31
|
+
==== Changing Fills
|
32
|
+
#code here
|
33
|
+
|
34
|
+
==== Merging Cells
|
35
|
+
#code here
|
20
36
|
|
21
37
|
=== Writing
|
22
38
|
workbook.write("path/to/desired/Excel/file.xlsx")
|
23
39
|
|
40
|
+
|
24
41
|
== For more information
|
25
42
|
Take a look at the files in spec/lib/ for rspecs on most methods
|
26
43
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0.
|
1
|
+
1.0.8
|
data/lib/parser.rb
CHANGED
@@ -216,23 +216,23 @@ module RubyXL
|
|
216
216
|
style_index = nil
|
217
217
|
|
218
218
|
data_type = value.attribute('t').to_s
|
219
|
-
|
220
|
-
if
|
219
|
+
|
220
|
+
if (value.css('v').to_s == "") || (value.css('v').children.to_s == "") #no data
|
221
|
+
cell_data = nil
|
222
|
+
elsif data_type == 's' #shared string
|
221
223
|
str_index = Integer(value.css('v').children.to_s)
|
222
224
|
cell_data = shared_strings[str_index].to_s
|
223
225
|
elsif data_type=='str' #raw string
|
224
226
|
cell_data = value.css('v').children.to_s
|
225
227
|
elsif data_type=='e' #error
|
226
228
|
cell_data = value.css('v').children.to_s
|
227
|
-
|
229
|
+
else# (value.css('v').to_s != "") && (value.css('v').children.to_s != "") #is number
|
228
230
|
data_type = ''
|
229
231
|
if(value.css('v').children.to_s =~ /\./) #is float
|
230
232
|
cell_data = Float(value.css('v').children.to_s)
|
231
|
-
else
|
233
|
+
else
|
232
234
|
cell_data = Integer(value.css('v').children.to_s)
|
233
235
|
end
|
234
|
-
else #no data
|
235
|
-
cell_data = nil
|
236
236
|
end
|
237
237
|
cell_formula = nil
|
238
238
|
if(value.css('f').to_s != "")
|
@@ -240,7 +240,7 @@ module RubyXL
|
|
240
240
|
end
|
241
241
|
|
242
242
|
unless @data_only
|
243
|
-
style_index =
|
243
|
+
style_index = value['s'].to_i #nil goes to 0 (default)
|
244
244
|
else
|
245
245
|
style_index = 0
|
246
246
|
end
|
@@ -370,7 +370,7 @@ module RubyXL
|
|
370
370
|
wb.appversion = files['app'].css('AppVersion').children.to_s
|
371
371
|
end
|
372
372
|
|
373
|
-
wb.shared_strings_XML = files['sharedString']
|
373
|
+
wb.shared_strings_XML = files['sharedString'].to_s
|
374
374
|
|
375
375
|
wb.worksheets = Array.new(@num_sheets) #array of Worksheet objs
|
376
376
|
wb
|
data/lib/writer/styles_writer.rb
CHANGED
@@ -78,17 +78,16 @@ module Writer
|
|
78
78
|
style_id_corrector['0']=0
|
79
79
|
1.upto(@workbook.cell_xfs[:xf].size) do |i|
|
80
80
|
style_id_corrector[i.to_s]= i-offset
|
81
|
-
#
|
82
|
-
(i+1).upto(@workbook.cell_xfs[:xf].size) do |j|
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
end
|
81
|
+
#style correction commented out until bug is fixed
|
82
|
+
# (i+1).upto(@workbook.cell_xfs[:xf].size) do |j|
|
83
|
+
# unless i == j
|
84
|
+
# if hash_equal(@workbook.cell_xfs[:xf][i],@workbook.cell_xfs[:xf][j])
|
85
|
+
# @workbook.cell_xfs[:xf].delete_at(i)
|
86
|
+
# style_id_corrector.delete(i.to_s)
|
87
|
+
# offset += 1
|
88
|
+
# end
|
89
|
+
# end
|
90
|
+
# end
|
92
91
|
end
|
93
92
|
@workbook.style_corrector = style_id_corrector
|
94
93
|
|
data/rubyXL.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{rubyXL}
|
8
|
-
s.version = "1.0.
|
8
|
+
s.version = "1.0.8"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Vivek Bhagwat"]
|
12
|
-
s.date = %q{2011-08-
|
12
|
+
s.date = %q{2011-08-03}
|
13
13
|
s.description = %q{rubyXL is a gem which allows the parsing, creation, and manipulation of Microsoft Excel (.xlsx/.xlsm) Documents}
|
14
14
|
s.email = %q{bhagwat.vivek@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubyXL
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 7
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 1.0.
|
9
|
+
- 8
|
10
|
+
version: 1.0.8
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Vivek Bhagwat
|
@@ -15,11 +15,11 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-08-
|
18
|
+
date: 2011-08-03 00:00:00 -04:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
22
|
-
|
22
|
+
prerelease: false
|
23
23
|
version_requirements: &id001 !ruby/object:Gem::Requirement
|
24
24
|
none: false
|
25
25
|
requirements:
|
@@ -29,11 +29,11 @@ dependencies:
|
|
29
29
|
segments:
|
30
30
|
- 0
|
31
31
|
version: "0"
|
32
|
-
prerelease: false
|
33
32
|
name: shoulda
|
34
33
|
requirement: *id001
|
35
|
-
- !ruby/object:Gem::Dependency
|
36
34
|
type: :development
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
prerelease: false
|
37
37
|
version_requirements: &id002 !ruby/object:Gem::Requirement
|
38
38
|
none: false
|
39
39
|
requirements:
|
@@ -45,11 +45,11 @@ dependencies:
|
|
45
45
|
- 0
|
46
46
|
- 0
|
47
47
|
version: 1.0.0
|
48
|
-
prerelease: false
|
49
48
|
name: bundler
|
50
49
|
requirement: *id002
|
51
|
-
- !ruby/object:Gem::Dependency
|
52
50
|
type: :development
|
51
|
+
- !ruby/object:Gem::Dependency
|
52
|
+
prerelease: false
|
53
53
|
version_requirements: &id003 !ruby/object:Gem::Requirement
|
54
54
|
none: false
|
55
55
|
requirements:
|
@@ -61,11 +61,11 @@ dependencies:
|
|
61
61
|
- 6
|
62
62
|
- 0
|
63
63
|
version: 1.6.0
|
64
|
-
prerelease: false
|
65
64
|
name: jeweler
|
66
65
|
requirement: *id003
|
67
|
-
- !ruby/object:Gem::Dependency
|
68
66
|
type: :development
|
67
|
+
- !ruby/object:Gem::Dependency
|
68
|
+
prerelease: false
|
69
69
|
version_requirements: &id004 !ruby/object:Gem::Requirement
|
70
70
|
none: false
|
71
71
|
requirements:
|
@@ -75,11 +75,11 @@ dependencies:
|
|
75
75
|
segments:
|
76
76
|
- 0
|
77
77
|
version: "0"
|
78
|
-
prerelease: false
|
79
78
|
name: rcov
|
80
79
|
requirement: *id004
|
81
|
-
- !ruby/object:Gem::Dependency
|
82
80
|
type: :development
|
81
|
+
- !ruby/object:Gem::Dependency
|
82
|
+
prerelease: false
|
83
83
|
version_requirements: &id005 !ruby/object:Gem::Requirement
|
84
84
|
none: false
|
85
85
|
requirements:
|
@@ -91,11 +91,11 @@ dependencies:
|
|
91
91
|
- 4
|
92
92
|
- 4
|
93
93
|
version: 1.4.4
|
94
|
-
prerelease: false
|
95
94
|
name: nokogiri
|
96
95
|
requirement: *id005
|
97
|
-
- !ruby/object:Gem::Dependency
|
98
96
|
type: :development
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
prerelease: false
|
99
99
|
version_requirements: &id006 !ruby/object:Gem::Requirement
|
100
100
|
none: false
|
101
101
|
requirements:
|
@@ -107,11 +107,11 @@ dependencies:
|
|
107
107
|
- 9
|
108
108
|
- 4
|
109
109
|
version: 0.9.4
|
110
|
-
prerelease: false
|
111
110
|
name: rubyzip
|
112
111
|
requirement: *id006
|
113
|
-
- !ruby/object:Gem::Dependency
|
114
112
|
type: :development
|
113
|
+
- !ruby/object:Gem::Dependency
|
114
|
+
prerelease: false
|
115
115
|
version_requirements: &id007 !ruby/object:Gem::Requirement
|
116
116
|
none: false
|
117
117
|
requirements:
|
@@ -123,9 +123,9 @@ dependencies:
|
|
123
123
|
- 3
|
124
124
|
- 4
|
125
125
|
version: 1.3.4
|
126
|
-
prerelease: false
|
127
126
|
name: rspec
|
128
127
|
requirement: *id007
|
128
|
+
type: :development
|
129
129
|
description: rubyXL is a gem which allows the parsing, creation, and manipulation of Microsoft Excel (.xlsx/.xlsm) Documents
|
130
130
|
email: bhagwat.vivek@gmail.com
|
131
131
|
executables: []
|