spreadsheet 0.6.1.3 → 0.6.1.4
Sign up to get free protection for your applications and to get access to all the features.
- data/GUIDE.txt +2 -2
- data/History.txt +11 -0
- data/Manifest.txt +1 -0
- data/lib/spreadsheet.rb +1 -1
- data/lib/spreadsheet/excel.rb +3 -0
- data/lib/spreadsheet/excel/internals.rb +1 -0
- data/lib/spreadsheet/excel/reader.rb +173 -0
- data/lib/spreadsheet/excel/reader/biff8.rb +3 -1
- data/lib/spreadsheet/excel/row.rb +3 -1
- data/lib/spreadsheet/excel/worksheet.rb +5 -1
- data/lib/spreadsheet/excel/writer/worksheet.rb +80 -0
- data/lib/spreadsheet/link.rb +40 -0
- data/lib/spreadsheet/worksheet.rb +9 -0
- data/test/data/test_version_excel97.xls +0 -0
- data/test/integration.rb +21 -8
- metadata +3 -2
data/GUIDE.txt
CHANGED
@@ -50,8 +50,8 @@ To access the values stored in a Row, treat the Row like an Array.
|
|
50
50
|
|
51
51
|
row[0]
|
52
52
|
|
53
|
-
-> this will return a String, a Float, an Integer, a Formula or a Date
|
54
|
-
DateTime object - or nil if the cell is empty.
|
53
|
+
-> this will return a String, a Float, an Integer, a Formula, a Link or a Date
|
54
|
+
or DateTime object - or nil if the cell is empty.
|
55
55
|
|
56
56
|
More information about the formatting of a cell can be found in the Format
|
57
57
|
with the equivalent index
|
data/History.txt
CHANGED
@@ -1,3 +1,14 @@
|
|
1
|
+
=== 0.6.1.4 / 2008-10-23
|
2
|
+
|
3
|
+
* 1 Bugfix
|
4
|
+
|
5
|
+
* Biff8#wide now works properly even if $KCODE=='UTF-8'
|
6
|
+
(Thanks to Bjørn Hjelle for the Bugreport)
|
7
|
+
|
8
|
+
* 1 minor enhancement
|
9
|
+
|
10
|
+
* Read/Write functionality for Links (only URLs can be written as of now)
|
11
|
+
|
1
12
|
=== 0.6.1.3 / 2008-10-21
|
2
13
|
|
3
14
|
* 2 Bugfixes
|
data/Manifest.txt
CHANGED
data/lib/spreadsheet.rb
CHANGED
data/lib/spreadsheet/excel.rb
CHANGED
@@ -211,6 +211,7 @@ module Internals
|
|
211
211
|
:font => 0x0031, # ●● FONT ➜ 6.43
|
212
212
|
:format => 0x041e, # ○○ FORMAT (Number Format) ➜ 6.45
|
213
213
|
:formula => 0x0006, # FORMULA ➜ 6.46
|
214
|
+
:hlink => 0x01b8, # HLINK ➜ 6.52 (BIFF8 only)
|
214
215
|
:label => 0x0204, # LABEL ➜ 6.59 (BIFF2-BIFF7)
|
215
216
|
:labelsst => 0x00fd, # LABELSST ➜ 6.61 (BIFF8 only)
|
216
217
|
:mulblank => 0x00be, # MULBLANK ➜ 6.64 (BIFF5-BIFF8)
|
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'spreadsheet/encodings'
|
2
2
|
require 'spreadsheet/font'
|
3
3
|
require 'spreadsheet/formula'
|
4
|
+
require 'spreadsheet/link'
|
4
5
|
require 'spreadsheet/excel/error'
|
5
6
|
require 'spreadsheet/excel/internals'
|
6
7
|
require 'spreadsheet/excel/sst_entry'
|
@@ -384,6 +385,176 @@ class Reader
|
|
384
385
|
# leave the Formula value blank
|
385
386
|
end
|
386
387
|
end
|
388
|
+
def read_hlink worksheet, work, pos, len
|
389
|
+
# 6.53.1 Common Record Contents
|
390
|
+
# Offset Size Contents
|
391
|
+
# 0 8 Cell range address of all cells containing this hyperlink
|
392
|
+
# (➜ 3.13.1)
|
393
|
+
# 8 16 GUID of StdLink:
|
394
|
+
# D0 C9 EA 79 F9 BA CE 11 8C 82 00 AA 00 4B A9 0B
|
395
|
+
# (79EAC9D0-BAF9-11CE-8C82-00AA004BA90B)
|
396
|
+
# 24 4 Unknown value: 0x00000002
|
397
|
+
# 28 4 Option flags (see below)
|
398
|
+
# Bit Mask Contents
|
399
|
+
# 0 0x00000001 0 = No link extant
|
400
|
+
# 1 = File link or URL
|
401
|
+
# 1 0x00000002 0 = Relative file path
|
402
|
+
# 1 = Absolute path or URL
|
403
|
+
# 2 and 4 0x00000014 0 = No description
|
404
|
+
# 1 (both bits) = Description
|
405
|
+
# 3 0x00000008 0 = No text mark
|
406
|
+
# 1 = Text mark
|
407
|
+
# 7 0x00000080 0 = No target frame
|
408
|
+
# 1 = Target frame
|
409
|
+
# 8 0x00000100 0 = File link or URL
|
410
|
+
# 1 = UNC path (incl. server name)
|
411
|
+
#--------------------------------------------------------------------------
|
412
|
+
# [32] 4 (optional, see option flags) Character count of description
|
413
|
+
# text, including trailing zero word (dl)
|
414
|
+
# [36] 2∙dl (optional, see option flags) Character array of description
|
415
|
+
# text, no Unicode string header, always 16-bit characters,
|
416
|
+
# zero-terminated
|
417
|
+
#--------------------------------------------------------------------------
|
418
|
+
# [var.] 4 (optional, see option flags) Character count of target
|
419
|
+
# frame, including trailing zero word (fl)
|
420
|
+
# [var.] 2∙fl (optional, see option flags) Character array of target
|
421
|
+
# frame, no Unicode string header, always 16-bit characters,
|
422
|
+
# zero-terminated
|
423
|
+
#--------------------------------------------------------------------------
|
424
|
+
# var. var. Special data (➜ 6.53.2 and following)
|
425
|
+
#--------------------------------------------------------------------------
|
426
|
+
# [var.] 4 (optional, see option flags) Character count of the text
|
427
|
+
# mark, including trailing zero word (tl)
|
428
|
+
# [var.] 2∙tl (optional, see option flags) Character array of the text
|
429
|
+
# mark without “#” sign, no Unicode string header, always
|
430
|
+
# 16-bit characters, zero-terminated
|
431
|
+
firstrow, lastrow, firstcol, lastcol, guid, opts = work.unpack 'v4H32x4V'
|
432
|
+
has_link = opts & 0x0001
|
433
|
+
absolute = opts & 0x0002
|
434
|
+
desc = opts & 0x0014
|
435
|
+
textmark = opts & 0x0008
|
436
|
+
target = opts & 0x0080
|
437
|
+
unc = opts & 0x0100
|
438
|
+
link = Link.new
|
439
|
+
url, description = nil
|
440
|
+
pos = 32
|
441
|
+
if desc > 0
|
442
|
+
description, pos = read_hlink_string work, pos
|
443
|
+
link << description
|
444
|
+
end
|
445
|
+
if target > 0
|
446
|
+
link.target_frame, pos = read_hlink_string work, pos
|
447
|
+
end
|
448
|
+
if unc > 0
|
449
|
+
# 6.53.4 Hyperlink to a File with UNC (Universal Naming Convention) Path
|
450
|
+
# These data fields are for UNC paths containing a server name (for
|
451
|
+
# instance “\\server\path\file.xls”). The lower 9 bits of the option
|
452
|
+
# flags field must be 1.x00x.xx112.
|
453
|
+
# Offset Size Contents
|
454
|
+
# 0 4 Character count of the UNC,
|
455
|
+
# including trailing zero word (fl)
|
456
|
+
# 4 2∙fl Character array of the UNC, no Unicode string header,
|
457
|
+
# always 16-bit characters, zeroterminated.
|
458
|
+
link.url, pos = read_hlink_string work, pos
|
459
|
+
elsif has_link > 0
|
460
|
+
uid, = work.unpack "x#{pos}H32"
|
461
|
+
pos += 16
|
462
|
+
if uid == "e0c9ea79f9bace118c8200aa004ba90b"
|
463
|
+
# 6.53.2 Hyperlink containing a URL (Uniform Resource Locator)
|
464
|
+
# These data fields occur for links which are not local files or files
|
465
|
+
# in the local network (for instance HTTP and FTP links and e-mail
|
466
|
+
# addresses). The lower 9 bits of the option flags field must be
|
467
|
+
# 0.x00x.xx112 (x means optional, depending on hyperlink content). The
|
468
|
+
# GUID could be used to distinguish a URL from a file link.
|
469
|
+
# Offset Size Contents
|
470
|
+
# 0 16 GUID of URL Moniker:
|
471
|
+
# E0 C9 EA 79 F9 BA CE 11 8C 82 00 AA 00 4B A9 0B
|
472
|
+
# (79EAC9E0-BAF9-11CE-8C82-00AA004BA90B)
|
473
|
+
# 16 4 Size of character array of the URL, including trailing
|
474
|
+
# zero word (us). There are us/2-1 characters in the
|
475
|
+
# following string.
|
476
|
+
# 20 us Character array of the URL, no Unicode string header,
|
477
|
+
# always 16-bit characters, zeroterminated
|
478
|
+
size, = work.unpack "x#{pos}V"
|
479
|
+
pos += 4
|
480
|
+
data = work[pos, size].chomp "\000\000"
|
481
|
+
link.url = client data, 'UTF-16LE'
|
482
|
+
pos += size
|
483
|
+
else
|
484
|
+
# 6.53.3 Hyperlink to a Local File
|
485
|
+
# These data fields are for links to files on local drives. The path of
|
486
|
+
# the file can be complete with drive letter (absolute) or relative to
|
487
|
+
# the location of the workbook. The lower 9 bits of the option flags
|
488
|
+
# field must be 0.x00x.xxx12. The GUID could be used to distinguish a
|
489
|
+
# URL from a file link.
|
490
|
+
# Offset Size Contents
|
491
|
+
# 0 16 GUID of File Moniker:
|
492
|
+
# 03 03 00 00 00 00 00 00 C0 00 00 00 00 00 00 46
|
493
|
+
# (00000303-0000-0000-C000-000000000046)
|
494
|
+
# 16 2 Directory up-level count. Each leading “..\” in the
|
495
|
+
# file link is deleted and increases this counter.
|
496
|
+
# 18 4 Character count of the shortened file path and name,
|
497
|
+
# including trailing zero byte (sl)
|
498
|
+
# 22 sl Character array of the shortened file path and name in
|
499
|
+
# 8.3-DOS-format. This field can be filled with a long
|
500
|
+
# file name too. No Unicode string header, always 8-bit
|
501
|
+
# characters, zeroterminated.
|
502
|
+
# 22+sl 24 Unknown byte sequence:
|
503
|
+
# FF FF AD DE 00 00 00 00
|
504
|
+
# 00 00 00 00 00 00 00 00
|
505
|
+
# 00 00 00 00 00 00 00 00
|
506
|
+
# 46+sl 4 Size of the following file link field including string
|
507
|
+
# length field and additional data field (sz). If sz is
|
508
|
+
# zero, nothing will follow (except a text mark).
|
509
|
+
# [50+sl] 4 (optional) Size of character array of the extended file
|
510
|
+
# path and name (xl). There are xl/2 characters in the
|
511
|
+
# following string.
|
512
|
+
# [54+sl] 2 (optional) Unknown byte sequence: 03 00
|
513
|
+
# [56+sl] xl (optional) Character array of the extended file path
|
514
|
+
# and name (xl), no Unicode string header, always 16-bit
|
515
|
+
# characters, not zero-terminated
|
516
|
+
uplevel, count = work.unpack "x#{pos}vV"
|
517
|
+
pos += 6
|
518
|
+
# TODO: short file path may have any of the OEM encodings. Find out which
|
519
|
+
# and use the #client method to convert the encoding.
|
520
|
+
prefix = internal('..\\', 'UTF-8') * uplevel
|
521
|
+
link.dos = link.url = prefix << work[pos, count].chomp("\000")
|
522
|
+
pos += count + 24
|
523
|
+
total, size = work.unpack "x#{pos}V2"
|
524
|
+
pos += 10
|
525
|
+
if total > 0
|
526
|
+
link.url = client work[pos, size], 'UTF-16LE'
|
527
|
+
pos += size
|
528
|
+
end
|
529
|
+
end
|
530
|
+
else
|
531
|
+
# 6.53.5 Hyperlink to the Current Workbook
|
532
|
+
# In this case only the text mark field is present (optional with
|
533
|
+
# description).
|
534
|
+
# Example: The URL “#Sheet2!B1:C2” refers to the given range in the
|
535
|
+
# current workbook.
|
536
|
+
# The lower 9 bits of the option flags field must be 0.x00x.1x002.
|
537
|
+
end
|
538
|
+
if textmark > 0
|
539
|
+
link.fragment, _ = read_hlink_string work, pos
|
540
|
+
end
|
541
|
+
if link.empty?
|
542
|
+
link << link.href
|
543
|
+
end
|
544
|
+
firstrow.upto lastrow do |row|
|
545
|
+
firstcol.upto lastcol do |col|
|
546
|
+
worksheet.add_link row, col, link
|
547
|
+
end
|
548
|
+
end
|
549
|
+
end
|
550
|
+
def read_hlink_string work, pos
|
551
|
+
count, = work.unpack "x#{pos}V"
|
552
|
+
len = count * 2
|
553
|
+
pos += 4
|
554
|
+
data = work[pos, len].chomp "\000\000"
|
555
|
+
pos += len
|
556
|
+
[client(data, 'UTF-16LE'), pos]
|
557
|
+
end
|
387
558
|
def read_index worksheet, work, pos, len
|
388
559
|
# Offset Size Contents
|
389
560
|
# 0 4 Not used
|
@@ -615,6 +786,8 @@ class Reader
|
|
615
786
|
when :row # ○○ Row Blocks ➜ 5.7
|
616
787
|
# ● ROW ➜ 6.83
|
617
788
|
set_row_address worksheet, work, pos, len
|
789
|
+
when :hlink
|
790
|
+
read_hlink worksheet, work, pos, len
|
618
791
|
end
|
619
792
|
previous = op
|
620
793
|
end
|
@@ -150,7 +150,9 @@ module Biff8
|
|
150
150
|
##
|
151
151
|
# Insert null-characters into a compressed UTF-16 string
|
152
152
|
def wide string
|
153
|
-
|
153
|
+
data = ''
|
154
|
+
string.each_byte do |byte| data << byte.chr << 0.chr end
|
155
|
+
data
|
154
156
|
end
|
155
157
|
private
|
156
158
|
##
|
@@ -53,7 +53,9 @@ class Row < Spreadsheet::Row
|
|
53
53
|
end
|
54
54
|
def enriched_data idx, data # :nodoc:
|
55
55
|
res = nil
|
56
|
-
if
|
56
|
+
if link = @worksheet.links[[@idx, idx]]
|
57
|
+
res = link
|
58
|
+
elsif fmt = format(idx)
|
57
59
|
res = if fmt.datetime? || fmt.time?
|
58
60
|
_datetime data
|
59
61
|
elsif fmt.date?
|
@@ -11,11 +11,15 @@ module Spreadsheet
|
|
11
11
|
class Worksheet < Spreadsheet::Worksheet
|
12
12
|
include Spreadsheet::Excel::Offset
|
13
13
|
offset :dimensions
|
14
|
-
attr_reader :offset, :ole
|
14
|
+
attr_reader :offset, :ole, :links
|
15
15
|
def initialize opts = {}
|
16
16
|
super
|
17
17
|
@offset, @ole, @reader = opts[:offset], opts[:ole], opts[:reader]
|
18
18
|
@dimensions = nil
|
19
|
+
@links = {}
|
20
|
+
end
|
21
|
+
def add_link row, column, link
|
22
|
+
@links.store [row, column], link
|
19
23
|
end
|
20
24
|
def column idx
|
21
25
|
ensure_rows_read
|
@@ -413,6 +413,7 @@ class Worksheet
|
|
413
413
|
# ○ PHONETIC ➜ 6.73
|
414
414
|
# ○ Conditional Formatting Table ➜ 5.12
|
415
415
|
# ○ Hyperlink Table ➜ 5.13
|
416
|
+
write_hyperlink_table
|
416
417
|
# ○ Data Validity Table ➜ 5.14
|
417
418
|
# ○ SHEETLAYOUT ➜ 6.91 (BIFF8X only)
|
418
419
|
# ○ SHEETPROTECTION Additional protection, ➜ 6.92 (BIFF8X only)
|
@@ -420,6 +421,85 @@ class Worksheet
|
|
420
421
|
# ● EOF ➜ 6.36
|
421
422
|
write_eof
|
422
423
|
end
|
424
|
+
def write_hlink row, col, link
|
425
|
+
# FIXME: only Hyperlinks are supported at present.
|
426
|
+
cell_range = [
|
427
|
+
row, row, # Cell range address of all cells containing this hyperlink
|
428
|
+
col, col, # (➜ 3.13.1)
|
429
|
+
].pack 'v4'
|
430
|
+
guid = [
|
431
|
+
# GUID of StdLink:
|
432
|
+
# D0 C9 EA 79 F9 BA CE 11 8C 82 00 AA 00 4B A9 0B
|
433
|
+
# (79EAC9D0-BAF9-11CE-8C82-00AA004BA90B)
|
434
|
+
"d0c9ea79f9bace118c8200aa004ba90b",
|
435
|
+
].pack 'H32'
|
436
|
+
opts = 0x01
|
437
|
+
opts |= 0x02
|
438
|
+
opts |= 0x14 unless link == link.url
|
439
|
+
opts |= 0x08 if link.fragment
|
440
|
+
opts |= 0x80 if link.target_frame
|
441
|
+
# TODO: UNC support
|
442
|
+
options = [
|
443
|
+
2, # Unknown value: 0x00000002
|
444
|
+
opts, # Option flags
|
445
|
+
# Bit Mask Contents
|
446
|
+
# 0 0x00000001 0 = No link extant
|
447
|
+
# 1 = File link or URL
|
448
|
+
# 1 0x00000002 0 = Relative file path
|
449
|
+
# 1 = Absolute path or URL
|
450
|
+
# 2 and 4 0x00000014 0 = No description
|
451
|
+
# 1 (both bits) = Description
|
452
|
+
# 3 0x00000008 0 = No text mark
|
453
|
+
# 1 = Text mark
|
454
|
+
# 7 0x00000080 0 = No target frame
|
455
|
+
# 1 = Target frame
|
456
|
+
# 8 0x00000100 0 = File link or URL
|
457
|
+
# 1 = UNC path (incl. server name)
|
458
|
+
|
459
|
+
].pack('V2')
|
460
|
+
tail = []
|
461
|
+
unless link == link.url
|
462
|
+
desc = internal(link).dup << "\000\000"
|
463
|
+
tail.push [desc.size / 2].pack('V'), desc
|
464
|
+
end
|
465
|
+
if link.target_frame
|
466
|
+
frme = internal(link.target_frame).dup << "\000\000"
|
467
|
+
tail.push [frme.size / 2].pack('V'), frme
|
468
|
+
end
|
469
|
+
url = internal(link.url).dup << "\000\000"
|
470
|
+
tail.push [
|
471
|
+
# 6.53.2 Hyperlink containing a URL (Uniform Resource Locator)
|
472
|
+
# These data fields occur for links which are not local files or files
|
473
|
+
# in the local network (for instance HTTP and FTP links and e-mail
|
474
|
+
# addresses). The lower 9 bits of the option flags field must be
|
475
|
+
# 0.x00x.xx112 (x means optional, depending on hyperlink content). The
|
476
|
+
# GUID could be used to distinguish a URL from a file link.
|
477
|
+
# GUID of URL Moniker:
|
478
|
+
# E0 C9 EA 79 F9 BA CE 11 8C 82 00 AA 00 4B A9 0B
|
479
|
+
# (79EAC9E0-BAF9-11CE-8C82-00AA004BA90B)
|
480
|
+
'e0c9ea79f9bace118c8200aa004ba90b',
|
481
|
+
url.size # Size of character array of the URL, including trailing zero
|
482
|
+
# word (us). There are us/2-1 characters in the following
|
483
|
+
# string.
|
484
|
+
].pack('H32V'), url
|
485
|
+
if link.fragment
|
486
|
+
frag = internal(link.fragment).dup << "\000\000"
|
487
|
+
tail.push [frag.size / 2].pack('V'), frag
|
488
|
+
end
|
489
|
+
write_op opcode(:hlink), cell_range, guid, options, *tail
|
490
|
+
end
|
491
|
+
def write_hyperlink_table
|
492
|
+
# TODO: theoretically it's possible to write fewer records by combining
|
493
|
+
# identical neighboring links in cell-ranges
|
494
|
+
links = []
|
495
|
+
@worksheet.each do |row|
|
496
|
+
row.each_with_index do |cell, idx|
|
497
|
+
if cell.is_a? Link
|
498
|
+
write_hlink row.idx, idx, cell
|
499
|
+
end
|
500
|
+
end
|
501
|
+
end
|
502
|
+
end
|
423
503
|
def write_iteration
|
424
504
|
its = 0 # 0 = Iterations off; 1 = Iterations on
|
425
505
|
write_op 0x0011, [its].pack('v')
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'uri'
|
2
|
+
|
3
|
+
module Spreadsheet
|
4
|
+
##
|
5
|
+
# The Link class. Is a Subclass of String, which lets you treat a Cell that
|
6
|
+
# contains a Link just as if it was a String (containing the link's description
|
7
|
+
# if there is one or the url with fragment otherwise), but gives you access
|
8
|
+
# to the url, fragment and target_frame if you need it.
|
9
|
+
#
|
10
|
+
#
|
11
|
+
# Interesting Attributes
|
12
|
+
# #url :: The Uniform Resource Location this Link points to.
|
13
|
+
# #fragment :: Also called text mark: http://example.com/page.html#fragment
|
14
|
+
# #target_frame :: Which frame a Link should be opened in, should also support
|
15
|
+
# the special frames _blank, _parent, _self and _top.
|
16
|
+
# #dos :: Excel may store a DOS-Filename together with the long
|
17
|
+
# Filename introduced in VFAT. You probably will not need this,
|
18
|
+
# but if you do, here is where you can find it.
|
19
|
+
class Link < String
|
20
|
+
attr_accessor :target_frame, :url, :dos, :fragment
|
21
|
+
def initialize url='', description=url
|
22
|
+
super description
|
23
|
+
@url = url
|
24
|
+
end
|
25
|
+
##
|
26
|
+
# The Url with the fragment appended if present.
|
27
|
+
def href
|
28
|
+
href = (@url || @dos).to_s.dup
|
29
|
+
if @fragment
|
30
|
+
href << '#' << @fragment
|
31
|
+
end
|
32
|
+
href
|
33
|
+
end
|
34
|
+
##
|
35
|
+
# Attempts to parse the output of href. May raise a URI::InvalidURIError
|
36
|
+
def to_uri
|
37
|
+
URI.parse href
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -30,6 +30,7 @@ module Spreadsheet
|
|
30
30
|
@workbook = opts[:workbook]
|
31
31
|
@rows = []
|
32
32
|
@columns = []
|
33
|
+
@links = {}
|
33
34
|
end
|
34
35
|
##
|
35
36
|
# Add a Format to the Workbook. If you use Row#set_format, you should not
|
@@ -139,6 +140,14 @@ module Spreadsheet
|
|
139
140
|
sprintf "#<%s:0x%014x %s @rows[%i]>", self.class, object_id,
|
140
141
|
variables, row_count
|
141
142
|
end
|
143
|
+
## The last Row containing any data
|
144
|
+
def last_row
|
145
|
+
row(last_row_index)
|
146
|
+
end
|
147
|
+
## The index of the last Row containing any data
|
148
|
+
def last_row_index
|
149
|
+
[dimensions[1] - 1, 0].max
|
150
|
+
end
|
142
151
|
##
|
143
152
|
# Replace the Row at _idx_ with the following arguments. Like #update_row,
|
144
153
|
# but truncates the Row if there are fewer arguments than Cells in the Row.
|
Binary file
|
data/test/integration.rb
CHANGED
@@ -44,8 +44,8 @@ module Spreadsheet
|
|
44
44
|
enc = Encoding.find enc
|
45
45
|
end
|
46
46
|
assert_equal enc, book.encoding
|
47
|
-
assert_equal
|
48
|
-
assert_equal
|
47
|
+
assert_equal 24, book.formats.size
|
48
|
+
assert_equal 5, book.fonts.size
|
49
49
|
str1 = book.shared_string 0
|
50
50
|
assert_equal @@iconv.iconv('Shared String'), str1
|
51
51
|
str2 = book.shared_string 1
|
@@ -76,7 +76,7 @@ module Spreadsheet
|
|
76
76
|
assert_equal 10, sheet.row_count
|
77
77
|
assert_equal 11, sheet.column_count
|
78
78
|
useds = [0,0,0,0,0,0,0,1,0,0]
|
79
|
-
unuseds = [2,2,1,1,1,2,1,11,1,
|
79
|
+
unuseds = [2,2,1,1,1,2,1,11,1,2]
|
80
80
|
sheet.each do |row|
|
81
81
|
assert_equal useds.shift, row.first_used
|
82
82
|
assert_equal unuseds.shift, row.first_unused
|
@@ -147,8 +147,8 @@ module Spreadsheet
|
|
147
147
|
enc = Encoding.find enc
|
148
148
|
end
|
149
149
|
assert_equal enc, book.encoding
|
150
|
-
assert_equal
|
151
|
-
assert_equal
|
150
|
+
assert_equal 24, book.formats.size
|
151
|
+
assert_equal 5, book.fonts.size
|
152
152
|
str1 = book.shared_string 0
|
153
153
|
assert_equal 'Shared String', str1
|
154
154
|
str2 = book.shared_string 1
|
@@ -179,7 +179,7 @@ module Spreadsheet
|
|
179
179
|
assert_equal 10, sheet.row_count
|
180
180
|
assert_equal 11, sheet.column_count
|
181
181
|
useds = [0,0,0,0,0,0,0,1,0,0]
|
182
|
-
unuseds = [2,2,1,1,1,2,1,11,1,
|
182
|
+
unuseds = [2,2,1,1,1,2,1,11,1,2]
|
183
183
|
sheet.each do |row|
|
184
184
|
assert_equal useds.shift, row.first_used
|
185
185
|
assert_equal unuseds.shift, row.first_unused
|
@@ -238,6 +238,11 @@ module Spreadsheet
|
|
238
238
|
assert_equal 0.0001, row[0]
|
239
239
|
row = sheet.row 9
|
240
240
|
assert_equal 0.00009, row[0]
|
241
|
+
link = row[1]
|
242
|
+
assert_instance_of Link, link
|
243
|
+
assert_equal 'Link-Text', link
|
244
|
+
assert_equal 'http://scm.ywesee.com/spreadsheet', link.url
|
245
|
+
assert_equal 'http://scm.ywesee.com/spreadsheet', link.href
|
241
246
|
end
|
242
247
|
def test_version_excel95__ooffice__utf16
|
243
248
|
Spreadsheet.client_encoding = 'UTF-16LE'
|
@@ -542,7 +547,7 @@ module Spreadsheet
|
|
542
547
|
assert_equal 10, sheet.row_count
|
543
548
|
assert_equal 11, sheet.column_count
|
544
549
|
useds = [0,0,0,0,0,0,0,1,0,0]
|
545
|
-
unuseds = [2,2,1,1,1,2,1,11,1,
|
550
|
+
unuseds = [2,2,1,1,1,2,1,11,1,2]
|
546
551
|
sheet.each do |row|
|
547
552
|
assert_equal useds.shift, row.first_used
|
548
553
|
assert_equal unuseds.shift, row.first_unused
|
@@ -651,7 +656,7 @@ module Spreadsheet
|
|
651
656
|
assert_equal 10, sheet.row_count
|
652
657
|
assert_equal 11, sheet.column_count
|
653
658
|
useds = [0,0,0,0,0,0,0,1,0,0]
|
654
|
-
unuseds = [2,2,1,1,1,2,1,11,1,
|
659
|
+
unuseds = [2,2,1,1,1,2,1,11,1,2]
|
655
660
|
sheet.each do |row|
|
656
661
|
assert_equal useds.shift, row.first_used
|
657
662
|
assert_equal unuseds.shift, row.first_unused
|
@@ -737,6 +742,9 @@ module Spreadsheet
|
|
737
742
|
fmt = Format.new :color => 'aqua'
|
738
743
|
sheet1[5,0] = 0.75
|
739
744
|
sheet1.row(5).set_format 0, fmt
|
745
|
+
link = Link.new 'http://scm.ywesee.com/?p=spreadsheet;a=summary',
|
746
|
+
'The Spreadsheet GitWeb'
|
747
|
+
sheet1[5,1] = link
|
740
748
|
sheet1[6,0] = 1
|
741
749
|
fmt = Format.new :color => 'green'
|
742
750
|
sheet1.row(6).set_format 0, fmt
|
@@ -850,6 +858,11 @@ module Spreadsheet
|
|
850
858
|
assert_equal 0.75, row[0]
|
851
859
|
assert_equal 0.75, sheet[5,0]
|
852
860
|
assert_equal 0.75, sheet.cell(5,0)
|
861
|
+
link = row[1]
|
862
|
+
assert_instance_of Link, link
|
863
|
+
url = @@iconv.iconv 'http://scm.ywesee.com/?p=spreadsheet;a=summary'
|
864
|
+
assert_equal @@iconv.iconv('The Spreadsheet GitWeb'), link
|
865
|
+
assert_equal url, link.url
|
853
866
|
row = sheet.row 6
|
854
867
|
assert_equal :green, row.format(0).font.color
|
855
868
|
assert_equal 1, row[0]
|
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.4
|
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-10-
|
12
|
+
date: 2008-10-23 00:00:00 +02:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -80,6 +80,7 @@ files:
|
|
80
80
|
- lib/spreadsheet/font.rb
|
81
81
|
- lib/spreadsheet/format.rb
|
82
82
|
- lib/spreadsheet/formula.rb
|
83
|
+
- lib/spreadsheet/link.rb
|
83
84
|
- lib/spreadsheet/row.rb
|
84
85
|
- lib/spreadsheet/workbook.rb
|
85
86
|
- lib/spreadsheet/worksheet.rb
|