spreadsheet 1.3.3 → 1.3.5
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.
- checksums.yaml +4 -4
- data/bin/irb +29 -0
- data/bin/racc +29 -0
- data/bin/rdbg +29 -0
- data/bin/rdoc +29 -0
- data/bin/ri +29 -0
- data/bin/rubocop +29 -0
- data/bin/ruby-parse +29 -0
- data/bin/ruby-rewrite +29 -0
- data/bin/standardrb +29 -0
- data/bin/test-unit +29 -0
- data/lib/parseexcel/parseexcel.rb +66 -58
- data/lib/parseexcel/parser.rb +1 -1
- data/lib/parseexcel.rb +1 -1
- data/lib/spreadsheet/column.rb +13 -10
- data/lib/spreadsheet/compatibility.rb +3 -1
- data/lib/spreadsheet/datatypes.rb +150 -147
- data/lib/spreadsheet/encodings.rb +20 -16
- data/lib/spreadsheet/errors.rb +2 -2
- data/lib/spreadsheet/excel/error.rb +23 -22
- data/lib/spreadsheet/excel/internals/biff5.rb +11 -11
- data/lib/spreadsheet/excel/internals/biff8.rb +13 -13
- data/lib/spreadsheet/excel/internals.rb +451 -451
- data/lib/spreadsheet/excel/offset.rb +34 -31
- data/lib/spreadsheet/excel/password_hash.rb +18 -18
- data/lib/spreadsheet/excel/reader/biff5.rb +34 -35
- data/lib/spreadsheet/excel/reader/biff8.rb +235 -222
- data/lib/spreadsheet/excel/reader.rb +1331 -1274
- data/lib/spreadsheet/excel/rgb.rb +91 -91
- data/lib/spreadsheet/excel/row.rb +99 -91
- data/lib/spreadsheet/excel/sst_entry.rb +41 -38
- data/lib/spreadsheet/excel/workbook.rb +87 -76
- data/lib/spreadsheet/excel/worksheet.rb +126 -107
- data/lib/spreadsheet/excel/writer/biff8.rb +57 -55
- data/lib/spreadsheet/excel/writer/format.rb +274 -256
- data/lib/spreadsheet/excel/writer/n_worksheet.rb +838 -798
- data/lib/spreadsheet/excel/writer/workbook.rb +672 -635
- data/lib/spreadsheet/excel/writer/worksheet.rb +899 -861
- data/lib/spreadsheet/excel/writer.rb +1 -1
- data/lib/spreadsheet/excel.rb +19 -12
- data/lib/spreadsheet/font.rb +31 -26
- data/lib/spreadsheet/format.rb +75 -59
- data/lib/spreadsheet/link.rb +8 -5
- data/lib/spreadsheet/note.rb +7 -6
- data/lib/spreadsheet/noteObject.rb +6 -5
- data/lib/spreadsheet/row.rb +35 -24
- data/lib/spreadsheet/version.rb +1 -1
- data/lib/spreadsheet/workbook.rb +28 -13
- data/lib/spreadsheet/worksheet.rb +103 -68
- data/lib/spreadsheet/writer.rb +3 -0
- data/lib/spreadsheet.rb +12 -15
- data/test/data/test_row_record_empty_range.xls +0 -0
- data/test/excel/reader.rb +8 -8
- data/test/excel/row.rb +35 -31
- data/test/excel/writer/workbook.rb +18 -16
- data/test/excel/writer/worksheet.rb +10 -8
- data/test/font.rb +44 -32
- data/test/format.rb +38 -33
- data/test/integration.rb +641 -598
- data/test/row.rb +5 -3
- data/test/suite.rb +7 -7
- data/test/workbook.rb +15 -14
- data/test/workbook_protection.rb +5 -5
- data/test/worksheet.rb +36 -34
- metadata +59 -6
|
@@ -1 +1 @@
|
|
|
1
|
-
require
|
|
1
|
+
require "spreadsheet/excel/writer/workbook"
|
data/lib/spreadsheet/excel.rb
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
require
|
|
1
|
+
require "spreadsheet"
|
|
2
2
|
|
|
3
3
|
##
|
|
4
4
|
# Spreadsheet::Excel Compatibility Layer.
|
|
@@ -7,38 +7,42 @@ module Spreadsheet
|
|
|
7
7
|
module Excel
|
|
8
8
|
class ExcelCompatibleWorkbook < Workbook
|
|
9
9
|
def initialize file_path, *args
|
|
10
|
-
super
|
|
10
|
+
super(*args)
|
|
11
11
|
@file_path = file_path
|
|
12
12
|
end
|
|
13
|
+
|
|
13
14
|
def close
|
|
14
15
|
write @file_path
|
|
15
16
|
end
|
|
16
17
|
end
|
|
17
|
-
|
|
18
|
+
|
|
19
|
+
def self.new file_path
|
|
18
20
|
ExcelCompatibleWorkbook.new file_path
|
|
19
21
|
end
|
|
22
|
+
|
|
20
23
|
class Workbook
|
|
21
24
|
def add_worksheet name
|
|
22
25
|
if name.is_a? String
|
|
23
|
-
create_worksheet :
|
|
26
|
+
create_worksheet name: name
|
|
24
27
|
else
|
|
25
28
|
super
|
|
26
29
|
end
|
|
27
30
|
end
|
|
28
31
|
end
|
|
29
32
|
end
|
|
33
|
+
|
|
30
34
|
class Worksheet
|
|
31
|
-
unless
|
|
32
|
-
|
|
33
|
-
def format_column column, width=nil, format=nil
|
|
35
|
+
unless method_defined?(:new_format_column)
|
|
36
|
+
alias_method :new_format_column, :format_column
|
|
37
|
+
def format_column column, width = nil, format = nil
|
|
34
38
|
if width.is_a? Format
|
|
35
39
|
new_format_column column, width, format
|
|
36
40
|
else
|
|
37
|
-
new_format_column column, format, :
|
|
41
|
+
new_format_column column, format, width: width
|
|
38
42
|
end
|
|
39
43
|
end
|
|
40
44
|
end
|
|
41
|
-
def write row, col, data=nil, format=nil
|
|
45
|
+
def write row, col, data = nil, format = nil
|
|
42
46
|
if data.is_a? Array
|
|
43
47
|
write_row row, col, data, format
|
|
44
48
|
else
|
|
@@ -47,7 +51,8 @@ module Spreadsheet
|
|
|
47
51
|
row.set_format col, format
|
|
48
52
|
end
|
|
49
53
|
end
|
|
50
|
-
|
|
54
|
+
|
|
55
|
+
def write_column row, col, data = nil, format = nil
|
|
51
56
|
if data.is_a? Array
|
|
52
57
|
data.each do |token|
|
|
53
58
|
if token.is_a? Array
|
|
@@ -61,7 +66,8 @@ module Spreadsheet
|
|
|
61
66
|
write row, col, data, format
|
|
62
67
|
end
|
|
63
68
|
end
|
|
64
|
-
|
|
69
|
+
|
|
70
|
+
def write_row row, col, data = nil, format = nil
|
|
65
71
|
if data.is_a? Array
|
|
66
72
|
data.each do |token|
|
|
67
73
|
if token.is_a? Array
|
|
@@ -75,7 +81,8 @@ module Spreadsheet
|
|
|
75
81
|
write row, col, data, format
|
|
76
82
|
end
|
|
77
83
|
end
|
|
78
|
-
|
|
84
|
+
|
|
85
|
+
def write_url row, col, url, string = url, format = nil
|
|
79
86
|
row(row)[col] = Link.new url, string
|
|
80
87
|
end
|
|
81
88
|
end
|
data/lib/spreadsheet/font.rb
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
require
|
|
3
|
-
require 'spreadsheet/encodings'
|
|
1
|
+
require "spreadsheet/datatypes"
|
|
2
|
+
require "spreadsheet/encodings"
|
|
4
3
|
|
|
5
4
|
module Spreadsheet
|
|
6
5
|
##
|
|
@@ -8,6 +7,7 @@ module Spreadsheet
|
|
|
8
7
|
class Font
|
|
9
8
|
include Spreadsheet::Datatypes
|
|
10
9
|
include Spreadsheet::Encodings
|
|
10
|
+
|
|
11
11
|
attr_accessor :name
|
|
12
12
|
##
|
|
13
13
|
# You can set the following boolean Font attributes
|
|
@@ -27,14 +27,14 @@ module Spreadsheet
|
|
|
27
27
|
# :bold => 700
|
|
28
28
|
# :normal => 400
|
|
29
29
|
# Default: :normal
|
|
30
|
-
enum :weight, :normal, :bold, Integer, :
|
|
30
|
+
enum :weight, :normal, :bold, Integer, bold: :b
|
|
31
31
|
##
|
|
32
32
|
# Escapement
|
|
33
33
|
# Valid values: :normal, :superscript or :subscript.
|
|
34
34
|
# Default: :normal
|
|
35
35
|
enum :escapement, :normal, :superscript, :subscript,
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
subscript: :sub,
|
|
37
|
+
superscript: :super
|
|
38
38
|
# Font size
|
|
39
39
|
# Valid values: Any positive Integer.
|
|
40
40
|
# Default: 10
|
|
@@ -44,8 +44,8 @@ module Spreadsheet
|
|
|
44
44
|
# :double_accounting.
|
|
45
45
|
# Default: :none
|
|
46
46
|
enum :underline, :none, :single, :double,
|
|
47
|
-
|
|
48
|
-
|
|
47
|
+
:single_accounting, :double_accounting,
|
|
48
|
+
single: true
|
|
49
49
|
# Font Family
|
|
50
50
|
# Valid values: :none, :roman, :swiss, :modern, :script, :decorative
|
|
51
51
|
# Default: :none
|
|
@@ -57,11 +57,11 @@ module Spreadsheet
|
|
|
57
57
|
# :hebrew, :arabic, :cyrillic, :thai, :iso_latin2, :oem_latin1
|
|
58
58
|
# Default: :default
|
|
59
59
|
enum :encoding, :default, :iso_latin1, :symbol, :apple_roman, :shift_jis,
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
def initialize name, opts={}
|
|
60
|
+
:korean_hangul, :korean_johab, :chinese_simplified,
|
|
61
|
+
:chinese_traditional, :greek, :turkish, :vietnamese,
|
|
62
|
+
:hebrew, :arabic, :baltic, :cyrillic, :thai, :iso_latin2,
|
|
63
|
+
:oem_latin1
|
|
64
|
+
def initialize name, opts = {}
|
|
65
65
|
self.name = name
|
|
66
66
|
@color = :text
|
|
67
67
|
@previous_fast_key = nil
|
|
@@ -76,38 +76,43 @@ module Spreadsheet
|
|
|
76
76
|
@family = nil
|
|
77
77
|
@encoding = nil
|
|
78
78
|
opts.each do |key, val|
|
|
79
|
-
|
|
79
|
+
send :"#{key}=", val
|
|
80
80
|
end
|
|
81
81
|
end
|
|
82
|
+
|
|
82
83
|
##
|
|
83
84
|
# Sets #weight to :bold if(_bool_), :normal otherwise.
|
|
84
85
|
def bold= bool
|
|
85
86
|
self.weight = bool ? :bold : nil
|
|
86
87
|
end
|
|
88
|
+
|
|
87
89
|
def key # :nodoc:
|
|
88
90
|
fk = fast_key
|
|
89
91
|
return @key if @previous_fast_key == fk
|
|
90
92
|
@previous_fast_key = fk
|
|
91
93
|
@key = build_key
|
|
92
94
|
end
|
|
95
|
+
|
|
93
96
|
private
|
|
97
|
+
|
|
94
98
|
def build_key # :nodoc:
|
|
95
|
-
underscore = client(
|
|
99
|
+
underscore = client("_", "UTF-8")
|
|
96
100
|
key = []
|
|
97
101
|
key << @name
|
|
98
|
-
key << underscore << client(size.to_s,
|
|
99
|
-
key << underscore << client(weight.to_s,
|
|
100
|
-
key << client(
|
|
101
|
-
key << client(
|
|
102
|
-
key << client(
|
|
103
|
-
key << client(
|
|
104
|
-
key << underscore << client(escapement.to_s,
|
|
105
|
-
key << underscore << client(underline.to_s,
|
|
106
|
-
key << underscore << client(color.to_s,
|
|
107
|
-
key << underscore << client(family.to_s,
|
|
108
|
-
key << underscore << client(encoding.to_s,
|
|
102
|
+
key << underscore << client(size.to_s, "US-ASCII")
|
|
103
|
+
key << underscore << client(weight.to_s, "US-ASCII")
|
|
104
|
+
key << client("_italic", "UTF-8") if italic?
|
|
105
|
+
key << client("_strikeout", "UTF-8") if strikeout?
|
|
106
|
+
key << client("_outline", "UTF-8") if outline?
|
|
107
|
+
key << client("_shadow", "UTF-8") if shadow?
|
|
108
|
+
key << underscore << client(escapement.to_s, "US-ASCII")
|
|
109
|
+
key << underscore << client(underline.to_s, "US-ASCII")
|
|
110
|
+
key << underscore << client(color.to_s, "US-ASCII")
|
|
111
|
+
key << underscore << client(family.to_s, "US-ASCII")
|
|
112
|
+
key << underscore << client(encoding.to_s, "US-ASCII")
|
|
109
113
|
key.join("")
|
|
110
114
|
end
|
|
115
|
+
|
|
111
116
|
def fast_key
|
|
112
117
|
[@name, @size, @weight, @italic, @strikeout, @outline, @shadow, @escapement, @underline, @color, @family, @encoding]
|
|
113
118
|
end
|
data/lib/spreadsheet/format.rb
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
require
|
|
3
|
-
require
|
|
4
|
-
require 'spreadsheet/font'
|
|
1
|
+
require "spreadsheet/datatypes"
|
|
2
|
+
require "spreadsheet/encodings"
|
|
3
|
+
require "spreadsheet/font"
|
|
5
4
|
|
|
6
5
|
module Spreadsheet
|
|
7
6
|
##
|
|
@@ -9,6 +8,7 @@ module Spreadsheet
|
|
|
9
8
|
class Format
|
|
10
9
|
include Spreadsheet::Datatypes
|
|
11
10
|
include Spreadsheet::Encodings
|
|
11
|
+
|
|
12
12
|
##
|
|
13
13
|
# You can set the following boolean attributes:
|
|
14
14
|
# #cross_down:: Draws a Line from the top-left to the bottom-right
|
|
@@ -29,84 +29,84 @@ module Spreadsheet
|
|
|
29
29
|
# other. Excel will ignore other rotation values if
|
|
30
30
|
# this is set.
|
|
31
31
|
boolean :cross_down, :cross_up, :hidden, :locked,
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
:merge_range, :shrink, :text_justlast, :text_wrap,
|
|
33
|
+
:rotation_stacked
|
|
34
34
|
##
|
|
35
35
|
# Border line styles
|
|
36
|
-
# Valid values: :none, :thin, :medium, :dashed, :dotted, :thick,
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
36
|
+
# Valid values: :none, :thin, :medium, :dashed, :dotted, :thick,
|
|
37
|
+
# :double, :hair, :medium_dashed, :thin_dash_dotted,
|
|
38
|
+
# :medium_dash_dotted, :thin_dash_dot_dotted,
|
|
39
|
+
# :medium_dash_dot_dotted, :slanted_medium_dash_dotted
|
|
40
40
|
# Default: :none
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
41
|
+
styles = [:thin, :medium, :dashed, :dotted, :thick,
|
|
42
|
+
:double, :hair, :medium_dashed, :thin_dash_dotted,
|
|
43
|
+
:medium_dash_dotted, :thin_dash_dot_dotted,
|
|
44
|
+
:medium_dash_dot_dotted, :slanted_medium_dash_dotted]
|
|
45
|
+
enum :left, :none, *styles
|
|
46
|
+
enum :right, :none, *styles
|
|
47
|
+
enum :top, :none, *styles
|
|
48
|
+
enum :bottom, :none, *styles
|
|
49
49
|
|
|
50
50
|
##
|
|
51
51
|
# Color attributes
|
|
52
|
-
colors
|
|
53
|
-
|
|
54
|
-
|
|
52
|
+
colors :bottom_color, :top_color, :left_color, :right_color,
|
|
53
|
+
:pattern_fg_color, :pattern_bg_color,
|
|
54
|
+
:diagonal_color
|
|
55
55
|
##
|
|
56
56
|
# Text direction
|
|
57
57
|
# Valid values: :context, :left_to_right, :right_to_left
|
|
58
58
|
# Default: :context
|
|
59
59
|
enum :text_direction, :context, :left_to_right, :right_to_left,
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
60
|
+
left_to_right: [:ltr, :l2r],
|
|
61
|
+
right_to_left: [:rtl, :r2l]
|
|
62
|
+
alias_method :reading_order, :text_direction
|
|
63
|
+
alias_method :reading_order=, :text_direction=
|
|
64
64
|
##
|
|
65
65
|
# Indentation level
|
|
66
66
|
enum :indent_level, 0, Integer
|
|
67
|
-
|
|
68
|
-
|
|
67
|
+
alias_method :indent, :indent_level
|
|
68
|
+
alias_method :indent=, :indent_level=
|
|
69
69
|
##
|
|
70
70
|
# Horizontal alignment
|
|
71
71
|
# Valid values: :default, :left, :center, :right, :fill, :justify, :merge,
|
|
72
72
|
# :distributed
|
|
73
73
|
# Default: :default
|
|
74
74
|
enum :horizontal_align, :default, :left, :center, :right, :fill, :justify,
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
75
|
+
:merge, :distributed,
|
|
76
|
+
center: :centre,
|
|
77
|
+
merge: [:center_across, :centre_across],
|
|
78
|
+
distributed: :equal_space
|
|
79
79
|
##
|
|
80
80
|
# Vertical alignment
|
|
81
81
|
# Valid values: :bottom, :top, :middle, :justify, :distributed
|
|
82
82
|
# Default: :bottom
|
|
83
83
|
enum :vertical_align, :bottom, :top, :middle, :justify, :distributed,
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
84
|
+
distributed: [:vdistributed, :vequal_space, :equal_space],
|
|
85
|
+
justify: :vjustify,
|
|
86
|
+
middle: [:vcenter, :vcentre, :center, :centre]
|
|
87
87
|
attr_accessor :font, :number_format, :name, :pattern, :used_merge
|
|
88
88
|
##
|
|
89
89
|
# Text rotation
|
|
90
90
|
attr_reader :rotation
|
|
91
|
-
def initialize opts={}
|
|
92
|
-
@font
|
|
93
|
-
@number_format
|
|
94
|
-
@rotation
|
|
95
|
-
@pattern
|
|
96
|
-
@bottom_color
|
|
97
|
-
@top_color
|
|
98
|
-
@left_color
|
|
99
|
-
@right_color
|
|
100
|
-
@diagonal_color
|
|
91
|
+
def initialize opts = {}
|
|
92
|
+
@font = Font.new client("Arial", "UTF-8"), family: :swiss
|
|
93
|
+
@number_format = client "GENERAL", "UTF-8"
|
|
94
|
+
@rotation = 0
|
|
95
|
+
@pattern = 0
|
|
96
|
+
@bottom_color = :black
|
|
97
|
+
@top_color = :black
|
|
98
|
+
@left_color = :black
|
|
99
|
+
@right_color = :black
|
|
100
|
+
@diagonal_color = :black
|
|
101
101
|
@pattern_fg_color = :border
|
|
102
102
|
@pattern_bg_color = :pattern_bg
|
|
103
103
|
@regexes = {
|
|
104
|
-
:
|
|
105
|
-
:
|
|
106
|
-
:
|
|
107
|
-
:
|
|
108
|
-
:
|
|
109
|
-
:
|
|
104
|
+
date: Regexp.new(client("[YMD]|d{2}|m{3}|y{2}", "UTF-8")),
|
|
105
|
+
date_or_time: Regexp.new(client("[hmsYMD]", "UTF-8")),
|
|
106
|
+
datetime: Regexp.new(client("([YMD].*[HS])|([HS].*[YMD])", "UTF-8")),
|
|
107
|
+
time: Regexp.new(client("[hms]", "UTF-8")),
|
|
108
|
+
number: Regexp.new(client("([#]|0+)", "UTF-8")),
|
|
109
|
+
locale: Regexp.new(client(/\A\[\$-\S+\]/.to_s, "UTF-8"))
|
|
110
110
|
}
|
|
111
111
|
|
|
112
112
|
# Temp code to prevent merged formats in non-merged cells.
|
|
@@ -119,7 +119,7 @@ module Spreadsheet
|
|
|
119
119
|
def update_format(opts = {})
|
|
120
120
|
opts.each do |attribute, value|
|
|
121
121
|
writer = "#{attribute}="
|
|
122
|
-
@font.respond_to?(writer) ? @font.send(writer,value) :
|
|
122
|
+
@font.respond_to?(writer) ? @font.send(writer, value) : send(writer, value)
|
|
123
123
|
end
|
|
124
124
|
self
|
|
125
125
|
end
|
|
@@ -135,83 +135,99 @@ module Spreadsheet
|
|
|
135
135
|
def align= location
|
|
136
136
|
self.horizontal_align = location
|
|
137
137
|
rescue ArgumentError
|
|
138
|
-
self.vertical_align =
|
|
138
|
+
self.vertical_align = begin
|
|
139
|
+
location
|
|
140
|
+
rescue
|
|
141
|
+
ArgumentError
|
|
142
|
+
end
|
|
139
143
|
end
|
|
144
|
+
|
|
140
145
|
##
|
|
141
146
|
# Returns an Array containing the line styles of the four borders:
|
|
142
147
|
# bottom, top, right, left
|
|
143
148
|
def border
|
|
144
149
|
[bottom, top, right, left]
|
|
145
150
|
end
|
|
151
|
+
|
|
146
152
|
##
|
|
147
153
|
# Set same line style on all four borders at once (left, right, top, bottom)
|
|
148
154
|
def border=(style)
|
|
149
|
-
[:bottom=, :top=, :right=, :left=].each
|
|
155
|
+
[:bottom=, :top=, :right=, :left=].each { |writer| send writer, style }
|
|
150
156
|
end
|
|
157
|
+
|
|
151
158
|
##
|
|
152
159
|
# Returns an Array containing the colors of the four borders:
|
|
153
160
|
# bottom, top, right, left
|
|
154
161
|
def border_color
|
|
155
|
-
[@bottom_color
|
|
162
|
+
[@bottom_color, @top_color, @right_color, @left_color]
|
|
156
163
|
end
|
|
164
|
+
|
|
157
165
|
##
|
|
158
166
|
# Set all four border colors to _color_ (left, right, top, bottom)
|
|
159
167
|
def border_color=(color)
|
|
160
168
|
[:bottom_color=, :top_color=, :right_color=, :left_color=].each do |writer|
|
|
161
|
-
send writer, color
|
|
169
|
+
send writer, color
|
|
170
|
+
end
|
|
162
171
|
end
|
|
172
|
+
|
|
163
173
|
##
|
|
164
174
|
# Set the Text rotation
|
|
165
175
|
# Valid values: Integers from -90 to 90,
|
|
166
176
|
# or :stacked (sets #rotation_stacked to true)
|
|
167
177
|
def rotation=(rot)
|
|
168
|
-
if rot.to_s.downcase ==
|
|
178
|
+
if rot.to_s.downcase == "stacked"
|
|
169
179
|
@rotation_stacked = true
|
|
170
180
|
@rotation = 0
|
|
171
|
-
elsif rot.
|
|
181
|
+
elsif rot.is_a?(Integer)
|
|
172
182
|
@rotation_stacked = false
|
|
173
183
|
@rotation = rot % 360
|
|
174
184
|
else
|
|
175
185
|
raise TypeError, "rotation value must be an Integer or the String 'stacked'"
|
|
176
186
|
end
|
|
177
187
|
end
|
|
188
|
+
|
|
178
189
|
##
|
|
179
190
|
# Backward compatibility method. May disappear at some point in the future.
|
|
180
191
|
def center_across!
|
|
181
192
|
self.horizontal_align = :merge
|
|
182
193
|
end
|
|
183
|
-
|
|
194
|
+
alias_method :merge!, :center_across!
|
|
184
195
|
##
|
|
185
196
|
# Is the cell formatted as a Date?
|
|
186
197
|
def date?
|
|
187
198
|
!number? && matches_format?(:date)
|
|
188
199
|
end
|
|
200
|
+
|
|
189
201
|
##
|
|
190
202
|
# Is the cell formatted as a Date or Time?
|
|
191
203
|
def date_or_time?
|
|
192
204
|
!number? && matches_format?(:date_or_time)
|
|
193
205
|
end
|
|
206
|
+
|
|
194
207
|
##
|
|
195
208
|
# Is the cell formatted as a DateTime?
|
|
196
209
|
def datetime?
|
|
197
210
|
!number? && matches_format?(:datetime)
|
|
198
211
|
end
|
|
212
|
+
|
|
199
213
|
##
|
|
200
214
|
# Is the cell formatted as a Time?
|
|
201
215
|
def time?
|
|
202
216
|
!number? && matches_format?(:time)
|
|
203
217
|
end
|
|
218
|
+
|
|
204
219
|
##
|
|
205
220
|
# Is the cell formatted as a number?
|
|
206
221
|
def number?
|
|
207
222
|
matches_format?(:number)
|
|
208
223
|
end
|
|
224
|
+
|
|
209
225
|
##
|
|
210
226
|
# Does the cell match a particular preset format?
|
|
211
227
|
def matches_format?(name)
|
|
212
228
|
# Excel number formats may optionally include a locale identifier like this:
|
|
213
229
|
# [$-409]
|
|
214
|
-
format = @number_format.to_s.sub(@regexes[:locale],
|
|
230
|
+
format = @number_format.to_s.sub(@regexes[:locale], "")
|
|
215
231
|
!!@regexes[name].match(format)
|
|
216
232
|
end
|
|
217
233
|
end
|
data/lib/spreadsheet/link.rb
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
require
|
|
2
|
-
require
|
|
1
|
+
require "uri"
|
|
2
|
+
require "spreadsheet/encodings"
|
|
3
3
|
|
|
4
4
|
module Spreadsheet
|
|
5
5
|
##
|
|
@@ -19,21 +19,24 @@ module Spreadsheet
|
|
|
19
19
|
# but if you do, here is where you can find it.
|
|
20
20
|
class Link < String
|
|
21
21
|
include Encodings
|
|
22
|
+
|
|
22
23
|
attr_accessor :target_frame, :url, :dos, :fragment
|
|
23
|
-
def initialize url=
|
|
24
|
-
super
|
|
24
|
+
def initialize url = "", description = url, fragment = nil
|
|
25
|
+
super(description)
|
|
25
26
|
@url = url
|
|
26
27
|
@fragment = fragment
|
|
27
28
|
end
|
|
29
|
+
|
|
28
30
|
##
|
|
29
31
|
# The Url with the fragment appended if present.
|
|
30
32
|
def href
|
|
31
33
|
href = (@url || @dos).to_s.dup
|
|
32
34
|
if @fragment
|
|
33
|
-
href << client(
|
|
35
|
+
href << client("#", "UTF-8") << @fragment
|
|
34
36
|
end
|
|
35
37
|
href
|
|
36
38
|
end
|
|
39
|
+
|
|
37
40
|
##
|
|
38
41
|
# Attempts to parse the output of href. May raise a URI::InvalidURIError
|
|
39
42
|
def to_uri
|
data/lib/spreadsheet/note.rb
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
require
|
|
1
|
+
require "spreadsheet/encodings"
|
|
2
2
|
|
|
3
3
|
module Spreadsheet
|
|
4
4
|
##
|
|
@@ -10,14 +10,15 @@ module Spreadsheet
|
|
|
10
10
|
# #author :: The name of the author who wrote the note
|
|
11
11
|
class Note
|
|
12
12
|
include Encodings
|
|
13
|
-
|
|
13
|
+
|
|
14
|
+
attr_accessor :author, :length, :obj_id, :row, :col, :text
|
|
14
15
|
def initialize
|
|
15
16
|
@author = nil
|
|
16
17
|
@length = 0
|
|
17
|
-
@
|
|
18
|
-
@row
|
|
19
|
-
@col
|
|
20
|
-
@text
|
|
18
|
+
@obj_id = nil
|
|
19
|
+
@row = -1
|
|
20
|
+
@col = -1
|
|
21
|
+
@text = ""
|
|
21
22
|
end
|
|
22
23
|
end
|
|
23
24
|
end
|
|
@@ -1,17 +1,18 @@
|
|
|
1
|
-
require
|
|
1
|
+
require "spreadsheet/encodings"
|
|
2
2
|
|
|
3
3
|
module Spreadsheet
|
|
4
4
|
##
|
|
5
|
-
# The NoteObject class is made to handle the text output from the
|
|
5
|
+
# The NoteObject class is made to handle the text output from the
|
|
6
6
|
# object, txo, continue records which contain a comment's text record.
|
|
7
7
|
#
|
|
8
8
|
#
|
|
9
9
|
class NoteObject
|
|
10
10
|
include Encodings
|
|
11
|
-
|
|
11
|
+
|
|
12
|
+
attr_accessor :obj_id, :text
|
|
12
13
|
def initialize
|
|
13
|
-
@
|
|
14
|
-
@text
|
|
14
|
+
@obj_id = -1
|
|
15
|
+
@text = ""
|
|
15
16
|
end
|
|
16
17
|
end
|
|
17
18
|
end
|