spreadsheet 1.2.6 → 1.2.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: c8aa45d407cf5aeadbf8af753a674fdf12dab84c
4
- data.tar.gz: 32a18ad8a2d79f9eb5df62f435560502c05bfbb8
2
+ SHA256:
3
+ metadata.gz: f3838959e9ca05cea64d92732af76a16989f192dee2ae8d6faa78f43f3148858
4
+ data.tar.gz: 6655bef2181febca0c1f052b557012f8ac08c35e1aa5a69d360e0b006b8231df
5
5
  SHA512:
6
- metadata.gz: 97f97bf780ece2ac6f25906106b1f62c1cb681cb91740620321875de8fcd2489dc97c592a4d143c52f1cd78c6f737e2b12a33fe3d6a0715ecd4f390461ffa713
7
- data.tar.gz: ddb5ee3babe8492581be775a760db74dd4f392f75773386c6a204682e051f20b56d004091741653691eba09f7e8433588945b266784747d95b5cfae4f0836180
6
+ metadata.gz: d215eec2e59d1e51a3d895b2dde467b48e3c807fedb871cd08c2f014fda0ddfb13af7629e1cfd4b72a65e56816fd2c635ce9f57ed744c156be11601aaa0fc3dc
7
+ data.tar.gz: 39963a66c937f064717bdbbe861ac786a2b3a3541409c0852da17f13d63c1c3dc449fc4f9b40bc1e31ca68bedc3a1fe0c43bdba8a32091249eec8d7240ce1140
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+ #
4
+ # This file was generated by Bundler.
5
+ #
6
+ # The application 'bundler' is installed as part of a gem, and
7
+ # this file is here to facilitate running it.
8
+ #
9
+
10
+ require "pathname"
11
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
12
+ Pathname.new(__FILE__).realpath)
13
+
14
+ require "rubygems"
15
+ require "bundler/setup"
16
+
17
+ load Gem.bin_path("bundler", "bundler")
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+ #
4
+ # This file was generated by Bundler.
5
+ #
6
+ # The application 'oletool' is installed as part of a gem, and
7
+ # this file is here to facilitate running it.
8
+ #
9
+
10
+ require "pathname"
11
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
12
+ Pathname.new(__FILE__).realpath)
13
+
14
+ require "rubygems"
15
+ require "bundler/setup"
16
+
17
+ load Gem.bin_path("ruby-ole", "oletool")
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+ #
4
+ # This file was generated by Bundler.
5
+ #
6
+ # The application 'rake' is installed as part of a gem, and
7
+ # this file is here to facilitate running it.
8
+ #
9
+
10
+ require "pathname"
11
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
12
+ Pathname.new(__FILE__).realpath)
13
+
14
+ require "rubygems"
15
+ require "bundler/setup"
16
+
17
+ load Gem.bin_path("rake", "rake")
data/bin/sow ADDED
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+ #
4
+ # This file was generated by Bundler.
5
+ #
6
+ # The application 'sow' is installed as part of a gem, and
7
+ # this file is here to facilitate running it.
8
+ #
9
+
10
+ require "pathname"
11
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
12
+ Pathname.new(__FILE__).realpath)
13
+
14
+ require "rubygems"
15
+ require "bundler/setup"
16
+
17
+ load Gem.bin_path("hoe", "sow")
@@ -1,18 +1,17 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+ #
4
+ # This file was generated by Bundler.
5
+ #
6
+ # The application 'xlsopcodes' is installed as part of a gem, and
7
+ # this file is here to facilitate running it.
8
+ #
2
9
 
3
- require 'spreadsheet'
10
+ require "pathname"
11
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
12
+ Pathname.new(__FILE__).realpath)
4
13
 
5
- source, target = ARGV
14
+ require "rubygems"
15
+ require "bundler/setup"
6
16
 
7
- if source.nil?
8
- puts "Usage: #{$0} <source> [<target>]"
9
- exit -1
10
- end
11
-
12
- target = target ? File.open(target, 'w') : STDOUT
13
-
14
- reader = Spreadsheet::Excel::Reader.new :print_opcodes => target
15
- reader.setup File.open(source)
16
-
17
- while tuple = reader.get_next_chunk
18
- end
17
+ load Gem.bin_path("spreadsheet", "xlsopcodes")
@@ -1,11 +1,5 @@
1
1
  require 'spreadsheet'
2
2
 
3
- warn <<-EOS
4
- [DEPRECATED] By requiring 'spreadsheet/excel' you are loading a Compatibility
5
- layer which provides a drop-in replacement for Spreadsheet::Excel
6
- versions <= 0.3.5.1. This code will be removed in Spreadsheet
7
- version 1.0.0
8
- EOS
9
3
  ##
10
4
  # Spreadsheet::Excel Compatibility Layer.
11
5
  # Drop-in replacement for Spreadsheet::Excel version <= 0.3.5.1
@@ -3,5 +3,5 @@
3
3
  module Spreadsheet
4
4
  ##
5
5
  # The version of Spreadsheet you are using.
6
- VERSION = '1.2.6'
6
+ VERSION = '1.2.7'
7
7
  end
Binary file
@@ -3,6 +3,8 @@
3
3
  require 'rubygems'
4
4
  require 'bundler'
5
5
  require 'find'
6
+ require 'simplecov'
7
+ SimpleCov.start
6
8
 
7
9
  $VERBOSE = true
8
10
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spreadsheet
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.6
4
+ version: 1.2.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hannes F. Wyss, Masaomi Hatakeyama, Zeno R.R. Davatz
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-01-22 00:00:00.000000000 Z
11
+ date: 2021-01-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ruby-ole
@@ -16,78 +16,71 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '1.0'
19
+ version: '0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: '1.0'
26
+ version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
- name: rdoc
28
+ name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: '4.0'
34
- - - "<"
35
- - !ruby/object:Gem::Version
36
- version: '7'
33
+ version: '0'
37
34
  type: :development
38
35
  prerelease: false
39
36
  version_requirements: !ruby/object:Gem::Requirement
40
37
  requirements:
41
38
  - - ">="
42
39
  - !ruby/object:Gem::Version
43
- version: '4.0'
44
- - - "<"
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: test-unit
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
45
53
  - !ruby/object:Gem::Version
46
- version: '7'
54
+ version: '0'
47
55
  - !ruby/object:Gem::Dependency
48
- name: hoe
56
+ name: simplecov
49
57
  requirement: !ruby/object:Gem::Requirement
50
58
  requirements:
51
- - - "~>"
59
+ - - ">="
52
60
  - !ruby/object:Gem::Version
53
- version: '3.17'
61
+ version: '0'
54
62
  type: :development
55
63
  prerelease: false
56
64
  version_requirements: !ruby/object:Gem::Requirement
57
65
  requirements:
58
- - - "~>"
66
+ - - ">="
59
67
  - !ruby/object:Gem::Version
60
- version: '3.17'
61
- description: |-
62
- The Spreadsheet Library is designed to read and write Spreadsheet Documents.
63
- As of version 0.6.0, only Microsoft Excel compatible spreadsheets are
64
- supported. Spreadsheet is a combination/complete rewrite of the
65
- Spreadsheet::Excel Library by Daniel J. Berger and the ParseExcel Library by
66
- Hannes Wyss. Spreadsheet can read, write and modify Spreadsheet Documents.
67
- email: zdavatz@ywesee.com
68
+ version: '0'
69
+ description: As of version 0.6.0, only Microsoft Excel compatible spreadsheets are
70
+ supported
71
+ email: hannes.wyss@gmail.com, mhatakeyama@ywesee.com, zdavatz@ywesee.com
68
72
  executables:
69
73
  - xlsopcodes
70
74
  extensions: []
71
- extra_rdoc_files:
72
- - GUIDE.md
73
- - History.md
74
- - LICENSE.txt
75
- - Manifest.txt
76
- - README.md
75
+ extra_rdoc_files: []
77
76
  files:
78
- - ".gitignore"
79
- - ".travis.yml"
80
- - Excel97-2007BinaryFileFormatSpecification.pdf
81
- - GUIDE.md
82
- - Gemfile
83
- - Gemfile.lock
84
- - History.md
85
77
  - LICENSE.txt
86
78
  - Manifest.txt
87
- - README.md
88
- - Rakefile
79
+ - bin/bundler
80
+ - bin/oletool
81
+ - bin/rake
82
+ - bin/sow
89
83
  - bin/xlsopcodes
90
- - excelfileformat.pdf
91
84
  - lib/parseexcel.rb
92
85
  - lib/parseexcel/parseexcel.rb
93
86
  - lib/parseexcel/parser.rb
@@ -130,11 +123,12 @@ files:
130
123
  - lib/spreadsheet/workbook.rb
131
124
  - lib/spreadsheet/worksheet.rb
132
125
  - lib/spreadsheet/writer.rb
133
- - spreadsheet.gemspec
134
126
  - test/data/test_adding_data_to_existing_file.xls
135
127
  - test/data/test_borders.xls
136
128
  - test/data/test_changes.xls
137
129
  - test/data/test_comment.xls
130
+ - test/data/test_compact_format_date.xls
131
+ - test/data/test_compact_many_rows.xls
138
132
  - test/data/test_copy.xls
139
133
  - test/data/test_datetime.xls
140
134
  - test/data/test_empty.xls
@@ -143,8 +137,10 @@ files:
143
137
  - test/data/test_margin.xls
144
138
  - test/data/test_merged_and_protected.xls
145
139
  - test/data/test_merged_cells.xls
140
+ - test/data/test_missing_format.xls
146
141
  - test/data/test_missing_row.xls
147
142
  - test/data/test_pagesetup.xls
143
+ - test/data/test_sizes.xls
148
144
  - test/data/test_text_drawing.xls
149
145
  - test/data/test_version_excel5.xls
150
146
  - test/data/test_version_excel95.xls
@@ -163,14 +159,12 @@ files:
163
159
  - test/workbook.rb
164
160
  - test/workbook_protection.rb
165
161
  - test/worksheet.rb
166
- homepage: https://github.com/zdavatz/spreadsheet
162
+ homepage: https://github.com/zdavatz/spreadsheet/
167
163
  licenses:
168
164
  - GPL-3.0
169
165
  metadata: {}
170
166
  post_install_message:
171
- rdoc_options:
172
- - "--main"
173
- - README.md
167
+ rdoc_options: []
174
168
  require_paths:
175
169
  - lib
176
170
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -184,9 +178,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
184
178
  - !ruby/object:Gem::Version
185
179
  version: '0'
186
180
  requirements: []
187
- rubyforge_project:
188
- rubygems_version: 2.6.8
181
+ rubygems_version: 3.2.3
189
182
  signing_key:
190
183
  specification_version: 4
191
184
  summary: The Spreadsheet Library is designed to read and write Spreadsheet Documents
192
- test_files: []
185
+ test_files:
186
+ - test/suite.rb
data/.gitignore DELETED
@@ -1,3 +0,0 @@
1
- tags
2
- *.swp
3
- /Gemfile.lock
@@ -1,46 +0,0 @@
1
- language: ruby
2
- dist: trusty
3
- sudo: false
4
- cache: bundler
5
- before_install:
6
- - "if $(ruby -e 'exit(RUBY_VERSION >= \"2.3.0\")'); then env -u RUBYOPT gem update --system; fi"
7
- - "if $(ruby -e 'exit(RUBY_VERSION >= \"2.3.0\")'); then env -u RUBYOPT gem install bundler --no-document; fi"
8
- - "if $(ruby -e 'exit(RUBY_VERSION < \"2.3.0\")'); then gem install bundler -v 1.17.3 --no-document; fi"
9
- bundler_args: --binstubs
10
- script: "bundle exec ruby test/suite.rb"
11
- rvm:
12
- - ruby-head
13
- - 2.6.3
14
- - 2.5.5
15
- - 2.4.5
16
- - 2.3.8
17
- - 2.2.10
18
- - 2.1.10
19
- - 2.0.0
20
- - 1.9.3
21
- - 1.9.2
22
- - 1.8.7
23
- - rbx-19mode
24
- - rbx-18mode
25
- - jruby-head
26
- - jruby-19mode
27
- - jruby-18mode
28
- - ree
29
- matrix:
30
- include:
31
- - rvm: 2.4.5
32
- env: RUBYOPT='--enable-frozen-string-literal --debug-frozen-string-literal' USE_LATEST_RUBY_OLE=yes
33
- - rvm: 2.5.5
34
- env: RUBYOPT='--enable-frozen-string-literal --debug-frozen-string-literal' USE_LATEST_RUBY_OLE=yes
35
- - rvm: 2.6.3
36
- env: RUBYOPT='--enable-frozen-string-literal --debug-frozen-string-literal' USE_LATEST_RUBY_OLE=yes
37
- allow_failures:
38
- - rvm: ruby-head
39
- - rvm: rbx-19mode
40
- - rvm: rbx-18mode
41
- - rvm: jruby-head
42
- - rvm: jruby-19mode
43
- - rvm: jruby-18mode
44
- - rvm: ree
45
- email:
46
- false
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