rubyXL 1.1.4 → 1.1.5
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +48 -5
- data/VERSION +1 -1
- data/lib/rubyXL.rb +6 -6
- data/lib/{Hash.rb → rubyXL/Hash.rb} +0 -0
- data/lib/{cell.rb → rubyXL/cell.rb} +0 -0
- data/lib/{color.rb → rubyXL/color.rb} +0 -0
- data/lib/{parser.rb → rubyXL/parser.rb} +8 -8
- data/lib/{private_class.rb → rubyXL/private_class.rb} +0 -0
- data/lib/{workbook.rb → rubyXL/workbook.rb} +1 -1
- data/lib/{worksheet.rb → rubyXL/worksheet.rb} +0 -0
- data/lib/{writer → rubyXL/writer}/app_writer.rb +0 -0
- data/lib/{writer → rubyXL/writer}/calc_chain_writer.rb +0 -0
- data/lib/{writer → rubyXL/writer}/content_types_writer.rb +0 -0
- data/lib/{writer → rubyXL/writer}/core_writer.rb +0 -0
- data/lib/{writer → rubyXL/writer}/root_rels_writer.rb +0 -0
- data/lib/{writer → rubyXL/writer}/shared_strings_writer.rb +0 -0
- data/lib/{writer → rubyXL/writer}/styles_writer.rb +0 -0
- data/lib/{writer → rubyXL/writer}/theme_writer.rb +0 -0
- data/lib/{writer → rubyXL/writer}/workbook_rels_writer.rb +0 -0
- data/lib/{writer → rubyXL/writer}/workbook_writer.rb +0 -0
- data/lib/{writer → rubyXL/writer}/worksheet_writer.rb +0 -0
- data/lib/{zip.rb → rubyXL/zip.rb} +0 -0
- data/rubyXL.gemspec +21 -21
- metadata +37 -37
data/README.rdoc
CHANGED
@@ -19,6 +19,9 @@
|
|
19
19
|
workbook.worksheets[0] #returns first worksheet
|
20
20
|
workbook[0] #returns first worksheet
|
21
21
|
|
22
|
+
==== Accessing Only the Values
|
23
|
+
workbook.worksheets[0].extract_data #produces a 2d array which consists only of the values (instead of the Cell objects which include other variables)
|
24
|
+
|
22
25
|
==== Accessing a Row (Array of Cells)
|
23
26
|
workbook[0].sheet_data[0] #returns first row in first worksheet
|
24
27
|
workbook[0][0] #returns first row in first worksheet
|
@@ -60,7 +63,18 @@
|
|
60
63
|
workbook[0].get_column_border_right(0) #returns weight of right border of first column (nil if none exists), other directions have the same syntax
|
61
64
|
|
62
65
|
==== Table identification
|
63
|
-
#
|
66
|
+
workbook[0].get_table(["NAME", "AGE", "HEIGHT"]) #returns hash of a table in the first worksheet, with the specified strings as headers, accessible by row and column
|
67
|
+
#it returns the following structure
|
68
|
+
{
|
69
|
+
:Name=>["John", "Jane", "Joe"],
|
70
|
+
:Height=>[70, 65, 68],
|
71
|
+
:Age=>[30, 25, 35]
|
72
|
+
:table=>[
|
73
|
+
{:Name=>"John", :Height=>70, :Age=>30},
|
74
|
+
{:Name=>"Jane", :Height=>65, :Age=>25},
|
75
|
+
{:Name=>"Joe", :Height=>68, :Age=>35}
|
76
|
+
]
|
77
|
+
}
|
64
78
|
|
65
79
|
=== Modifying
|
66
80
|
|
@@ -73,6 +87,8 @@
|
|
73
87
|
|
74
88
|
workbook.worksheets[0].add_cell_obj(Cell.new(1,0,'blah')) #sets A2 to 'blah'
|
75
89
|
|
90
|
+
==== Changing Cells
|
91
|
+
workbook.worksheets[0][0][0].change_contents("", workbook.worksheets[0][0][0].formula) #sets A1 to empty string, preserves formula
|
76
92
|
|
77
93
|
==== Changing Fonts
|
78
94
|
workbook.worksheets[0].sheet_data[0][0].change_font_bold(true) #sets A1 to bold
|
@@ -114,17 +130,44 @@ bottom, center, distributed, top
|
|
114
130
|
workbook.worksheets[0].merge_cells(0,0,1,1) #merges A1:B2
|
115
131
|
|
116
132
|
==== Insert Row
|
117
|
-
|
133
|
+
This method will insert a row at specified index, pushing all rows below it down. It also copies styles from row above.
|
134
|
+
|
135
|
+
WARNING: Use of this method WILL break formulas referencing cells which have been moved, as the formulas do not adapt to the shifted rows
|
136
|
+
workbook.worksheets[0].insert_row(1)
|
118
137
|
|
119
138
|
==== Insert Column
|
120
|
-
|
139
|
+
This method will insert a column at specified index, pushing all columns to the right of it one to the right. It also copies styles from column to the left
|
140
|
+
|
141
|
+
WARNING: Use of this method WILL break formulas referencing cells which have been moved, as the formulas do not adapt to the shifted columns
|
142
|
+
workbook.worksheets[0].insert_column(1)
|
121
143
|
|
122
144
|
==== Delete Row
|
123
|
-
|
145
|
+
This method will delete a row at specified index, pushing all rows below it up.
|
146
|
+
|
147
|
+
WARNING: Use of this method WILL break formulas referencing cells which have been moved, as the formulas do not adapt to the shifted rows
|
148
|
+
workbook.worksheets[0].delete_row(1)
|
124
149
|
|
125
150
|
==== Delete Column
|
126
|
-
|
151
|
+
This method will delete a column at specified index, pushing all columns to the right of it left.
|
152
|
+
|
153
|
+
WARNING: Use of this method WILL break formulas referencing cells which have been moved, as the formulas do not adapt to the shifted columns
|
154
|
+
workbook.worksheets[0].delete_column(1)
|
155
|
+
|
156
|
+
==== Insert Cell
|
157
|
+
This method will insert a cell at specified position. It takes a :right or :down option, to shift cells either left or down upon inserting (nil means replacing the cell)
|
158
|
+
|
159
|
+
WARNING: Use of this method WILL break formulas referencing cells which have been moved, as the formulas do not adapt to the shifted cells
|
160
|
+
workbook.worksheets[0].insert_cell(0,0,"blah",formula=nil,:right) #inserts cell at A1, shifts cells in first row right
|
161
|
+
workbook.worksheets[0].insert_cell(0,0,"blah",formula=nil,:down) #inserts cell at A1, shifts cells in first column down
|
162
|
+
workbook.worksheets[0].insert_cell(0,0,"blah") #inserts cell at A1, shifts nothing
|
163
|
+
|
164
|
+
==== Delete Cell
|
165
|
+
This method will delete a cell at specified position. It takes a :left or :up option, to shift cells either up or left upon deletion (nil means simply deleting the cell contents)
|
127
166
|
|
167
|
+
WARNING: Use of this method WILL break formulas referencing cells which have been moved, as the formulas do not adapt to the shifted cells
|
168
|
+
workbook.worksheets[0].delete_cell(0,0,:left) #deletes A1, shifts contents of first row left
|
169
|
+
workbook.worksheets[0].delete_cell(0,0,:up) #deletes A1, shifts contents of first column up
|
170
|
+
workbook.worksheets[0].delete_cell(0,0) #deletes A1, does not shift cells
|
128
171
|
|
129
172
|
=== Writing
|
130
173
|
workbook.write("path/to/desired/Excel/file.xlsx")
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.1.
|
1
|
+
1.1.5
|
data/lib/rubyXL.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
$: << File.expand_path(File.dirname(__FILE__))
|
2
|
-
require File.expand_path(File.join(File.dirname(__FILE__),'workbook'))
|
3
|
-
require File.expand_path(File.join(File.dirname(__FILE__),
|
4
|
-
require File.expand_path(File.join(File.dirname(__FILE__),'worksheet'))
|
5
|
-
require File.expand_path(File.join(File.dirname(__FILE__),'cell'))
|
6
|
-
require File.expand_path(File.join(File.dirname(__FILE__),'parser'))
|
7
|
-
require File.expand_path(File.join(File.dirname(__FILE__),'color'))
|
2
|
+
require File.expand_path(File.join(File.dirname(__FILE__),'rubyXL','workbook'))
|
3
|
+
require File.expand_path(File.join(File.dirname(__FILE__),'rubyXL','private_class'))
|
4
|
+
require File.expand_path(File.join(File.dirname(__FILE__),'rubyXL','worksheet'))
|
5
|
+
require File.expand_path(File.join(File.dirname(__FILE__),'rubyXL','cell'))
|
6
|
+
require File.expand_path(File.join(File.dirname(__FILE__),'rubyXL','parser'))
|
7
|
+
require File.expand_path(File.join(File.dirname(__FILE__),'rubyXL','color'))
|
8
8
|
|
9
9
|
module RubyXL
|
10
10
|
end
|
File without changes
|
File without changes
|
File without changes
|
@@ -49,13 +49,13 @@ module RubyXL
|
|
49
49
|
node << "<t xml:space=\"preserve\">#{text}</t>"
|
50
50
|
end
|
51
51
|
end
|
52
|
-
|
53
52
|
|
54
|
-
|
53
|
+
string_nodes = files['sharedString'].css('si t')
|
55
54
|
wb.shared_strings = {}
|
56
|
-
|
57
|
-
|
58
|
-
wb.shared_strings[
|
55
|
+
string_nodes.each_with_index do |node,i|
|
56
|
+
string = node.children.to_s
|
57
|
+
wb.shared_strings[i] = string
|
58
|
+
wb.shared_strings[string] = i
|
59
59
|
end
|
60
60
|
end
|
61
61
|
|
@@ -77,7 +77,7 @@ module RubyXL
|
|
77
77
|
#2. Fill in the matrix with data from worksheet/shared_string files
|
78
78
|
#3. Apply styles
|
79
79
|
wb.worksheets.each_index do |i|
|
80
|
-
Parser.fill_worksheet(wb,i,files,shared_strings)
|
80
|
+
Parser.fill_worksheet(wb,i,files,wb.shared_strings)
|
81
81
|
end
|
82
82
|
|
83
83
|
return wb
|
@@ -225,7 +225,7 @@ module RubyXL
|
|
225
225
|
style_index = nil
|
226
226
|
|
227
227
|
data_type = value.attribute('t').to_s
|
228
|
-
|
228
|
+
|
229
229
|
if (value.css('v').to_s == "") || (value.css('v').children.to_s == "") #no data
|
230
230
|
cell_data = nil
|
231
231
|
elsif data_type == 's' #shared string
|
@@ -239,7 +239,7 @@ module RubyXL
|
|
239
239
|
data_type = ''
|
240
240
|
if(value.css('v').children.to_s =~ /\./) #is float
|
241
241
|
cell_data = Float(value.css('v').children.to_s)
|
242
|
-
else
|
242
|
+
else
|
243
243
|
cell_data = Integer(value.css('v').children.to_s)
|
244
244
|
end
|
245
245
|
end
|
File without changes
|
@@ -8,7 +8,7 @@ require File.expand_path(File.join(File.dirname(__FILE__),'writer','workbook_wri
|
|
8
8
|
require File.expand_path(File.join(File.dirname(__FILE__),'writer','styles_writer'))
|
9
9
|
require File.expand_path(File.join(File.dirname(__FILE__),'writer','shared_strings_writer'))
|
10
10
|
require File.expand_path(File.join(File.dirname(__FILE__),'writer','worksheet_writer'))
|
11
|
-
require 'zip'
|
11
|
+
require 'rubyXL/zip'
|
12
12
|
|
13
13
|
module RubyXL
|
14
14
|
class Workbook
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
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.1.
|
8
|
+
s.version = "1.1.5"
|
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-09-08}
|
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 = [
|
@@ -24,26 +24,26 @@ Gem::Specification.new do |s|
|
|
24
24
|
"Rakefile",
|
25
25
|
"VERSION",
|
26
26
|
"lib/.DS_Store",
|
27
|
-
"lib/Hash.rb",
|
28
|
-
"lib/cell.rb",
|
29
|
-
"lib/color.rb",
|
30
|
-
"lib/parser.rb",
|
31
|
-
"lib/private_class.rb",
|
32
27
|
"lib/rubyXL.rb",
|
33
|
-
"lib/
|
34
|
-
"lib/
|
35
|
-
"lib/
|
36
|
-
"lib/
|
37
|
-
"lib/
|
38
|
-
"lib/
|
39
|
-
"lib/
|
40
|
-
"lib/writer/
|
41
|
-
"lib/writer/
|
42
|
-
"lib/writer/
|
43
|
-
"lib/writer/
|
44
|
-
"lib/writer/
|
45
|
-
"lib/writer/
|
46
|
-
"lib/
|
28
|
+
"lib/rubyXL/Hash.rb",
|
29
|
+
"lib/rubyXL/cell.rb",
|
30
|
+
"lib/rubyXL/color.rb",
|
31
|
+
"lib/rubyXL/parser.rb",
|
32
|
+
"lib/rubyXL/private_class.rb",
|
33
|
+
"lib/rubyXL/workbook.rb",
|
34
|
+
"lib/rubyXL/worksheet.rb",
|
35
|
+
"lib/rubyXL/writer/app_writer.rb",
|
36
|
+
"lib/rubyXL/writer/calc_chain_writer.rb",
|
37
|
+
"lib/rubyXL/writer/content_types_writer.rb",
|
38
|
+
"lib/rubyXL/writer/core_writer.rb",
|
39
|
+
"lib/rubyXL/writer/root_rels_writer.rb",
|
40
|
+
"lib/rubyXL/writer/shared_strings_writer.rb",
|
41
|
+
"lib/rubyXL/writer/styles_writer.rb",
|
42
|
+
"lib/rubyXL/writer/theme_writer.rb",
|
43
|
+
"lib/rubyXL/writer/workbook_rels_writer.rb",
|
44
|
+
"lib/rubyXL/writer/workbook_writer.rb",
|
45
|
+
"lib/rubyXL/writer/worksheet_writer.rb",
|
46
|
+
"lib/rubyXL/zip.rb",
|
47
47
|
"rubyXL.gemspec",
|
48
48
|
"spec/lib/cell_spec.rb",
|
49
49
|
"spec/lib/color_spec.rb",
|
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: 25
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 1.1.
|
9
|
+
- 5
|
10
|
+
version: 1.1.5
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Vivek Bhagwat
|
@@ -15,11 +15,13 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-08
|
18
|
+
date: 2011-09-08 00:00:00 -04:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
22
|
+
type: :development
|
22
23
|
prerelease: false
|
24
|
+
name: shoulda
|
23
25
|
version_requirements: &id001 !ruby/object:Gem::Requirement
|
24
26
|
none: false
|
25
27
|
requirements:
|
@@ -29,11 +31,11 @@ dependencies:
|
|
29
31
|
segments:
|
30
32
|
- 0
|
31
33
|
version: "0"
|
32
|
-
name: shoulda
|
33
34
|
requirement: *id001
|
34
|
-
type: :development
|
35
35
|
- !ruby/object:Gem::Dependency
|
36
|
+
type: :development
|
36
37
|
prerelease: false
|
38
|
+
name: bundler
|
37
39
|
version_requirements: &id002 !ruby/object:Gem::Requirement
|
38
40
|
none: false
|
39
41
|
requirements:
|
@@ -45,11 +47,11 @@ dependencies:
|
|
45
47
|
- 0
|
46
48
|
- 0
|
47
49
|
version: 1.0.0
|
48
|
-
name: bundler
|
49
50
|
requirement: *id002
|
50
|
-
type: :development
|
51
51
|
- !ruby/object:Gem::Dependency
|
52
|
+
type: :development
|
52
53
|
prerelease: false
|
54
|
+
name: jeweler
|
53
55
|
version_requirements: &id003 !ruby/object:Gem::Requirement
|
54
56
|
none: false
|
55
57
|
requirements:
|
@@ -61,11 +63,11 @@ dependencies:
|
|
61
63
|
- 6
|
62
64
|
- 0
|
63
65
|
version: 1.6.0
|
64
|
-
name: jeweler
|
65
66
|
requirement: *id003
|
66
|
-
type: :development
|
67
67
|
- !ruby/object:Gem::Dependency
|
68
|
+
type: :development
|
68
69
|
prerelease: false
|
70
|
+
name: rcov
|
69
71
|
version_requirements: &id004 !ruby/object:Gem::Requirement
|
70
72
|
none: false
|
71
73
|
requirements:
|
@@ -75,11 +77,11 @@ dependencies:
|
|
75
77
|
segments:
|
76
78
|
- 0
|
77
79
|
version: "0"
|
78
|
-
name: rcov
|
79
80
|
requirement: *id004
|
80
|
-
type: :development
|
81
81
|
- !ruby/object:Gem::Dependency
|
82
|
+
type: :development
|
82
83
|
prerelease: false
|
84
|
+
name: nokogiri
|
83
85
|
version_requirements: &id005 !ruby/object:Gem::Requirement
|
84
86
|
none: false
|
85
87
|
requirements:
|
@@ -91,11 +93,11 @@ dependencies:
|
|
91
93
|
- 4
|
92
94
|
- 4
|
93
95
|
version: 1.4.4
|
94
|
-
name: nokogiri
|
95
96
|
requirement: *id005
|
96
|
-
type: :development
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
|
+
type: :development
|
98
99
|
prerelease: false
|
100
|
+
name: rubyzip
|
99
101
|
version_requirements: &id006 !ruby/object:Gem::Requirement
|
100
102
|
none: false
|
101
103
|
requirements:
|
@@ -107,11 +109,11 @@ dependencies:
|
|
107
109
|
- 9
|
108
110
|
- 4
|
109
111
|
version: 0.9.4
|
110
|
-
name: rubyzip
|
111
112
|
requirement: *id006
|
112
|
-
type: :development
|
113
113
|
- !ruby/object:Gem::Dependency
|
114
|
+
type: :development
|
114
115
|
prerelease: false
|
116
|
+
name: rspec
|
115
117
|
version_requirements: &id007 !ruby/object:Gem::Requirement
|
116
118
|
none: false
|
117
119
|
requirements:
|
@@ -123,9 +125,7 @@ dependencies:
|
|
123
125
|
- 3
|
124
126
|
- 4
|
125
127
|
version: 1.3.4
|
126
|
-
name: rspec
|
127
128
|
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: []
|
@@ -143,26 +143,26 @@ files:
|
|
143
143
|
- Rakefile
|
144
144
|
- VERSION
|
145
145
|
- lib/.DS_Store
|
146
|
-
- lib/Hash.rb
|
147
|
-
- lib/cell.rb
|
148
|
-
- lib/color.rb
|
149
|
-
- lib/parser.rb
|
150
|
-
- lib/private_class.rb
|
151
146
|
- lib/rubyXL.rb
|
152
|
-
- lib/
|
153
|
-
- lib/
|
154
|
-
- lib/
|
155
|
-
- lib/
|
156
|
-
- lib/
|
157
|
-
- lib/
|
158
|
-
- lib/
|
159
|
-
- lib/writer/
|
160
|
-
- lib/writer/
|
161
|
-
- lib/writer/
|
162
|
-
- lib/writer/
|
163
|
-
- lib/writer/
|
164
|
-
- lib/writer/
|
165
|
-
- lib/
|
147
|
+
- lib/rubyXL/Hash.rb
|
148
|
+
- lib/rubyXL/cell.rb
|
149
|
+
- lib/rubyXL/color.rb
|
150
|
+
- lib/rubyXL/parser.rb
|
151
|
+
- lib/rubyXL/private_class.rb
|
152
|
+
- lib/rubyXL/workbook.rb
|
153
|
+
- lib/rubyXL/worksheet.rb
|
154
|
+
- lib/rubyXL/writer/app_writer.rb
|
155
|
+
- lib/rubyXL/writer/calc_chain_writer.rb
|
156
|
+
- lib/rubyXL/writer/content_types_writer.rb
|
157
|
+
- lib/rubyXL/writer/core_writer.rb
|
158
|
+
- lib/rubyXL/writer/root_rels_writer.rb
|
159
|
+
- lib/rubyXL/writer/shared_strings_writer.rb
|
160
|
+
- lib/rubyXL/writer/styles_writer.rb
|
161
|
+
- lib/rubyXL/writer/theme_writer.rb
|
162
|
+
- lib/rubyXL/writer/workbook_rels_writer.rb
|
163
|
+
- lib/rubyXL/writer/workbook_writer.rb
|
164
|
+
- lib/rubyXL/writer/worksheet_writer.rb
|
165
|
+
- lib/rubyXL/zip.rb
|
166
166
|
- rubyXL.gemspec
|
167
167
|
- spec/lib/cell_spec.rb
|
168
168
|
- spec/lib/color_spec.rb
|