spreadsheet 1.1.3 → 1.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/Manifest.txt +1 -0
- data/bin/bundle +114 -0
- data/bin/bundler +17 -0
- data/bin/oletool +29 -0
- data/bin/rake +29 -0
- data/bin/sow +17 -0
- data/bin/xlsopcodes +22 -11
- data/lib/spreadsheet/excel/internals.rb +1 -1
- data/lib/spreadsheet/excel/reader/biff8.rb +1 -1
- data/lib/spreadsheet/excel/reader.rb +12 -10
- data/lib/spreadsheet/excel/workbook.rb +1 -2
- data/lib/spreadsheet/excel/writer/n_worksheet.rb +0 -75
- data/lib/spreadsheet/excel/writer/workbook.rb +5 -92
- data/lib/spreadsheet/excel/writer/worksheet.rb +3 -81
- data/lib/spreadsheet/excel.rb +0 -6
- data/lib/spreadsheet/format.rb +2 -2
- data/lib/spreadsheet/version.rb +7 -0
- data/lib/spreadsheet/workbook.rb +1 -1
- data/lib/spreadsheet/worksheet.rb +23 -13
- data/lib/spreadsheet.rb +2 -4
- data/test/data/test_compact_format_date.xls +0 -0
- data/test/data/test_compact_many_rows.xls +0 -0
- data/test/data/test_missing_format.xls +0 -0
- data/test/data/test_sizes.xls +0 -0
- data/test/excel/reader.rb +13 -0
- data/test/format.rb +2 -0
- data/test/integration.rb +36 -12
- data/test/suite.rb +2 -0
- data/test/worksheet.rb +26 -4
- metadata +65 -49
- data/.gitignore +0 -2
- data/.travis.yml +0 -35
- data/Excel97-2007BinaryFileFormatSpecification.pdf +0 -0
- data/GUIDE.md +0 -339
- data/Gemfile +0 -10
- data/Gemfile.lock +0 -23
- data/History.md +0 -746
- data/README.md +0 -113
- data/Rakefile +0 -21
- data/excelfileformat.pdf +0 -0
- data/spreadsheet.gemspec +0 -24
metadata
CHANGED
@@ -1,88 +1,101 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: spreadsheet
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1
|
4
|
+
version: 1.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
- Masaomi Hatakeyama, Zeno R.R. Davatz
|
7
|
+
- Hannes F. Wyss, Masaomi Hatakeyama, Zeno R.R. Davatz
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-01-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bigdecimal
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: ruby-ole
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
16
30
|
requirements:
|
17
31
|
- - ">="
|
18
32
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
33
|
+
version: '0'
|
20
34
|
type: :runtime
|
21
35
|
prerelease: false
|
22
36
|
version_requirements: !ruby/object:Gem::Requirement
|
23
37
|
requirements:
|
24
38
|
- - ">="
|
25
39
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
40
|
+
version: '0'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
42
|
+
name: rake
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
30
44
|
requirements:
|
31
|
-
- - "
|
45
|
+
- - ">="
|
32
46
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
47
|
+
version: '0'
|
34
48
|
type: :development
|
35
49
|
prerelease: false
|
36
50
|
version_requirements: !ruby/object:Gem::Requirement
|
37
51
|
requirements:
|
38
|
-
- - "
|
52
|
+
- - ">="
|
39
53
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
54
|
+
version: '0'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
56
|
+
name: test-unit
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
44
58
|
requirements:
|
45
|
-
- - "
|
59
|
+
- - ">="
|
46
60
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
61
|
+
version: '0'
|
48
62
|
type: :development
|
49
63
|
prerelease: false
|
50
64
|
version_requirements: !ruby/object:Gem::Requirement
|
51
65
|
requirements:
|
52
|
-
- - "
|
66
|
+
- - ">="
|
53
67
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: simplecov
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
description: As of version 0.6.0, only Microsoft Excel compatible spreadsheets are
|
84
|
+
supported
|
85
|
+
email: hannes.wyss@gmail.com, mhatakeyama@ywesee.com, zdavatz@ywesee.com
|
63
86
|
executables:
|
64
87
|
- xlsopcodes
|
65
88
|
extensions: []
|
66
|
-
extra_rdoc_files:
|
67
|
-
- GUIDE.md
|
68
|
-
- History.md
|
69
|
-
- LICENSE.txt
|
70
|
-
- Manifest.txt
|
71
|
-
- README.md
|
89
|
+
extra_rdoc_files: []
|
72
90
|
files:
|
73
|
-
- ".gitignore"
|
74
|
-
- ".travis.yml"
|
75
|
-
- Excel97-2007BinaryFileFormatSpecification.pdf
|
76
|
-
- GUIDE.md
|
77
|
-
- Gemfile
|
78
|
-
- Gemfile.lock
|
79
|
-
- History.md
|
80
91
|
- LICENSE.txt
|
81
92
|
- Manifest.txt
|
82
|
-
-
|
83
|
-
-
|
93
|
+
- bin/bundle
|
94
|
+
- bin/bundler
|
95
|
+
- bin/oletool
|
96
|
+
- bin/rake
|
97
|
+
- bin/sow
|
84
98
|
- bin/xlsopcodes
|
85
|
-
- excelfileformat.pdf
|
86
99
|
- lib/parseexcel.rb
|
87
100
|
- lib/parseexcel/parseexcel.rb
|
88
101
|
- lib/parseexcel/parser.rb
|
@@ -121,14 +134,16 @@ files:
|
|
121
134
|
- lib/spreadsheet/note.rb
|
122
135
|
- lib/spreadsheet/noteObject.rb
|
123
136
|
- lib/spreadsheet/row.rb
|
137
|
+
- lib/spreadsheet/version.rb
|
124
138
|
- lib/spreadsheet/workbook.rb
|
125
139
|
- lib/spreadsheet/worksheet.rb
|
126
140
|
- lib/spreadsheet/writer.rb
|
127
|
-
- spreadsheet.gemspec
|
128
141
|
- test/data/test_adding_data_to_existing_file.xls
|
129
142
|
- test/data/test_borders.xls
|
130
143
|
- test/data/test_changes.xls
|
131
144
|
- test/data/test_comment.xls
|
145
|
+
- test/data/test_compact_format_date.xls
|
146
|
+
- test/data/test_compact_many_rows.xls
|
132
147
|
- test/data/test_copy.xls
|
133
148
|
- test/data/test_datetime.xls
|
134
149
|
- test/data/test_empty.xls
|
@@ -137,8 +152,10 @@ files:
|
|
137
152
|
- test/data/test_margin.xls
|
138
153
|
- test/data/test_merged_and_protected.xls
|
139
154
|
- test/data/test_merged_cells.xls
|
155
|
+
- test/data/test_missing_format.xls
|
140
156
|
- test/data/test_missing_row.xls
|
141
157
|
- test/data/test_pagesetup.xls
|
158
|
+
- test/data/test_sizes.xls
|
142
159
|
- test/data/test_text_drawing.xls
|
143
160
|
- test/data/test_version_excel5.xls
|
144
161
|
- test/data/test_version_excel95.xls
|
@@ -157,14 +174,13 @@ files:
|
|
157
174
|
- test/workbook.rb
|
158
175
|
- test/workbook_protection.rb
|
159
176
|
- test/worksheet.rb
|
160
|
-
homepage:
|
177
|
+
homepage: https://github.com/zdavatz/spreadsheet/
|
161
178
|
licenses:
|
162
|
-
-
|
163
|
-
metadata:
|
179
|
+
- GPL-3.0
|
180
|
+
metadata:
|
181
|
+
changelog_uri: https://github.com/zdavatz/spreadsheet//blob/master/History.md
|
164
182
|
post_install_message:
|
165
|
-
rdoc_options:
|
166
|
-
- "--main"
|
167
|
-
- README.md
|
183
|
+
rdoc_options: []
|
168
184
|
require_paths:
|
169
185
|
- lib
|
170
186
|
required_ruby_version: !ruby/object:Gem::Requirement
|
@@ -178,9 +194,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
178
194
|
- !ruby/object:Gem::Version
|
179
195
|
version: '0'
|
180
196
|
requirements: []
|
181
|
-
|
182
|
-
rubygems_version: 2.5.1
|
197
|
+
rubygems_version: 3.2.3
|
183
198
|
signing_key:
|
184
199
|
specification_version: 4
|
185
200
|
summary: The Spreadsheet Library is designed to read and write Spreadsheet Documents
|
186
|
-
test_files:
|
201
|
+
test_files:
|
202
|
+
- test/suite.rb
|
data/.gitignore
DELETED
data/.travis.yml
DELETED
@@ -1,35 +0,0 @@
|
|
1
|
-
language: ruby
|
2
|
-
sudo: false
|
3
|
-
cache: bundler
|
4
|
-
before_install:
|
5
|
-
- gem install bundler
|
6
|
-
bundler_args: --binstubs
|
7
|
-
script: "bundle exec ruby test/suite.rb"
|
8
|
-
rvm:
|
9
|
-
- ruby-head
|
10
|
-
- 2.0.0
|
11
|
-
- 2.2.3
|
12
|
-
- 2.1.7
|
13
|
-
- 1.9.3
|
14
|
-
- 1.9.2
|
15
|
-
- 1.8.7
|
16
|
-
- rbx-19mode
|
17
|
-
- rbx-18mode
|
18
|
-
- jruby-head
|
19
|
-
- jruby-19mode
|
20
|
-
- jruby-18mode
|
21
|
-
- ree
|
22
|
-
matrix:
|
23
|
-
allow_failures:
|
24
|
-
- rvm: ruby-head
|
25
|
-
- rvm: rbx-19mode
|
26
|
-
- rvm: rbx-18mode
|
27
|
-
- rvm: jruby-head
|
28
|
-
- rvm: jruby-19mode
|
29
|
-
- rvm: jruby-18mode
|
30
|
-
- rvm: ree
|
31
|
-
notifications:
|
32
|
-
email:
|
33
|
-
recipients:
|
34
|
-
- yasaka@ywesee.com
|
35
|
-
- zdavatz@ywesee.com
|
Binary file
|
data/GUIDE.md
DELETED
@@ -1,339 +0,0 @@
|
|
1
|
-
# Getting Started with Spreadsheet
|
2
|
-
This guide is meant to get you started using Spreadsheet. By the end of it,
|
3
|
-
you should be able to read and write Spreadsheets.
|
4
|
-
|
5
|
-
Before you can do anything, you first need to make sure all that code is
|
6
|
-
loaded:
|
7
|
-
|
8
|
-
```ruby
|
9
|
-
require 'spreadsheet'
|
10
|
-
```
|
11
|
-
|
12
|
-
## Reading is easy!
|
13
|
-
|
14
|
-
Worksheets come in various encodings. You need to tell Spreadsheet which
|
15
|
-
encoding you want to deal with. The default is UTF-8
|
16
|
-
|
17
|
-
```ruby
|
18
|
-
Spreadsheet.client_encoding = 'UTF-8'
|
19
|
-
```
|
20
|
-
|
21
|
-
Let's open a workbook:
|
22
|
-
|
23
|
-
```ruby
|
24
|
-
book = Spreadsheet.open '/path/to/an/excel-file.xls'
|
25
|
-
```
|
26
|
-
|
27
|
-
We can either access all the worksheets in a workbook...
|
28
|
-
|
29
|
-
```ruby
|
30
|
-
book.worksheets
|
31
|
-
```
|
32
|
-
|
33
|
-
...or access them by index or name (encoded in your `client_encoding`).
|
34
|
-
|
35
|
-
```ruby
|
36
|
-
sheet1 = book.worksheet 0
|
37
|
-
sheet2 = book.worksheet 'Sheet1'
|
38
|
-
```
|
39
|
-
|
40
|
-
Now you can either iterate over all rows that contain some data. A call to
|
41
|
-
`Worksheet.each` without arguments will omit empty rows at the beginning of the
|
42
|
-
worksheet:
|
43
|
-
|
44
|
-
```ruby
|
45
|
-
sheet1.each do |row|
|
46
|
-
# do something interesting with a row
|
47
|
-
end
|
48
|
-
```
|
49
|
-
|
50
|
-
Or you can tell a worksheet how many rows should be omitted at the beginning.
|
51
|
-
The following starts at the 3rd row, regardless of whether or not it or the
|
52
|
-
preceding rows contain any data:
|
53
|
-
|
54
|
-
```ruby
|
55
|
-
sheet2.each 2 do |row|
|
56
|
-
# do something interesting with a row
|
57
|
-
end
|
58
|
-
```
|
59
|
-
|
60
|
-
Or you can access rows directly, by their index (0-based):
|
61
|
-
|
62
|
-
```ruby
|
63
|
-
row = sheet1.row(3)
|
64
|
-
```
|
65
|
-
|
66
|
-
To access the values stored in a row, treat the row like an array.
|
67
|
-
|
68
|
-
```ruby
|
69
|
-
row[0]
|
70
|
-
```
|
71
|
-
|
72
|
-
This will return a `String`, a `Float`, an `Integer`, a `Formula`, a `Link` or a `Date`
|
73
|
-
or `DateTime` object - or `nil` if the cell is empty.
|
74
|
-
|
75
|
-
More information about the formatting of a cell can be found in the format
|
76
|
-
with the equivalent index:
|
77
|
-
|
78
|
-
```ruby
|
79
|
-
row.format 2
|
80
|
-
```
|
81
|
-
|
82
|
-
## Writing is easy
|
83
|
-
As before, make sure you have Spreadsheet required and the client_encoding
|
84
|
-
set. Then make a new Workbook:
|
85
|
-
|
86
|
-
```ruby
|
87
|
-
book = Spreadsheet::Workbook.new
|
88
|
-
```
|
89
|
-
|
90
|
-
Add a Worksheet and you're good to go:
|
91
|
-
|
92
|
-
```ruby
|
93
|
-
sheet1 = book.create_worksheet
|
94
|
-
```
|
95
|
-
|
96
|
-
This will create a Worksheet with the Name "Worksheet1". If you prefer another
|
97
|
-
name, you may do either of the following:
|
98
|
-
|
99
|
-
```ruby
|
100
|
-
sheet2 = book.create_worksheet :name => 'My Second Worksheet'
|
101
|
-
sheet1.name = 'My First Worksheet'
|
102
|
-
```
|
103
|
-
|
104
|
-
Now, add data to the Worksheet, using either Worksheet#[]=,
|
105
|
-
Worksheet#update_row, or work directly on Row using any of the Array-Methods
|
106
|
-
that modify an Array in place:
|
107
|
-
|
108
|
-
```ruby
|
109
|
-
sheet1.row(0).concat %w{Name Country Acknowlegement}
|
110
|
-
sheet1[1,0] = 'Japan'
|
111
|
-
row = sheet1.row(1)
|
112
|
-
row.push 'Creator of Ruby'
|
113
|
-
row.unshift 'Yukihiro Matsumoto'
|
114
|
-
sheet1.row(2).replace [ 'Daniel J. Berger', 'U.S.A.',
|
115
|
-
'Author of original code for Spreadsheet::Excel' ]
|
116
|
-
sheet1.row(3).push 'Charles Lowe', 'Author of the ruby-ole Library'
|
117
|
-
sheet1.row(3).insert 1, 'Unknown'
|
118
|
-
sheet1.update_row 4, 'Hannes Wyss', 'Switzerland', 'Author'
|
119
|
-
```
|
120
|
-
|
121
|
-
Add some Formatting for flavour:
|
122
|
-
|
123
|
-
```ruby
|
124
|
-
sheet1.row(0).height = 18
|
125
|
-
|
126
|
-
format = Spreadsheet::Format.new :color => :blue,
|
127
|
-
:weight => :bold,
|
128
|
-
:size => 18
|
129
|
-
sheet1.row(0).default_format = format
|
130
|
-
|
131
|
-
bold = Spreadsheet::Format.new :weight => :bold
|
132
|
-
4.times do |x| sheet1.row(x + 1).set_format(0, bold) end
|
133
|
-
```
|
134
|
-
|
135
|
-
And finally, write the Excel File:
|
136
|
-
|
137
|
-
```ruby
|
138
|
-
book.write '/path/to/output/excel-file.xls'
|
139
|
-
```
|
140
|
-
|
141
|
-
## Modifying an existing Document
|
142
|
-
|
143
|
-
Spreadsheet has some limited support for modifying an existing Document. This
|
144
|
-
is done by copying verbatim those parts of an Excel-document which Spreadsheet
|
145
|
-
can't modify (yet), recalculating relevant offsets, and writing the data that
|
146
|
-
can be changed.
|
147
|
-
Here's what should work:
|
148
|
-
|
149
|
-
* Adding, changing and deleting cells.
|
150
|
-
* You should be able to fill in Data to be evaluated by predefined Formulas
|
151
|
-
|
152
|
-
Limitations:
|
153
|
-
|
154
|
-
* Spreadsheet can only write BIFF8 (Excel97 and higher). The results of
|
155
|
-
modifying an earlier version of Excel are undefined.
|
156
|
-
* Spreadsheet does not modify Formatting at present. That means in particular
|
157
|
-
that if you set the Value of a Cell to a Date, it can only be read as a
|
158
|
-
Date if its Format was set correctly prior to the change.
|
159
|
-
* Although it is theoretically possible, it is not recommended to write the
|
160
|
-
resulting Document back to the same File/IO that it was read from.
|
161
|
-
|
162
|
-
And here's how it works:
|
163
|
-
|
164
|
-
```ruby
|
165
|
-
book = Spreadsheet.open '/path/to/an/excel-file.xls'
|
166
|
-
sheet = book.worksheet 0
|
167
|
-
sheet.each do |row|
|
168
|
-
row[0] *= 2
|
169
|
-
end
|
170
|
-
book.write '/path/to/output/excel-file.xls'
|
171
|
-
```
|
172
|
-
|
173
|
-
Or you can directly access the cell that you want and add your text on it:
|
174
|
-
|
175
|
-
```ruby
|
176
|
-
sheet.rows[2][1] = "X"
|
177
|
-
```
|
178
|
-
|
179
|
-
## Date and DateTime
|
180
|
-
Excel does not know a separate Datatype for Dates. Instead it encodes Dates
|
181
|
-
into standard floating-point numbers and recognizes a Date-Cell by its
|
182
|
-
formatting-string:
|
183
|
-
|
184
|
-
```ruby
|
185
|
-
row.format(3).number_format
|
186
|
-
```
|
187
|
-
|
188
|
-
Whenever a Cell's Format describes a Date or Time, Spreadsheet will give you
|
189
|
-
the decoded Date or DateTime value. Should you need to access the underlying
|
190
|
-
Float, you may do the following:
|
191
|
-
|
192
|
-
```ruby
|
193
|
-
row.at(3)
|
194
|
-
```
|
195
|
-
|
196
|
-
If for some reason the Date-recognition fails, you may force Date-decoding:
|
197
|
-
|
198
|
-
```ruby
|
199
|
-
row.date(3)
|
200
|
-
row.datetime(3)
|
201
|
-
```
|
202
|
-
|
203
|
-
When you set the value of a Cell to a Date, Time or DateTime, Spreadsheet will
|
204
|
-
try to set the cell's number-format to a corresponding value (one of Excel's
|
205
|
-
builtin formats). If you have already defined a Date- or DateTime-format,
|
206
|
-
Spreadsheet will use that instead. If a format has already been applied to
|
207
|
-
a particular Cell, Spreadsheet will leave it untouched:
|
208
|
-
|
209
|
-
```ruby
|
210
|
-
row[4] = Date.new 1975, 8, 21
|
211
|
-
# -> assigns the builtin Date-Format: 'M/D/YY'
|
212
|
-
book.add_format Format.new(:number_format => 'DD.MM.YYYY hh:mm:ss')
|
213
|
-
row[5] = DateTime.new 2008, 10, 12, 11, 59
|
214
|
-
# -> assigns the added DateTime-Format: 'DD.MM.YYYY hh:mm:ss'
|
215
|
-
row.set_format 6, Format.new(:number_format => 'D-MMM-YYYY')
|
216
|
-
row[6] = Time.new 2008, 10, 12
|
217
|
-
# -> the Format of cell 6 is left unchanged.
|
218
|
-
```
|
219
|
-
|
220
|
-
## Outline (Grouping) and Hiding
|
221
|
-
Spreadsheet supports outline (grouping) and hiding functions from version
|
222
|
-
0.6.5. In order to hide rows or columns, you can use 'hidden' property.
|
223
|
-
As for outline, 'outline_level' property is also available. You can use
|
224
|
-
both 'hidden' and 'outline_level' at the same time.
|
225
|
-
|
226
|
-
You can create a new file with outline and hiding rows and columns as
|
227
|
-
follows:
|
228
|
-
|
229
|
-
```ruby
|
230
|
-
require 'spreadsheet'
|
231
|
-
|
232
|
-
# create a new book and sheet
|
233
|
-
book = Spreadsheet::Workbook.new
|
234
|
-
sheet = book.create_worksheet
|
235
|
-
5.times {|j| 5.times {|i| sheet[j,i] = (i+1)*10**j}}
|
236
|
-
|
237
|
-
# column
|
238
|
-
sheet.column(2).hidden = true
|
239
|
-
sheet.column(3).hidden = true
|
240
|
-
sheet.column(2).outline_level = 1
|
241
|
-
sheet.column(3).outline_level = 1
|
242
|
-
|
243
|
-
# row
|
244
|
-
sheet.row(2).hidden = true
|
245
|
-
sheet.row(3).hidden = true
|
246
|
-
sheet.row(2).outline_level = 1
|
247
|
-
sheet.row(3).outline_level = 1
|
248
|
-
|
249
|
-
# save file
|
250
|
-
book.write 'out.xls'
|
251
|
-
```
|
252
|
-
|
253
|
-
Also you can read an existing file and change the hidden and outline
|
254
|
-
properties. Here is the example below:
|
255
|
-
|
256
|
-
```ruby
|
257
|
-
require 'spreadsheet'
|
258
|
-
|
259
|
-
# read an existing file
|
260
|
-
file = ARGV[0]
|
261
|
-
book = Spreadsheet.open(file, 'rb')
|
262
|
-
sheet= book.worksheet(0)
|
263
|
-
|
264
|
-
# column
|
265
|
-
sheet.column(2).hidden = true
|
266
|
-
sheet.column(3).hidden = true
|
267
|
-
sheet.column(2).outline_level = 1
|
268
|
-
sheet.column(3).outline_level = 1
|
269
|
-
|
270
|
-
# row
|
271
|
-
sheet.row(2).hidden = true
|
272
|
-
sheet.row(3).hidden = true
|
273
|
-
sheet.row(2).outline_level = 1
|
274
|
-
sheet.row(3).outline_level = 1
|
275
|
-
|
276
|
-
# save file
|
277
|
-
book.write "out.xls"
|
278
|
-
```
|
279
|
-
|
280
|
-
Notes
|
281
|
-
* The outline_level should be under 8, which is due to the Excel data format.
|
282
|
-
|
283
|
-
## Allow access to rendered output instead of just writing a file
|
284
|
-
|
285
|
-
```ruby
|
286
|
-
file_contents = StringIO.new
|
287
|
-
book.write file_contents # => Now file_contents contains the rendered file output
|
288
|
-
```
|
289
|
-
|
290
|
-
Also see: https://github.com/zdavatz/spreadsheet/issues/125#issuecomment-75541041
|
291
|
-
|
292
|
-
## More about Encodings
|
293
|
-
Spreadsheet assumes it's running on Ruby 1.8 with Iconv-support. It is your
|
294
|
-
responsibility to handle Conversion Errors, or to prevent them e.g. by using
|
295
|
-
the Iconv Transliteration and Ignore flags:
|
296
|
-
Spreadsheet.client_encoding = 'LATIN1//TRANSLIT//IGNORE'
|
297
|
-
|
298
|
-
## Page setup (for printing)
|
299
|
-
|
300
|
-
```ruby
|
301
|
-
sheet.pagesetup[:orientation] = :landscape # or :portrait (default)
|
302
|
-
sheet.pagesetup[:adjust_to] = 85 # default 100
|
303
|
-
```
|
304
|
-
|
305
|
-
## Backward Compatibility
|
306
|
-
Spreadsheet is designed to be a drop-in replacement for both ParseExcel and
|
307
|
-
Spreadsheet::Excel. It provides a number of require-paths for backward
|
308
|
-
compatibility with its predecessors. If you have been working with ParseExcel,
|
309
|
-
you have probably used one or more of the following:
|
310
|
-
|
311
|
-
```ruby
|
312
|
-
require 'parseexcel'
|
313
|
-
require 'parseexcel/parseexcel'
|
314
|
-
require 'parseexcel/parser'
|
315
|
-
```
|
316
|
-
|
317
|
-
Either of the above will define the ParseExcel.parse method as a facade to
|
318
|
-
Spreadsheet.open. Additionally, this will alter Spreadsheets behavior to define
|
319
|
-
the ParseExcel::Worksheet::Cell class and fill each parsed Row with instances
|
320
|
-
thereof, which in turn provide ParseExcel's Cell#to_s(encoding) and Cell#date
|
321
|
-
methods.
|
322
|
-
You will have to manually uninstall the parseexcel library.
|
323
|
-
|
324
|
-
If you are upgrading from Spreadsheet::Excel, you were probably using
|
325
|
-
Workbook#add_worksheet and Worksheet#write, write_row or write_column.
|
326
|
-
Use the following to load the code which provides them:
|
327
|
-
|
328
|
-
```ruby
|
329
|
-
require 'spreadsheet/excel'
|
330
|
-
```
|
331
|
-
|
332
|
-
Again, you will have to manually uninstall the spreadsheet-excel library.
|
333
|
-
|
334
|
-
If you perform fancy formatting, you may run into trouble as the
|
335
|
-
Format implementation has changed considerably. If that is the case, please
|
336
|
-
drop me a line at "zdavatz at ywesee dot com" and I will try to help you. Don't
|
337
|
-
forget to include the offending code-snippet!
|
338
|
-
|
339
|
-
All compatibility code is deprecated and will be removed in version 1.0.0
|
data/Gemfile
DELETED
data/Gemfile.lock
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
GEM
|
2
|
-
remote: https://rubygems.org/
|
3
|
-
specs:
|
4
|
-
hoe (3.14.2)
|
5
|
-
rake (>= 0.8, < 11.0)
|
6
|
-
minitest (5.8.2)
|
7
|
-
power_assert (0.2.4)
|
8
|
-
rake (10.4.2)
|
9
|
-
ruby-ole (1.2.11.8)
|
10
|
-
test-unit (3.1.5)
|
11
|
-
power_assert
|
12
|
-
|
13
|
-
PLATFORMS
|
14
|
-
ruby
|
15
|
-
|
16
|
-
DEPENDENCIES
|
17
|
-
hoe (>= 3.4)
|
18
|
-
minitest
|
19
|
-
ruby-ole
|
20
|
-
test-unit
|
21
|
-
|
22
|
-
BUNDLED WITH
|
23
|
-
1.10.6
|