spreadsheet 0.6.4 → 0.6.4.1

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,3 +1,31 @@
1
+ === 0.6.4.1 / 2009-09-17
2
+
3
+ * 3 Bugfixes
4
+
5
+ * Fixes the issue reported by Thomas Preymesser and tracked down most of the
6
+ way by Hugh McGowan in
7
+ http://rubyforge.org/tracker/index.php?func=detail&aid=26647&group_id=678&atid=2677
8
+ where reading the value of the first occurrence of a shared formula
9
+ failed.
10
+
11
+ * Fixes the issue reported by Anonymous in
12
+ http://rubyforge.org/tracker/index.php?func=detail&aid=26546&group_id=678&atid=2677
13
+ where InvalidDate was raised for some Dates.
14
+
15
+ * Fixes the issue reported by John Lee in
16
+ http://rubyforge.org/tracker/index.php?func=detail&aid=27110&group_id=678&atid=2677
17
+ which is probably a duplicate of the Bug previously reported by Kadvin XJ in
18
+ http://rubyforge.org/tracker/index.php?func=detail&aid=26182&group_id=678&atid=2677
19
+ where unchanged rows were marked as changed in the Excel-Writer while the
20
+ File was being written, triggering an Error.
21
+
22
+ * 1 minor enhancement
23
+
24
+ * Detect row offsets from Cell data if Row-Ops are missing
25
+ This fixes a bug reported by Alexander Logvinov in
26
+ http://rubyforge.org/tracker/index.php?func=detail&aid=26513&group_id=678&atid=2677
27
+
28
+
1
29
  === 0.6.4 / 2009-07-03
2
30
 
3
31
  * 5 Bugfixes
data/Manifest.txt CHANGED
@@ -40,9 +40,12 @@ lib/spreadsheet/row.rb
40
40
  lib/spreadsheet/workbook.rb
41
41
  lib/spreadsheet/worksheet.rb
42
42
  lib/spreadsheet/writer.rb
43
+ test/data/test_changes.xls
43
44
  test/data/test_copy.xls
44
45
  test/data/test_datetime.xls
45
46
  test/data/test_empty.xls
47
+ test/data/test_formula.xls
48
+ test/data/test_missing_row.xls
46
49
  test/data/test_version_excel5.xls
47
50
  test/data/test_version_excel95.xls
48
51
  test/data/test_version_excel97.xls
data/README.txt CHANGED
@@ -1,18 +1,18 @@
1
- Last Update: 16.12.2008, 10.33 - zdavatz
1
+ Last Update: 17.09.2009, 16.32 - hwyss
2
2
 
3
3
 
4
4
  = Spreadsheet
5
5
 
6
- http://spreadsheet.rubyforge.org
7
- http://scm.ywesee.com/spreadsheet
6
+ http://spreadsheet.rubyforge.org
7
+ http://scm.ywesee.com/spreadsheet
8
8
 
9
9
  For a viewable directory of all recent changes, please see:
10
10
 
11
- http://scm.ywesee.com/?p=spreadsheet;a=summary
11
+ http://scm.ywesee.com/?p=spreadsheet;a=summary
12
12
 
13
13
  For Non-GPLv3 commercial licencing, please see:
14
14
 
15
- http://www.spreadsheet.ch
15
+ http://www.spreadsheet.ch
16
16
 
17
17
 
18
18
  == Description
data/bin/xlsopcodes CHANGED
@@ -12,7 +12,7 @@ end
12
12
  target = target ? File.open(target, 'w') : STDOUT
13
13
 
14
14
  reader = Spreadsheet::Excel::Reader.new :print_opcodes => target
15
- reader.setup source
15
+ reader.setup File.open(source)
16
16
 
17
17
  while tuple = reader.get_next_chunk
18
18
  end
data/lib/spreadsheet.rb CHANGED
@@ -42,7 +42,7 @@ module Spreadsheet
42
42
 
43
43
  ##
44
44
  # The version of Spreadsheet you are using.
45
- VERSION = '0.6.4'
45
+ VERSION = '0.6.4.1'
46
46
 
47
47
  ##
48
48
  # Default client Encoding. Change this value if your application uses a
@@ -226,6 +226,7 @@ module Internals
226
226
  :string => 0x0207, # STRING ➜ 6.98
227
227
  :style => 0x0293, # ●● STYLE ➜ 6.99
228
228
  :xf => 0x00e0, # ●● XF ➜ 6.115
229
+ :sharedfmla => 0x04bc, # SHAREDFMLA ➜ 5.94
229
230
  ########################## Unhandled Opcodes ################################
230
231
  :extsst => 0x00ff, # ● EXTSST ➜ 6.40
231
232
  :index => 0x020b, # ○ INDEX ➜ 5.7 (Row Blocks), ➜ 6.55
@@ -16,10 +16,11 @@ module Spreadsheet
16
16
  class Reader
17
17
  include Spreadsheet::Encodings
18
18
  include Spreadsheet::Excel::Internals
19
- ROW_BLOCK_OPS = [
20
- :blank, :boolerr, :dbcell, :formula, :label, :labelsst, :mulblank, :mulrk,
21
- :number, :rk, :rstring,
22
- ]
19
+ ROW_BLOCK_OPS = {
20
+ :blank => true, :boolerr => true, :dbcell => true, :formula => true,
21
+ :label => true, :labelsst => true, :mulblank => true, :mulrk => true,
22
+ :number => true, :rk => true, :rstring => true,
23
+ }
23
24
  def initialize opts = {}
24
25
  @pos = 0
25
26
  @bigendian = opts.fetch(:bigendian) {
@@ -378,6 +379,10 @@ class Reader
378
379
  formula.value = value
379
380
  elsif rtype == 0
380
381
  pos, op, len, work = get_next_chunk
382
+ if op == :sharedfmla
383
+ ## TODO: formula-support in 0.8.0
384
+ pos, op, len, work = get_next_chunk
385
+ end
381
386
  if op == :string
382
387
  formula.value = client read_string(work, 2), @workbook.encoding
383
388
  else
@@ -804,6 +809,7 @@ class Reader
804
809
  end
805
810
  def read_worksheet worksheet, offset
806
811
  @pos = offset
812
+ @detected_rows = {}
807
813
  previous = nil
808
814
  while tuple = get_next_chunk
809
815
  pos, op, len, work = tuple
@@ -835,6 +841,10 @@ class Reader
835
841
  read_hlink worksheet, work, pos, len
836
842
  when :window2
837
843
  read_window2 worksheet, work, pos, len
844
+ else
845
+ if ROW_BLOCK_OPS.include?(op)
846
+ set_missing_row_address worksheet, work, pos, len
847
+ end
838
848
  end
839
849
  previous = op
840
850
  end
@@ -1021,6 +1031,21 @@ class Reader
1021
1031
  cells.formats[column] = @workbook.format(xf) unless xf == 0
1022
1032
  cells[column] = value
1023
1033
  end
1034
+ def set_missing_row_address worksheet, work, pos, len
1035
+ # Offset Size Contents
1036
+ # 0 2 Index of this row
1037
+ # 2 2 Index to this column
1038
+ row_index, column_index = work.unpack 'v2'
1039
+ unless worksheet.offsets[row_index]
1040
+ @current_row_block_offset ||= [pos]
1041
+ data = {
1042
+ :index => row_index,
1043
+ :row_block => @current_row_block_offset,
1044
+ :offset => @current_row_block_offset[0],
1045
+ }
1046
+ worksheet.set_row_address row_index, data
1047
+ end
1048
+ end
1024
1049
  def set_row_address worksheet, work, pos, len
1025
1050
  # Offset Size Contents
1026
1051
  # 0 2 Index of this row
@@ -62,9 +62,11 @@ class Row < Spreadsheet::Row
62
62
  min += 1
63
63
  end
64
64
  if min > 59
65
+ min = 0
65
66
  hour += 1
66
67
  end
67
68
  if hour > 23
69
+ hour = 0
68
70
  date += 1
69
71
  end
70
72
  if LEAP_ERROR > base
@@ -45,7 +45,7 @@ class Worksheet < Spreadsheet::Worksheet
45
45
  if addr = @row_addresses[idx]
46
46
  row = @reader.read_row self, addr
47
47
  [:default_format, :height, :outline_level, :hidden, ].each do |key|
48
- row.send "#{key}=", addr[key]
48
+ row.send "unupdated_#{key}=", addr[key]
49
49
  end
50
50
  row.worksheet = self
51
51
  row
@@ -265,6 +265,7 @@ class Worksheet
265
265
  end
266
266
  row_offsets.sort!
267
267
  row_offsets.reverse!
268
+ control = changes.size
268
269
  @worksheet.each do |row|
269
270
  key = row.idx
270
271
  if changes.include?(key) && !work.include?(key)
@@ -272,6 +273,13 @@ class Worksheet
272
273
  work.store key, pair
273
274
  end
274
275
  end
276
+ if changes.size > control
277
+ warn <<-EOS
278
+ Your Worksheet was modified while it was being written. This should not happen.
279
+ Please contact the author (hannes dot wyss at gmail dot com) with a sample file
280
+ and minimal code that generates this warning. Thanks!
281
+ EOS
282
+ end
275
283
  work = work.sort_by do |key, (pos, len)|
276
284
  [pos, key.is_a?(Integer) ? key : -1]
277
285
  end
@@ -69,9 +69,9 @@ module Spreadsheet
69
69
  # stored for the cell.
70
70
  def default_format= format
71
71
  @worksheet.add_format format if @worksheet
72
- @worksheet.row_updated @idx, self if @worksheet
73
72
  @default_format = format
74
73
  end
74
+ format_updater :default_format
75
75
  ##
76
76
  # #first_used the 0-based index of the first non-blank Cell.
77
77
  def first_used
Binary file
Binary file
Binary file
Binary file
data/test/excel/row.rb CHANGED
@@ -24,6 +24,12 @@ class TestRow < Test::Unit::TestCase
24
24
  d2 = row.datetime 1
25
25
  assert_equal d1, d2
26
26
  end
27
+ def test_datetime_overflow
28
+ row = Row.new @worksheet, 0, [nil, 40010.6666666666]
29
+ d1 = DateTime.new(2009,07,16,16)
30
+ d2 = row.datetime 1
31
+ assert_equal d1, d2
32
+ end
27
33
  end
28
34
  end
29
35
  end
data/test/integration.rb CHANGED
@@ -535,9 +535,19 @@ module Spreadsheet
535
535
  assert_equal 00, time.min
536
536
  assert_equal 00, time.sec
537
537
  time = sheet[1,0]
538
+ assert_equal 1899, time.year
539
+ assert_equal 12, time.month
540
+ assert_equal 30, time.day
538
541
  assert_equal 22, time.hour
539
542
  assert_equal 30, time.min
540
543
  assert_equal 45, time.sec
544
+ time = sheet[0,1]
545
+ assert_equal 1899, time.year
546
+ assert_equal 12, time.month
547
+ assert_equal 31, time.day
548
+ assert_equal 4, time.hour
549
+ assert_equal 30, time.min
550
+ assert_equal 45, time.sec
541
551
  end
542
552
  def test_change_encoding
543
553
  path = File.join @data, 'test_version_excel95.xls'
@@ -1234,5 +1244,31 @@ module Spreadsheet
1234
1244
  assert_equal date1, sheet.row(0).date(0)
1235
1245
  assert_equal datetime1, sheet.row(1).datetime(0)
1236
1246
  end
1247
+ def test_sharedfmla
1248
+ path = File.join @data, 'test_formula.xls'
1249
+ book = Spreadsheet.open path
1250
+ assert_instance_of Excel::Workbook, book
1251
+ sheet = book.worksheet 0
1252
+ 64.times do |idx|
1253
+ assert_equal '5026', sheet[idx.next, 2].value
1254
+ end
1255
+ end
1256
+ def test_missing_row_op
1257
+ path = File.join @data, 'test_missing_row.xls'
1258
+ book = Spreadsheet.open path
1259
+ assert_instance_of Excel::Workbook, book
1260
+ sheet = book.worksheet 0
1261
+ assert_not_nil sheet[1,0]
1262
+ assert_not_nil sheet[2,1]
1263
+ end
1264
+ def test_changes
1265
+ path = File.join @data, 'test_changes.xls'
1266
+ book = Spreadsheet.open path
1267
+ assert_instance_of Excel::Workbook, book
1268
+ sheet = book.worksheet 1
1269
+ sheet[20,0] = 'Ciao Mundo!'
1270
+ target = File.join @var, 'test_changes.xls'
1271
+ assert_nothing_raised do book.write target end
1272
+ end
1237
1273
  end
1238
1274
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spreadsheet
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.4
4
+ version: 0.6.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hannes Wyss
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-07-03 00:00:00 +02:00
12
+ date: 2009-09-17 00:00:00 +02:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -30,9 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: 1.8.3
33
+ version: 2.3.3
34
34
  version:
35
- description: The Spreadsheet Library is designed to read and write Spreadsheet Documents. As of version 0.6.0, only Microsoft Excel compatible spreadsheets are supported. Spreadsheet is a combination/complete rewrite of the Spreadsheet::Excel Library by Daniel J. Berger and the ParseExcel Library by Hannes Wyss. Spreadsheet can read, write and modify Spreadsheet Documents.
35
+ description: |-
36
+ The Spreadsheet Library is designed to read and write Spreadsheet Documents.
37
+ As of version 0.6.0, only Microsoft Excel compatible spreadsheets are
38
+ supported. Spreadsheet is a combination/complete rewrite of the
39
+ Spreadsheet::Excel Library by Daniel J. Berger and the ParseExcel Library by
40
+ Hannes Wyss. Spreadsheet can read, write and modify Spreadsheet Documents.
36
41
  email:
37
42
  - hannes.wyss@gmail.com
38
43
  executables:
@@ -88,9 +93,12 @@ files:
88
93
  - lib/spreadsheet/workbook.rb
89
94
  - lib/spreadsheet/worksheet.rb
90
95
  - lib/spreadsheet/writer.rb
96
+ - test/data/test_changes.xls
91
97
  - test/data/test_copy.xls
92
98
  - test/data/test_datetime.xls
93
99
  - test/data/test_empty.xls
100
+ - test/data/test_formula.xls
101
+ - test/data/test_missing_row.xls
94
102
  - test/data/test_version_excel5.xls
95
103
  - test/data/test_version_excel95.xls
96
104
  - test/data/test_version_excel97.xls
@@ -103,7 +111,9 @@ files:
103
111
  - test/workbook.rb
104
112
  - test/worksheet.rb
105
113
  has_rdoc: true
106
- homepage: " http://spreadsheet.rubyforge.org"
114
+ homepage: http://spreadsheet.rubyforge.org
115
+ licenses: []
116
+
107
117
  post_install_message:
108
118
  rdoc_options:
109
119
  - --main
@@ -125,9 +135,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
125
135
  requirements: []
126
136
 
127
137
  rubyforge_project: spreadsheet
128
- rubygems_version: 1.3.1
138
+ rubygems_version: 1.3.4
129
139
  signing_key:
130
- specification_version: 2
140
+ specification_version: 3
131
141
  summary: The Spreadsheet Library is designed to read and write Spreadsheet Documents
132
142
  test_files: []
133
143