spreadsheet 0.6.1.8 → 0.6.1.9
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/History.txt +14 -0
- data/lib/spreadsheet.rb +1 -1
- data/lib/spreadsheet/excel/reader.rb +1 -0
- data/lib/spreadsheet/excel/row.rb +10 -1
- data/lib/spreadsheet/excel/workbook.rb +4 -0
- data/lib/spreadsheet/excel/writer/workbook.rb +11 -2
- data/lib/spreadsheet/format.rb +1 -1
- data/test/integration.rb +14 -0
- metadata +2 -2
data/History.txt
CHANGED
@@ -1,3 +1,17 @@
|
|
1
|
+
=== 0.6.1.9 / 2008-11-07
|
2
|
+
|
3
|
+
* 1 Bugfix
|
4
|
+
|
5
|
+
* Fixes a precision-issue in Excel::Row#datetime: Excel records Time-Values
|
6
|
+
with more significant bits (but not necessarily more precise) than
|
7
|
+
DateTime can handle.
|
8
|
+
(Thanks to Bjørn Hjelle for the Bugreport)
|
9
|
+
|
10
|
+
* 1 minor enhancement
|
11
|
+
|
12
|
+
* Added support for appending Worksheets to a Workbook
|
13
|
+
(Thanks to Mohammed Rabbani for the report)
|
14
|
+
|
1
15
|
=== 0.6.1.8 / 2008-10-31
|
2
16
|
|
3
17
|
* 1 Bugfix
|
data/lib/spreadsheet.rb
CHANGED
@@ -20,6 +20,11 @@ class Row < Spreadsheet::Row
|
|
20
20
|
def datetime idx
|
21
21
|
_datetime at(idx)
|
22
22
|
end
|
23
|
+
def each &block
|
24
|
+
size.times do |idx|
|
25
|
+
block.call self[idx]
|
26
|
+
end
|
27
|
+
end
|
23
28
|
##
|
24
29
|
# Access data in this Row like you would in an Array. If a cell is formatted
|
25
30
|
# as a Date or DateTime, the decoded Date or DateTime value is returned.
|
@@ -49,7 +54,11 @@ class Row < Spreadsheet::Row
|
|
49
54
|
def _datetime data # :nodoc:
|
50
55
|
return data if data.is_a?(DateTime)
|
51
56
|
date = _date data
|
52
|
-
|
57
|
+
hour = (data % 1) * 24
|
58
|
+
min = (hour % 1) * 60
|
59
|
+
sec = (min % 1) * 60
|
60
|
+
DateTime.new(date.year, date.month, date.day,
|
61
|
+
hour.to_i, min.to_i, sec.round)
|
53
62
|
end
|
54
63
|
def enriched_data idx, data # :nodoc:
|
55
64
|
res = nil
|
@@ -154,11 +154,17 @@ class Workbook < Spreadsheet::Writer
|
|
154
154
|
sst_strings.each_with_index do |str, idx| sst.store str, idx end
|
155
155
|
sheets = worksheets(workbook)
|
156
156
|
positions = []
|
157
|
+
newsheets = []
|
157
158
|
sheets.each do |sheet|
|
158
159
|
@sst[sheet] = sst
|
159
160
|
pos, len = workbook.offsets[sheet.worksheet]
|
160
|
-
|
161
|
-
|
161
|
+
if pos
|
162
|
+
positions.push pos
|
163
|
+
sheet.write_changes reader, pos + len, sst_status
|
164
|
+
else
|
165
|
+
newsheets.push sheet
|
166
|
+
sheet.write_from_scratch
|
167
|
+
end
|
162
168
|
sheet_data[sheet.worksheet] = sheet.data
|
163
169
|
end
|
164
170
|
Ole::Storage.open io do |ole|
|
@@ -202,6 +208,9 @@ class Workbook < Spreadsheet::Writer
|
|
202
208
|
reader.seek lastpos
|
203
209
|
end
|
204
210
|
writer.write reader.read
|
211
|
+
newsheets.each do |sheet|
|
212
|
+
writer.write sheet.data
|
213
|
+
end
|
205
214
|
end
|
206
215
|
end
|
207
216
|
end
|
data/lib/spreadsheet/format.rb
CHANGED
@@ -160,7 +160,7 @@ module Spreadsheet
|
|
160
160
|
##
|
161
161
|
# Is the cell formatted as a DateTime?
|
162
162
|
def datetime?
|
163
|
-
!!/([YMD].*[
|
163
|
+
!!/([YMD].*[HS])|([HS].*[YMD])/.match(@number_format.to_s)
|
164
164
|
end
|
165
165
|
##
|
166
166
|
# Is the cell formatted as a Time?
|
data/test/integration.rb
CHANGED
@@ -502,6 +502,20 @@ module Spreadsheet
|
|
502
502
|
assert_instance_of Excel::Worksheet, sheet
|
503
503
|
assert_equal sheet, book.worksheet("S\000h\000e\000e\000t\0001\000")
|
504
504
|
end
|
505
|
+
def test_datetime
|
506
|
+
path = File.join @data, 'test_datetime.xls'
|
507
|
+
book = Spreadsheet.open path
|
508
|
+
assert_instance_of Excel::Workbook, book
|
509
|
+
sheet = book.worksheet 0
|
510
|
+
time = sheet[0,0]
|
511
|
+
assert_equal 22, time.hour
|
512
|
+
assert_equal 00, time.min
|
513
|
+
assert_equal 00, time.sec
|
514
|
+
time = sheet[1,0]
|
515
|
+
assert_equal 22, time.hour
|
516
|
+
assert_equal 30, time.min
|
517
|
+
assert_equal 45, time.sec
|
518
|
+
end
|
505
519
|
def test_change_encoding
|
506
520
|
path = File.join @data, 'test_version_excel95.xls'
|
507
521
|
book = Spreadsheet.open path
|
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.1.
|
4
|
+
version: 0.6.1.9
|
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: 2008-
|
12
|
+
date: 2008-11-07 00:00:00 +01:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|