spreadsheet-excel 0.3.5 → 0.3.5.1

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/CHANGES CHANGED
@@ -1,3 +1,9 @@
1
+ == 0.3.5.1 - 8-Feb-2007
2
+ * Fixed a bug reported by Kirk Haines where string-inputs were sliced into
3
+ oblivion by Worksheet#write. This only concerns gem-installations of
4
+ Spreadsheet::Excel. Stupid, stupid maintainers should create gems from a
5
+ clean export, not a working directory containing highly experimental code!
6
+
1
7
  == 0.3.5 - 18-Aug-2006
2
8
  * Instead of making OLEWriter inherit from IO, just have it delegate
3
9
  the IO method calls to an IO object reference in an instance variable. That
@@ -8,6 +8,6 @@ require "format"
8
8
 
9
9
  module Spreadsheet
10
10
  class Excel < Workbook
11
- VERSION = "0.3.5"
11
+ VERSION = "0.3.5.1"
12
12
  end
13
13
  end
@@ -6,7 +6,6 @@ class Worksheet < BIFFWriter
6
6
  ColMax = 256
7
7
  StrMax = 255
8
8
  Buffer = 4096
9
- ContMax = 2080
10
9
 
11
10
  attr_reader :name, :xf_index
12
11
  attr_accessor :index, :colinfo, :selection, :offset
@@ -273,9 +272,12 @@ class Worksheet < BIFFWriter
273
272
 
274
273
  def write_string(row, col, str, format)
275
274
  record = 0x0204
275
+ length = 0x0008 + str.length
276
276
 
277
277
  xf_index = XF(row, col, format)
278
278
 
279
+ strlen = str.length
280
+
279
281
  raise MaxSizeError if row >= RowMax
280
282
  raise MaxSizeError if col >= ColMax
281
283
 
@@ -284,20 +286,17 @@ class Worksheet < BIFFWriter
284
286
  @dim_colmin = col if col < @dim_colmin
285
287
  @dim_colmax = col if col > @dim_colmax
286
288
 
287
- strlen = str.size
288
- pstr = str.slice!(0,StrMax)
289
- length = 0x0008 + pstr.size
289
+ # Truncate strings over 255 characters
290
+ if strlen > StrMax
291
+ str = str[0..StrMax-1]
292
+ length = 0x0008 + StrMax
293
+ strlen = StrMax
294
+ end
295
+
290
296
  header = [record, length].pack("vv")
291
297
  data = [row, col, xf_index, strlen].pack("vvvv")
292
- append(header, data, pstr)
293
-
294
- record = 0x003C
295
- until(str.empty?)
296
- pstr = str.slice!(0,ContMax)
297
- header = [record, pstr.size].pack("vv")
298
- append(header, pstr)
299
- end
300
298
 
299
+ append(header, data, str)
301
300
  end
302
301
 
303
302
  # Write a blank cell to the specified row and column (zero indexed).
@@ -21,6 +21,6 @@ require "ftools"
21
21
 
22
22
  class TC_Excel < Test::Unit::TestCase
23
23
  def test_version
24
- assert_equal("0.3.5", Spreadsheet::Excel::VERSION)
24
+ assert_equal("0.3.5.1", Spreadsheet::Excel::VERSION)
25
25
  end
26
26
  end
@@ -68,19 +68,10 @@ class TC_Workbook < Test::Unit::TestCase
68
68
  assert_equal(3,@wb.formats.length,"Bad number of formats")
69
69
  end
70
70
 
71
- def test_write_string_continued
72
- ws = @wb.add_worksheet
73
- txt = ''
74
- 0.upto(256) { |num|
75
- txt << "." << num.to_s
76
- }
77
- ws.write(0,0,txt)
78
- end
79
-
80
71
  def teardown
81
72
  @wb.close
82
73
  @wb = nil
83
- #File.delete("test.xls") if File.exists?("test.xls")
74
+ File.delete("test.xls") if File.exists?("test.xls")
84
75
  end
85
76
 
86
77
  end
metadata CHANGED
@@ -1,10 +1,10 @@
1
1
  --- !ruby/object:Gem::Specification
2
- rubygems_version: 0.8.11
2
+ rubygems_version: 0.9.0
3
3
  specification_version: 1
4
4
  name: spreadsheet-excel
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.3.5
7
- date: 2006-08-23 00:00:00 +02:00
6
+ version: 0.3.5.1
7
+ date: 2007-02-08 00:00:00 +01:00
8
8
  summary: Creates Excel documents on any platform
9
9
  require_paths:
10
10
  - lib
@@ -25,60 +25,32 @@ required_ruby_version: !ruby/object:Gem::Version::Requirement
25
25
  platform: ruby
26
26
  signing_key:
27
27
  cert_chain:
28
+ post_install_message:
28
29
  authors:
29
30
  - Hannes Wyss
30
31
  files:
31
- - CVS/Root
32
- - CVS/Repository
33
- - CVS/Entries
34
- - doc/CVS
35
32
  - doc/format.txt
36
33
  - doc/spreadsheet.txt
37
- - doc/CVS/Root
38
- - doc/CVS/Repository
39
- - doc/CVS/Entries
40
- - examples/CVS
41
- - examples/example_basic.rb
42
- - examples/example_format.rb
43
- - examples/CVS/Root
44
- - examples/CVS/Repository
45
- - examples/CVS/Entries
46
- - lib/CVS
47
34
  - lib/spreadsheet
48
- - lib/CVS/Root
49
- - lib/CVS/Repository
50
- - lib/CVS/Entries
51
- - lib/spreadsheet/CVS
52
35
  - lib/spreadsheet/biffwriter.rb
53
- - lib/spreadsheet/worksheet.rb
36
+ - lib/spreadsheet/excel.rb
54
37
  - lib/spreadsheet/format.rb
55
- - lib/spreadsheet/olewriter.rb.orig
56
- - lib/spreadsheet/olewriter.rb.rej
57
- - lib/spreadsheet/workbook.rb
58
38
  - lib/spreadsheet/olewriter.rb
59
- - lib/spreadsheet/excel.rb
60
- - lib/spreadsheet/CVS/Root
61
- - lib/spreadsheet/CVS/Repository
62
- - lib/spreadsheet/CVS/Entries
63
- - test/CVS
39
+ - lib/spreadsheet/workbook.rb
40
+ - lib/spreadsheet/worksheet.rb
41
+ - examples/example_basic.rb
42
+ - examples/example_format.rb
43
+ - test/perl_output
64
44
  - test/tc_all.rb
65
45
  - test/tc_biff.rb
66
- - test/tc_ole.rb
67
- - test/ts_all.rb
68
- - test/perl_output
69
- - test/foo.ole
46
+ - test/tc_excel.rb
70
47
  - test/tc_format.rb
71
- - test/delete_this
72
- - test/test.xls
48
+ - test/tc_ole.rb
73
49
  - test/tc_workbook.rb
74
50
  - test/tc_worksheet.rb
75
- - test/tc_excel.rb
76
- - test/CVS/Root
77
- - test/CVS/Repository
78
- - test/CVS/Entries
79
- - test/perl_output/CVS
80
- - test/perl_output/README
51
+ - test/ts_all.rb
81
52
  - test/perl_output/f_font_biff
53
+ - test/perl_output/README
82
54
  - test/perl_output/f_font_key
83
55
  - test/perl_output/f_xf_biff
84
56
  - test/perl_output/ole_write_header
@@ -86,9 +58,6 @@ files:
86
58
  - test/perl_output/ws_store_dimensions
87
59
  - test/perl_output/ws_store_selection
88
60
  - test/perl_output/ws_store_window2
89
- - test/perl_output/CVS/Root
90
- - test/perl_output/CVS/Repository
91
- - test/perl_output/CVS/Entries
92
61
  - README
93
62
  - CHANGES
94
63
  test_files:
@@ -1,10 +0,0 @@
1
- /.project/1.2/Tue Oct 11 14:08:38 2005//
2
- /MANIFEST/1.10/Mon Dec 5 02:05:39 2005/-kb/
3
- /install.rb/1.8/Mon Dec 5 02:13:14 2005/-ko/
4
- D/doc////
5
- D/examples////
6
- D/lib////
7
- D/test////
8
- /CHANGES/1.15/Fri Aug 18 13:42:05 2006/-kb/
9
- /README/1.6/Fri Aug 18 13:38:31 2006/-kb/
10
- /spreadsheet-excel.gemspec/1.8/Fri Aug 18 13:38:59 2006/-kb/
@@ -1 +0,0 @@
1
- RubySpreadsheet
data/CVS/Root DELETED
@@ -1 +0,0 @@
1
- :ext:hwyss@rubyspreadsheet.cvs.sourceforge.net:/cvsroot/rubyspreadsheet
@@ -1,3 +0,0 @@
1
- /format.txt/1.4/Mon Oct 10 22:39:01 2005//
2
- /spreadsheet.txt/1.10/Fri Feb 17 03:43:30 2006/-ko/
3
- D
@@ -1 +0,0 @@
1
- RubySpreadsheet/doc
@@ -1 +0,0 @@
1
- :ext:hwyss@rubyspreadsheet.cvs.sourceforge.net:/cvsroot/rubyspreadsheet
@@ -1,3 +0,0 @@
1
- /example_basic.rb/1.2/Wed Oct 12 21:05:44 2005//
2
- /example_format.rb/1.2/Wed Oct 12 21:11:40 2005//
3
- D
@@ -1 +0,0 @@
1
- RubySpreadsheet/examples
@@ -1 +0,0 @@
1
- :ext:hwyss@rubyspreadsheet.cvs.sourceforge.net:/cvsroot/rubyspreadsheet
@@ -1 +0,0 @@
1
- D/spreadsheet////
@@ -1 +0,0 @@
1
- RubySpreadsheet/lib
@@ -1 +0,0 @@
1
- :ext:hwyss@rubyspreadsheet.cvs.sourceforge.net:/cvsroot/rubyspreadsheet
@@ -1,7 +0,0 @@
1
- /biffwriter.rb/1.1/Tue Oct 11 17:09:08 2005//
2
- /excel.rb/1.4/Fri Feb 17 03:34:00 2006//
3
- /worksheet.rb/1.2/Fri Feb 17 03:33:24 2006//
4
- /format.rb/1.2/Fri Aug 18 13:15:05 2006//
5
- /olewriter.rb/1.4/Fri Aug 18 13:20:26 2006//
6
- /workbook.rb/1.5/Fri Aug 18 13:20:13 2006//
7
- D
@@ -1 +0,0 @@
1
- RubySpreadsheet/lib/spreadsheet
@@ -1 +0,0 @@
1
- :ext:hwyss@rubyspreadsheet.cvs.sourceforge.net:/cvsroot/rubyspreadsheet
@@ -1,196 +0,0 @@
1
- # olewriter.rb
2
- #
3
- # This class should never be instantiated directly. The entire class, and all
4
- # its methods should be considered private.
5
-
6
- class MaxSizeError < StandardError; end
7
-
8
- class OLEWriter
9
-
10
- # Not meant for public consumption
11
- MaxSize = 7087104
12
- BlockSize = 4096
13
- BlockDiv = 512
14
- ListBlocks = 127
15
-
16
- attr_reader :biff_size, :book_size, :big_blocks, :list_blocks
17
- attr_reader :root_start, :size_allowed
18
-
19
- # Accept an IO or IO-like object or a filename (as a String)
20
- def initialize(arg)
21
- if arg.kind_of?(String)
22
- @io = File.open(arg, "w")
23
- else
24
- @io = arg
25
- end
26
- @io.binmode
27
-
28
- @biff_only = false
29
- @size_allowed = true
30
- @biff_size = 0
31
- @book_size = 0
32
- @big_blocks = 0
33
- @list_blocks = 0
34
- @root_start = 0
35
- @block_count = 4
36
- end
37
-
38
- # Imitate IO.open behavior
39
- def self.open(arg)
40
- if block_given?
41
- ole = self.new(arg)
42
- result = yield(ole)
43
- ole.close
44
- result
45
- else
46
- self.new(arg)
47
- end
48
- end
49
-
50
- # Delegate 'write' and 'print' to the internal IO object.
51
- def write(*args, &block)
52
- @io.write(*args, &block)
53
- end
54
- def print(*args, &block)
55
- @io.print(*args, &block)
56
- end
57
-
58
- # Set the size of the data to be written to the OLE stream
59
- #
60
- # @big_blocks = (109 depot block x (128 -1 marker word)
61
- # - (1 x end words)) = 13842
62
- #
63
- # MaxSize = @big_blocks * 512 bytes = 7087104
64
- def set_size(size = BlockSize)
65
- raise MaxSizeError if size > MaxSize
66
-
67
- @biff_size = size
68
-
69
- if biff_size > BlockSize
70
- @book_size = size
71
- else
72
- @book_size = BlockSize
73
- end
74
-
75
- @size_allowed = true
76
- end
77
-
78
- # Calculate various sizes needed for the OLE stream
79
- def calculate_sizes
80
- @big_blocks = (@book_size.to_f/BlockDiv.to_f).ceil
81
- @list_blocks = (@big_blocks / ListBlocks) + 1
82
- @root_start = @big_blocks
83
- end
84
-
85
- # Write root entry, big block list and close the filehandle.
86
- def close
87
- if @size_allowed == true
88
- write_padding
89
- write_property_storage
90
- write_big_block_depot
91
- end
92
- @io.close
93
- end
94
-
95
- # Write the OLE header block
96
- def write_header
97
- return if @biff_only == true
98
- calculate_sizes
99
- root_start = @root_start
100
-
101
- write([0xD0CF11E0, 0xA1B11AE1].pack("NN"))
102
- write([0x00, 0x00, 0x00, 0x00].pack("VVVV"))
103
- write([0x3E, 0x03, -2, 0x09].pack("vvvv"))
104
- write([0x06, 0x00, 0x00].pack("VVV"))
105
- write([@list_blocks, root_start].pack("VV"))
106
- write([0x00, 0x1000,-2].pack("VVV"))
107
- write([0x00, -2 ,0x00].pack("VVV"))
108
-
109
- unused = [-1].pack("V")
110
-
111
- 1.upto(@list_blocks){
112
- root_start += 1
113
- write([root_start].pack("V"))
114
- }
115
-
116
- @list_blocks.upto(108){
117
- write(unused)
118
- }
119
- end
120
-
121
- # Write a big block depot
122
- def write_big_block_depot
123
- total_blocks = @list_blocks * 128
124
- used_blocks = @big_blocks + @list_blocks + 2
125
-
126
- marker = [-3].pack("V")
127
- eoc = [-2].pack("V")
128
- unused = [-1].pack("V")
129
-
130
- num_blocks = @big_blocks - 1
131
-
132
- 1.upto(num_blocks){|n|
133
- write([n].pack("V"))
134
- }
135
-
136
- write eoc
137
- write eoc
138
-
139
- 1.upto(@list_blocks){ write(marker) }
140
-
141
- used_blocks.upto(total_blocks){ write(unused) }
142
-
143
- end
144
-
145
- # Write property storage
146
- def write_property_storage
147
- write_pps('Root Entry', 0x05, 1, -2, 0x00)
148
- write_pps('Book', 0x02, -1, 0x00, @book_size)
149
- write_pps("", 0x00, -1, 0x00, 0x0000)
150
- write_pps("", 0x00, -1, 0x00, 0x0000)
151
- end
152
-
153
- # Write property sheet in property storage
154
- def write_pps(name, type, dir, start, size)
155
- length = 0
156
- ord_name = []
157
- unless name.empty?
158
- name += "\0"
159
- ord_name = name.unpack("c*")
160
- length = name.length * 2
161
- end
162
-
163
- zero = [0].pack("C")
164
- unknown = [0].pack("V")
165
-
166
- write(ord_name.pack("v*"))
167
-
168
- for n in 1..64-length
169
- write(zero)
170
- end
171
-
172
- write([length,type,-1,-1,dir].pack("vvVVV"))
173
-
174
- for n in 1..5
175
- write(unknown)
176
- end
177
-
178
- for n in 1..4
179
- write([0].pack("V"))
180
- end
181
-
182
- write([start,size].pack("VV"))
183
- write(unknown)
184
- end
185
-
186
- # Pad the end of the file
187
- def write_padding
188
- min_size = 512
189
- min_size = BlockSize if @biff_size < BlockSize
190
-
191
- if @biff_size % min_size != 0
192
- padding = min_size - (@biff_size % min_size)
193
- write("\0" * padding)
194
- end
195
- end
196
- end
@@ -1,32 +0,0 @@
1
- ***************
2
- *** 83,97 ****
3
- end
4
-
5
- # Write root entry, big block list and close the filehandle.
6
- def close
7
- - return if @io.closed?
8
- if @size_allowed == true
9
- write_padding
10
- write_property_storage
11
- write_big_block_depot
12
- end
13
- - @io.close
14
- end
15
-
16
- # Write the OLE header block
17
- def write_header
18
- --- 65,78 ----
19
- end
20
-
21
- # Write root entry, big block list and close the filehandle.
22
- def close
23
- if @size_allowed == true
24
- write_padding
25
- write_property_storage
26
- write_big_block_depot
27
- end
28
- + super
29
- end
30
-
31
- # Write the OLE header block
32
- def write_header
@@ -1,9 +0,0 @@
1
- /tc_all.rb/1.1/Sun Nov 23 03:46:55 2003//
2
- /tc_biff.rb/1.3/Wed Oct 12 21:33:36 2005//
3
- /tc_excel.rb/1.7/Fri Feb 17 03:36:41 2006//
4
- /tc_ole.rb/1.4/Wed Oct 12 21:33:05 2005//
5
- /tc_worksheet.rb/1.3/Wed Oct 12 21:35:11 2005//
6
- /ts_all.rb/1.2/Wed Oct 12 21:35:30 2005//
7
- D/perl_output////
8
- /tc_format.rb/1.5/Fri Aug 18 13:15:13 2006//
9
- /tc_workbook.rb/1.3/Fri Aug 18 13:05:40 2006//
@@ -1 +0,0 @@
1
- RubySpreadsheet/test
@@ -1 +0,0 @@
1
- :ext:hwyss@rubyspreadsheet.cvs.sourceforge.net:/cvsroot/rubyspreadsheet
Binary file
File without changes
@@ -1,10 +0,0 @@
1
- /README/1.5/Mon Oct 10 22:50:37 2005/-kb/
2
- /f_font_biff/1.1/Wed Dec 4 00:15:06 2002/-kb/
3
- /f_font_key/1.1/Wed Dec 4 00:14:48 2002/-kb/
4
- /f_xf_biff/1.1/Wed Dec 4 00:14:31 2002/-kb/
5
- /ole_write_header/1.1/Mon Oct 10 22:51:03 2005/-kb/
6
- /ws_colinfo/1.1/Thu Nov 28 04:52:55 2002/-kb/
7
- /ws_store_dimensions/1.1/Thu Nov 28 04:53:19 2002/-kb/
8
- /ws_store_selection/1.1/Thu Nov 28 04:53:19 2002/-kb/
9
- /ws_store_window2/1.1/Thu Nov 28 04:53:19 2002/-kb/
10
- D
@@ -1 +0,0 @@
1
- RubySpreadsheet/test/perl_output
@@ -1 +0,0 @@
1
- :ext:hwyss@rubyspreadsheet.cvs.sourceforge.net:/cvsroot/rubyspreadsheet
Binary file