spreadsheet 0.6.4.1 → 0.6.5.0

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/GUIDE.txt CHANGED
@@ -168,6 +168,64 @@ a particular Cell, Spreadsheet will leave it untouched:
168
168
  row[6] = Time.new 2008, 10, 12
169
169
  # -> the Format of cell 6 is left unchanged.
170
170
 
171
+ == Outline (Grouping) and Hiding
172
+ Spreadsheet supports outline (grouping) and hiding functions from version
173
+ 0.6.5. In order to hide rows or columns, you can use 'hidden' property.
174
+ As for outline, 'outline_level' property is also available. You can use
175
+ both 'hidden' and 'outline_level' at the same time.
176
+
177
+ You can create a new file with outline and hiding rows and columns as
178
+ follows:
179
+
180
+ require 'spreadsheet'
181
+
182
+ # create a new book and sheet
183
+ book = Spreadsheet::Workbook.new
184
+ sheet = book.create_worksheet
185
+ 5.times {|j| 5.times {|i| sheet[j,i] = (i+1)*10**j}}
186
+
187
+ # column
188
+ sheet.column(2).hidden = true
189
+ sheet.column(3).hidden = true
190
+ sheet.column(2).outline_level = 1
191
+ sheet.column(3).outline_level = 1
192
+
193
+ # row
194
+ sheet.row(2).hidden = true
195
+ sheet.row(3).hidden = true
196
+ sheet.row(2).outline_level = 1
197
+ sheet.row(3).outline_level = 1
198
+
199
+ # save file
200
+ book.write 'out.xls'
201
+
202
+ Also you can read an existing file and change the hidden and outline
203
+ properties. Here is the example below:
204
+
205
+ require 'spreadsheet'
206
+
207
+ # read an existing file
208
+ file = ARGV[0]
209
+ book = Spreadsheet.open(file, 'rb')
210
+ sheet= book.worksheet(0)
211
+
212
+ # column
213
+ sheet.column(2).hidden = true
214
+ sheet.column(3).hidden = true
215
+ sheet.column(2).outline_level = 1
216
+ sheet.column(3).outline_level = 1
217
+
218
+ # row
219
+ sheet.row(2).hidden = true
220
+ sheet.row(3).hidden = true
221
+ sheet.row(2).outline_level = 1
222
+ sheet.row(3).outline_level = 1
223
+
224
+ # save file
225
+ book.write "out.xls"
226
+
227
+ Notes
228
+ * The outline_level should be under 8, which is due to the Excel data format.
171
229
 
172
230
  == More about Encodings
173
231
  Spreadsheet assumes it's running on Ruby 1.8 with Iconv-support. It is your
data/History.txt CHANGED
@@ -1,3 +1,15 @@
1
+ === 0.6.5 / 07.12.2010
2
+
3
+ * 2 Enhancements courtesy to ISS AG.
4
+
5
+ * Outlining (Grouping) of lines and columns is now possible. The outlining
6
+ maximum is 8. This means you can do 8 subgroups in a group.
7
+
8
+ * Hiding and Unhiding of lines and columns is now possible.
9
+
10
+ * Both of above two points is now possible by creating a new Excel File from
11
+ scratch or editing an existing XLS and adding groups or hiding lines to it.
12
+
1
13
  === 0.6.4.1 / 2009-09-17
2
14
 
3
15
  * 3 Bugfixes
data/README.txt CHANGED
@@ -1,14 +1,13 @@
1
- Last Update: 17.09.2009, 16.32 - hwyss
1
+ Last Update: 08.12.2010 - Zeno Davatz
2
2
 
3
3
 
4
4
  = Spreadsheet
5
5
 
6
6
  http://spreadsheet.rubyforge.org
7
- http://scm.ywesee.com/spreadsheet
8
7
 
9
8
  For a viewable directory of all recent changes, please see:
10
9
 
11
- http://scm.ywesee.com/?p=spreadsheet;a=summary
10
+ http://scm.ywesee.com/?p=spreadsheet/.git;a=summary
12
11
 
13
12
  For Non-GPLv3 commercial licencing, please see:
14
13
 
@@ -26,6 +25,7 @@ Hannes Wyss. Spreadsheet can read, write and modify Spreadsheet Documents.
26
25
 
27
26
  == What's new?
28
27
 
28
+ * Supported outline (grouping) functions
29
29
  * Significantly improved memory-efficiency when reading large Excel Files
30
30
  * Limited Spreadsheet modification support
31
31
  * Improved handling of String Encodings
@@ -45,7 +45,6 @@ Hannes Wyss. Spreadsheet can read, write and modify Spreadsheet Documents.
45
45
  == Dependencies
46
46
 
47
47
  * ruby 1.8
48
- * Iconv
49
48
  * ruby-ole[http://code.google.com/p/ruby-ole/]
50
49
 
51
50
 
@@ -63,6 +62,13 @@ Using RubyGems[http://www.rubygems.org]:
63
62
  If you don't like RubyGems[http://www.rubygems.org], let me know which
64
63
  installation solution you prefer and I'll include it in the future.
65
64
 
65
+ If you can use 'rake' and 'hoe' library is also installed, you can
66
+ build a gem package as follows:
67
+
68
+ * rake gem
69
+
70
+ The gem package is built in pkg directory.
71
+
66
72
 
67
73
  == Authors
68
74
 
@@ -75,7 +81,7 @@ ParseExcel:
75
81
  Copyright (c) 2003 by Hannes Wyss (hannes.wyss@gmail.com)
76
82
 
77
83
  New Code:
78
- Copyright (c) 2008 by Hannes Wyss (hannes.wyss@gmail.com)
84
+ Copyright (c) 2010 ywesee GmbH (mhatakeyama@ywesee.com, zdavatz@ywesee.com)
79
85
 
80
86
 
81
87
  == License
data/Rakefile CHANGED
@@ -1,5 +1,7 @@
1
1
  # -*- ruby -*-
2
2
 
3
+ $: << File.expand_path("./lib", File.dirname(__FILE__))
4
+
3
5
  require 'rubygems'
4
6
  require 'hoe'
5
7
  require './lib/spreadsheet.rb'
@@ -8,7 +10,7 @@ ENV['RDOCOPT'] = '-c utf8'
8
10
 
9
11
  Hoe.new('spreadsheet', Spreadsheet::VERSION) do |p|
10
12
  # p.rubyforge_name = 'spreadsheetx' # if different than lowercase project name
11
- p.developer('Hannes Wyss', 'hannes.wyss@gmail.com')
13
+ p.developer('Masaomi Hatakeyama, Zeno R.R. Davatz','mhatakeyama@ywesee.com, zdavatz@ywesee.com')
12
14
  p.remote_rdoc_dir = ''
13
15
  p.extra_deps << 'ruby-ole'
14
16
  end
data/lib/spreadsheet.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  ### Spreadsheet - A Library for reading and writing Spreadsheet Documents.
2
2
  #
3
- # Copyright (C) 2008 Hannes Wyss
3
+ # Copyright (C) 2008-2010 ywesee GmbH
4
4
  #
5
5
  # This program is free software: you can redistribute it and/or modify
6
6
  # it under the terms of the GNU General Public License as published by
@@ -17,9 +17,9 @@
17
17
  #
18
18
  # Contact Information:
19
19
  #
20
- # E-Mail: hannes.wyss@gmail.com
20
+ # E-Mail: mhatakeyama@ywesee.com, zdavatz@ywesee.com
21
21
  # P-Mail: ywesee GmbH
22
- # Hannes Wyss
22
+ # Zeno R.R. Davatz
23
23
  # Winterthurerstrasse 52
24
24
  # 8006 Zürich
25
25
  ### Switzerland
@@ -42,7 +42,7 @@ module Spreadsheet
42
42
 
43
43
  ##
44
44
  # The version of Spreadsheet you are using.
45
- VERSION = '0.6.4.1'
45
+ VERSION = '0.6.5.0'
46
46
 
47
47
  ##
48
48
  # Default client Encoding. Change this value if your application uses a
@@ -216,7 +216,7 @@ class Reader
216
216
  :width => width.to_f / 256,
217
217
  :hidden => (opts & 0x0001) > 0,
218
218
  :collapsed => (opts & 0x1000) > 0,
219
- :outline_level => (opts & 0x0700)
219
+ :outline_level => (opts & 0x0700) / 256
220
220
  column.worksheet = worksheet
221
221
  worksheet.columns[col] = column
222
222
  end
@@ -830,6 +830,8 @@ class Reader
830
830
  #when :index # ○ INDEX ➜ 5.7 (Row Blocks), ➜ 6.55
831
831
  # TODO: if there are changes in rows, omit index when writing
832
832
  #read_index worksheet, work, pos, len
833
+ when :guts # GUTS 5.53
834
+ read_guts worksheet, work, pos, len
833
835
  when :colinfo # ○○ COLINFO ➜ 6.18
834
836
  read_colinfo worksheet, work, pos, len
835
837
  when :dimensions # ● DIMENSIONS ➜ 6.31
@@ -849,6 +851,18 @@ class Reader
849
851
  previous = op
850
852
  end
851
853
  end
854
+ def read_guts worksheet, work, pos, len
855
+ # Offset Size Contents
856
+ # 0 2 Width of the area to display row outlines (left of the sheet), in pixel
857
+ # 2 2 Height of the area to display column outlines (above the sheet), in pixel
858
+ # 4 2 Number of visible row outline levels (used row levels + 1; or 0, if not used)
859
+ # 6 2 Number of visible column outline levels (used column levels + 1; or 0, if not used)
860
+ width, height, row_level, col_level = work.unpack 'v4'
861
+ worksheet.guts[:width] = width
862
+ worksheet.guts[:height] = height
863
+ worksheet.guts[:row_level] = row_level
864
+ worksheet.guts[:col_level] = col_level
865
+ end
852
866
  def read_style work, pos, len
853
867
  # User-Defined Cell Styles:
854
868
  # Offset Size Contents
@@ -1,7 +1,7 @@
1
1
  require 'spreadsheet/workbook'
2
2
  require 'spreadsheet/excel/offset'
3
3
  require 'spreadsheet/excel/writer'
4
- require 'ole/file_system'
4
+ require 'ole/storage'
5
5
 
6
6
  module Spreadsheet
7
7
  module Excel
@@ -11,13 +11,14 @@ module Spreadsheet
11
11
  class Worksheet < Spreadsheet::Worksheet
12
12
  include Spreadsheet::Excel::Offset
13
13
  offset :dimensions
14
- attr_reader :offset, :ole, :links
14
+ attr_reader :offset, :ole, :links, :guts
15
15
  def initialize opts = {}
16
16
  @row_addresses = nil
17
17
  super
18
18
  @offset, @ole, @reader = opts[:offset], opts[:ole], opts[:reader]
19
19
  @dimensions = nil
20
20
  @links = {}
21
+ @guts = {}
21
22
  end
22
23
  def add_link row, column, link
23
24
  @links.store [row, column], link
@@ -3,7 +3,7 @@ require 'spreadsheet/writer'
3
3
  require 'spreadsheet/excel/writer/biff8'
4
4
  require 'spreadsheet/excel/writer/format'
5
5
  require 'spreadsheet/excel/writer/worksheet'
6
- require 'ole/file_system'
6
+ require 'ole/storage'
7
7
 
8
8
  module Spreadsheet
9
9
  module Excel
@@ -240,6 +240,15 @@ class Worksheet
240
240
  write_multiples row, first_idx, multiples if multiples
241
241
  end
242
242
  def write_changes reader, endpos, sst_status
243
+
244
+ ## FIXME this is not smart solution to update outline_level.
245
+ # without this process, outlines in row disappear in MS Excel.
246
+ @worksheet.row_count.times do |i|
247
+ if @worksheet.row(i).outline_level > 0
248
+ @worksheet.row(i).outline_level = @worksheet.row(i).outline_level
249
+ end
250
+ end
251
+
243
252
  reader.seek @worksheet.offset
244
253
  blocks = row_blocks
245
254
  lastpos = reader.pos
@@ -296,6 +305,13 @@ and minimal code that generates this warning. Thanks!
296
305
  lastpos = pos + len
297
306
  reader.seek lastpos
298
307
  end
308
+
309
+ # Necessary for outline (grouping) and hiding functions
310
+ # but these below are not necessary to run
311
+ # if [Row|Column]#hidden? = false and [Row|Column]#outline_level == 0
312
+ write_colinfos
313
+ write_guts
314
+
299
315
  @io.write reader.read(endpos - lastpos)
300
316
  end
301
317
  def write_colinfo bunch
@@ -448,6 +464,7 @@ and minimal code that generates this warning. Thanks!
448
464
  # ○ PRINTGRIDLINES ➜ 5.80
449
465
  # ○ GRIDSET ➜ 5.52
450
466
  # ○ GUTS ➜ 5.53
467
+ write_guts
451
468
  # ○ DEFAULTROWHEIGHT ➜ 5.31
452
469
  write_defaultrowheight
453
470
  # ○ WSBOOL ➜ 5.113
@@ -483,6 +500,28 @@ and minimal code that generates this warning. Thanks!
483
500
  # ● EOF ➜ 5.36
484
501
  write_eof
485
502
  end
503
+ ##
504
+ # Write record that contains information about the layout of outline symbols.
505
+ def write_guts
506
+ # find the maximum outline_level in rows and columns
507
+ row_outline_level = 0
508
+ col_outline_level = 0
509
+ if(row = @worksheet.rows.select{|x| x!=nil}.max{|a,b| a.outline_level <=> b.outline_level})
510
+ row_outline_level = row.outline_level
511
+ end
512
+ if(col = @worksheet.columns.select{|x| x!=nil}.max{|a,b| a.outline_level <=> b.outline_level})
513
+ col_outline_level = col.outline_level
514
+ end
515
+ # set data
516
+ data = [
517
+ 0, # Width of the area to display row outlines (left of the sheet), in pixel
518
+ 0, # Height of the area to display column outlines (above the sheet), in pixel
519
+ row_outline_level+1, # Number of visible row outline levels (used row levels+1; or 0,if not used)
520
+ col_outline_level+1 # Number of visible column outline levels (used column levels+1; or 0,if not used)
521
+ ]
522
+ # write record
523
+ write_op opcode(:guts), data.pack('v4')
524
+ end
486
525
  def write_hlink row, col, link
487
526
  # FIXME: only Hyperlinks are supported at present.
488
527
  cell_range = [
@@ -793,6 +832,8 @@ and minimal code that generates this warning. Thanks!
793
832
  if @worksheet.selected
794
833
  flags |= 0x0200
795
834
  end
835
+ flags |= 0x0080 # Show outline symbols,
836
+ # but if [Row|Column]#outline_level = 0 the symbols are not shown.
796
837
  data = [ flags, 0, 0, 0, 0, 0 ].pack binfmt(:window2)
797
838
  write_op opcode(:window2), data
798
839
  end
@@ -59,7 +59,8 @@ module Spreadsheet
59
59
  enum :encoding, :default, :iso_latin1, :symbol, :apple_roman, :shift_jis,
60
60
  :korean_hangul, :korean_johab, :chinese_simplified,
61
61
  :chinese_traditional, :greek, :turkish, :vietnamese,
62
- :hebrew, :arabic, :cyrillic, :thai, :iso_latin2, :oem_latin1
62
+ :hebrew, :arabic, :baltic, :cyrillic, :thai, :iso_latin2,
63
+ :oem_latin1
63
64
  def initialize name, opts={}
64
65
  self.name = name
65
66
  @color = :text
@@ -30,7 +30,7 @@ module Spreadsheet
30
30
  def href
31
31
  href = (@url || @dos).to_s.dup
32
32
  if @fragment
33
- href << client('#') << @fragment
33
+ href << client('#', 'UTF-8') << @fragment
34
34
  end
35
35
  href
36
36
  end
data/test/integration.rb CHANGED
@@ -829,7 +829,7 @@ module Spreadsheet
829
829
  sheet1[5,0] = 0.75
830
830
  sheet1.row(5).set_format 0, fmt
831
831
  link = Link.new 'http://scm.ywesee.com/?p=spreadsheet;a=summary',
832
- 'The Spreadsheet GitWeb'
832
+ 'The Spreadsheet GitWeb', 'top'
833
833
  sheet1[5,1] = link
834
834
  sheet1[6,0] = 1
835
835
  fmt = Format.new :color => 'green'
@@ -962,6 +962,7 @@ module Spreadsheet
962
962
  url = @@iconv.iconv 'http://scm.ywesee.com/?p=spreadsheet;a=summary'
963
963
  assert_equal @@iconv.iconv('The Spreadsheet GitWeb'), link
964
964
  assert_equal url, link.url
965
+ assert_equal @@iconv.iconv('top'), link.fragment
965
966
  row = sheet.row 6
966
967
  assert_equal :green, row.format(0).font.color
967
968
  assert_equal 1, row[0]
@@ -1270,5 +1271,11 @@ module Spreadsheet
1270
1271
  target = File.join @var, 'test_changes.xls'
1271
1272
  assert_nothing_raised do book.write target end
1272
1273
  end
1274
+ def test_read_baltic
1275
+ path = File.join @data, 'test_baltic.xls'
1276
+ assert_nothing_raised do
1277
+ Spreadsheet.open path
1278
+ end
1279
+ end
1273
1280
  end
1274
1281
  end
metadata CHANGED
@@ -1,37 +1,54 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spreadsheet
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.4.1
4
+ hash: 107
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 6
9
+ - 5
10
+ - 0
11
+ version: 0.6.5.0
5
12
  platform: ruby
6
13
  authors:
7
- - Hannes Wyss
14
+ - Masaomi Hatakeyama, Zeno R.R. Davatz
8
15
  autorequire:
9
16
  bindir: bin
10
17
  cert_chain: []
11
18
 
12
- date: 2009-09-17 00:00:00 +02:00
19
+ date: 2010-12-13 00:00:00 +01:00
13
20
  default_executable:
14
21
  dependencies:
15
22
  - !ruby/object:Gem::Dependency
16
23
  name: ruby-ole
17
- type: :runtime
18
- version_requirement:
19
- version_requirements: !ruby/object:Gem::Requirement
24
+ prerelease: false
25
+ requirement: &id001 !ruby/object:Gem::Requirement
26
+ none: false
20
27
  requirements:
21
28
  - - ">="
22
29
  - !ruby/object:Gem::Version
30
+ hash: 3
31
+ segments:
32
+ - 0
23
33
  version: "0"
24
- version:
34
+ type: :runtime
35
+ version_requirements: *id001
25
36
  - !ruby/object:Gem::Dependency
26
37
  name: hoe
27
- type: :development
28
- version_requirement:
29
- version_requirements: !ruby/object:Gem::Requirement
38
+ prerelease: false
39
+ requirement: &id002 !ruby/object:Gem::Requirement
40
+ none: false
30
41
  requirements:
31
42
  - - ">="
32
43
  - !ruby/object:Gem::Version
33
- version: 2.3.3
34
- version:
44
+ hash: 47
45
+ segments:
46
+ - 2
47
+ - 8
48
+ - 0
49
+ version: 2.8.0
50
+ type: :development
51
+ version_requirements: *id002
35
52
  description: |-
36
53
  The Spreadsheet Library is designed to read and write Spreadsheet Documents.
37
54
  As of version 0.6.0, only Microsoft Excel compatible spreadsheets are
@@ -39,7 +56,7 @@ description: |-
39
56
  Spreadsheet::Excel Library by Daniel J. Berger and the ParseExcel Library by
40
57
  Hannes Wyss. Spreadsheet can read, write and modify Spreadsheet Documents.
41
58
  email:
42
- - hannes.wyss@gmail.com
59
+ - mhatakeyama@ywesee.com, zdavatz@ywesee.com
43
60
  executables:
44
61
  - xlsopcodes
45
62
  extensions: []
@@ -121,21 +138,27 @@ rdoc_options:
121
138
  require_paths:
122
139
  - lib
123
140
  required_ruby_version: !ruby/object:Gem::Requirement
141
+ none: false
124
142
  requirements:
125
143
  - - ">="
126
144
  - !ruby/object:Gem::Version
145
+ hash: 3
146
+ segments:
147
+ - 0
127
148
  version: "0"
128
- version:
129
149
  required_rubygems_version: !ruby/object:Gem::Requirement
150
+ none: false
130
151
  requirements:
131
152
  - - ">="
132
153
  - !ruby/object:Gem::Version
154
+ hash: 3
155
+ segments:
156
+ - 0
133
157
  version: "0"
134
- version:
135
158
  requirements: []
136
159
 
137
160
  rubyforge_project: spreadsheet
138
- rubygems_version: 1.3.4
161
+ rubygems_version: 1.3.7
139
162
  signing_key:
140
163
  specification_version: 3
141
164
  summary: The Spreadsheet Library is designed to read and write Spreadsheet Documents