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
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f244d6b1694de3b2590286a2b047de226f36cd855dd534a2db47d221da62ec59
|
|
4
|
+
data.tar.gz: e7043746b2683555f602be54ad7e3b68495e5bf7e9abaae5df5c839c139ecc74
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 97e1b3679d5693891b5a3caba131de68cbac2783067ebd4d318c457db924008b0100209a4d218ebd4357f80bf4cb70b8a1482ae5ea51fec1ec7fd23ccef89fd7
|
|
7
|
+
data.tar.gz: eee493446105db70f89be23210bafff8683c068cb1a0e319fe4ab356aa0af2ce4904d5e545e79eae4a15af898c9d5b69df9f6e0307a07f94ee5d3d7d09d9b083
|
data/bin/irb
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
#
|
|
5
|
+
# This file was generated by Bundler.
|
|
6
|
+
#
|
|
7
|
+
# The application 'irb' is installed as part of a gem, and
|
|
8
|
+
# this file is here to facilitate running it.
|
|
9
|
+
#
|
|
10
|
+
|
|
11
|
+
require "pathname"
|
|
12
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
|
|
13
|
+
Pathname.new(__FILE__).realpath)
|
|
14
|
+
|
|
15
|
+
bundle_binstub = File.expand_path("../bundle", __FILE__)
|
|
16
|
+
|
|
17
|
+
if File.file?(bundle_binstub)
|
|
18
|
+
if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
|
|
19
|
+
load(bundle_binstub)
|
|
20
|
+
else
|
|
21
|
+
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
|
22
|
+
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
require "rubygems"
|
|
27
|
+
require "bundler/setup"
|
|
28
|
+
|
|
29
|
+
load Gem.bin_path("irb", "irb")
|
data/bin/racc
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
#
|
|
5
|
+
# This file was generated by Bundler.
|
|
6
|
+
#
|
|
7
|
+
# The application 'racc' is installed as part of a gem, and
|
|
8
|
+
# this file is here to facilitate running it.
|
|
9
|
+
#
|
|
10
|
+
|
|
11
|
+
require "pathname"
|
|
12
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
|
|
13
|
+
Pathname.new(__FILE__).realpath)
|
|
14
|
+
|
|
15
|
+
bundle_binstub = File.expand_path("../bundle", __FILE__)
|
|
16
|
+
|
|
17
|
+
if File.file?(bundle_binstub)
|
|
18
|
+
if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
|
|
19
|
+
load(bundle_binstub)
|
|
20
|
+
else
|
|
21
|
+
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
|
22
|
+
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
require "rubygems"
|
|
27
|
+
require "bundler/setup"
|
|
28
|
+
|
|
29
|
+
load Gem.bin_path("racc", "racc")
|
data/bin/rdbg
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
#
|
|
5
|
+
# This file was generated by Bundler.
|
|
6
|
+
#
|
|
7
|
+
# The application 'rdbg' is installed as part of a gem, and
|
|
8
|
+
# this file is here to facilitate running it.
|
|
9
|
+
#
|
|
10
|
+
|
|
11
|
+
require "pathname"
|
|
12
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
|
|
13
|
+
Pathname.new(__FILE__).realpath)
|
|
14
|
+
|
|
15
|
+
bundle_binstub = File.expand_path("../bundle", __FILE__)
|
|
16
|
+
|
|
17
|
+
if File.file?(bundle_binstub)
|
|
18
|
+
if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
|
|
19
|
+
load(bundle_binstub)
|
|
20
|
+
else
|
|
21
|
+
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
|
22
|
+
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
require "rubygems"
|
|
27
|
+
require "bundler/setup"
|
|
28
|
+
|
|
29
|
+
load Gem.bin_path("debug", "rdbg")
|
data/bin/rdoc
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
#
|
|
5
|
+
# This file was generated by Bundler.
|
|
6
|
+
#
|
|
7
|
+
# The application 'rdoc' is installed as part of a gem, and
|
|
8
|
+
# this file is here to facilitate running it.
|
|
9
|
+
#
|
|
10
|
+
|
|
11
|
+
require "pathname"
|
|
12
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
|
|
13
|
+
Pathname.new(__FILE__).realpath)
|
|
14
|
+
|
|
15
|
+
bundle_binstub = File.expand_path("../bundle", __FILE__)
|
|
16
|
+
|
|
17
|
+
if File.file?(bundle_binstub)
|
|
18
|
+
if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
|
|
19
|
+
load(bundle_binstub)
|
|
20
|
+
else
|
|
21
|
+
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
|
22
|
+
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
require "rubygems"
|
|
27
|
+
require "bundler/setup"
|
|
28
|
+
|
|
29
|
+
load Gem.bin_path("rdoc", "rdoc")
|
data/bin/ri
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
#
|
|
5
|
+
# This file was generated by Bundler.
|
|
6
|
+
#
|
|
7
|
+
# The application 'ri' is installed as part of a gem, and
|
|
8
|
+
# this file is here to facilitate running it.
|
|
9
|
+
#
|
|
10
|
+
|
|
11
|
+
require "pathname"
|
|
12
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
|
|
13
|
+
Pathname.new(__FILE__).realpath)
|
|
14
|
+
|
|
15
|
+
bundle_binstub = File.expand_path("../bundle", __FILE__)
|
|
16
|
+
|
|
17
|
+
if File.file?(bundle_binstub)
|
|
18
|
+
if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
|
|
19
|
+
load(bundle_binstub)
|
|
20
|
+
else
|
|
21
|
+
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
|
22
|
+
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
require "rubygems"
|
|
27
|
+
require "bundler/setup"
|
|
28
|
+
|
|
29
|
+
load Gem.bin_path("rdoc", "ri")
|
data/bin/rubocop
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
#
|
|
5
|
+
# This file was generated by Bundler.
|
|
6
|
+
#
|
|
7
|
+
# The application 'rubocop' is installed as part of a gem, and
|
|
8
|
+
# this file is here to facilitate running it.
|
|
9
|
+
#
|
|
10
|
+
|
|
11
|
+
require "pathname"
|
|
12
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
|
|
13
|
+
Pathname.new(__FILE__).realpath)
|
|
14
|
+
|
|
15
|
+
bundle_binstub = File.expand_path("../bundle", __FILE__)
|
|
16
|
+
|
|
17
|
+
if File.file?(bundle_binstub)
|
|
18
|
+
if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
|
|
19
|
+
load(bundle_binstub)
|
|
20
|
+
else
|
|
21
|
+
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
|
22
|
+
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
require "rubygems"
|
|
27
|
+
require "bundler/setup"
|
|
28
|
+
|
|
29
|
+
load Gem.bin_path("rubocop", "rubocop")
|
data/bin/ruby-parse
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
#
|
|
5
|
+
# This file was generated by Bundler.
|
|
6
|
+
#
|
|
7
|
+
# The application 'ruby-parse' is installed as part of a gem, and
|
|
8
|
+
# this file is here to facilitate running it.
|
|
9
|
+
#
|
|
10
|
+
|
|
11
|
+
require "pathname"
|
|
12
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
|
|
13
|
+
Pathname.new(__FILE__).realpath)
|
|
14
|
+
|
|
15
|
+
bundle_binstub = File.expand_path("../bundle", __FILE__)
|
|
16
|
+
|
|
17
|
+
if File.file?(bundle_binstub)
|
|
18
|
+
if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
|
|
19
|
+
load(bundle_binstub)
|
|
20
|
+
else
|
|
21
|
+
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
|
22
|
+
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
require "rubygems"
|
|
27
|
+
require "bundler/setup"
|
|
28
|
+
|
|
29
|
+
load Gem.bin_path("parser", "ruby-parse")
|
data/bin/ruby-rewrite
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
#
|
|
5
|
+
# This file was generated by Bundler.
|
|
6
|
+
#
|
|
7
|
+
# The application 'ruby-rewrite' is installed as part of a gem, and
|
|
8
|
+
# this file is here to facilitate running it.
|
|
9
|
+
#
|
|
10
|
+
|
|
11
|
+
require "pathname"
|
|
12
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
|
|
13
|
+
Pathname.new(__FILE__).realpath)
|
|
14
|
+
|
|
15
|
+
bundle_binstub = File.expand_path("../bundle", __FILE__)
|
|
16
|
+
|
|
17
|
+
if File.file?(bundle_binstub)
|
|
18
|
+
if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
|
|
19
|
+
load(bundle_binstub)
|
|
20
|
+
else
|
|
21
|
+
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
|
22
|
+
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
require "rubygems"
|
|
27
|
+
require "bundler/setup"
|
|
28
|
+
|
|
29
|
+
load Gem.bin_path("parser", "ruby-rewrite")
|
data/bin/standardrb
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
#
|
|
5
|
+
# This file was generated by Bundler.
|
|
6
|
+
#
|
|
7
|
+
# The application 'standardrb' is installed as part of a gem, and
|
|
8
|
+
# this file is here to facilitate running it.
|
|
9
|
+
#
|
|
10
|
+
|
|
11
|
+
require "pathname"
|
|
12
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
|
|
13
|
+
Pathname.new(__FILE__).realpath)
|
|
14
|
+
|
|
15
|
+
bundle_binstub = File.expand_path("../bundle", __FILE__)
|
|
16
|
+
|
|
17
|
+
if File.file?(bundle_binstub)
|
|
18
|
+
if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
|
|
19
|
+
load(bundle_binstub)
|
|
20
|
+
else
|
|
21
|
+
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
|
22
|
+
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
require "rubygems"
|
|
27
|
+
require "bundler/setup"
|
|
28
|
+
|
|
29
|
+
load Gem.bin_path("standard", "standardrb")
|
data/bin/test-unit
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
#
|
|
5
|
+
# This file was generated by Bundler.
|
|
6
|
+
#
|
|
7
|
+
# The application 'test-unit' is installed as part of a gem, and
|
|
8
|
+
# this file is here to facilitate running it.
|
|
9
|
+
#
|
|
10
|
+
|
|
11
|
+
require "pathname"
|
|
12
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
|
|
13
|
+
Pathname.new(__FILE__).realpath)
|
|
14
|
+
|
|
15
|
+
bundle_binstub = File.expand_path("../bundle", __FILE__)
|
|
16
|
+
|
|
17
|
+
if File.file?(bundle_binstub)
|
|
18
|
+
if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
|
|
19
|
+
load(bundle_binstub)
|
|
20
|
+
else
|
|
21
|
+
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
|
22
|
+
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
require "rubygems"
|
|
27
|
+
require "bundler/setup"
|
|
28
|
+
|
|
29
|
+
load Gem.bin_path("test-unit", "test-unit")
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
require
|
|
1
|
+
require "spreadsheet"
|
|
2
2
|
|
|
3
|
-
warn
|
|
4
|
-
[DEPRECATED] By requiring 'parseexcel', 'parseexcel/parseexcel' and/or
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
3
|
+
warn <<~EOS
|
|
4
|
+
[DEPRECATED] By requiring 'parseexcel', 'parseexcel/parseexcel' and/or
|
|
5
|
+
'parseexcel/parser' you are loading a Compatibility layer which
|
|
6
|
+
provides a drop-in replacement for the ParseExcel library. This
|
|
7
|
+
code makes the reading of Spreadsheet documents less efficient and
|
|
8
|
+
will be removed in Spreadsheet version 1.0.0
|
|
9
9
|
EOS
|
|
10
10
|
|
|
11
11
|
module Spreadsheet
|
|
@@ -14,62 +14,70 @@ module Spreadsheet
|
|
|
14
14
|
# ParseExcel library. This code is deprecated and will be removed in
|
|
15
15
|
# Spreadsheet version 1.0.0
|
|
16
16
|
module ParseExcel
|
|
17
|
-
def
|
|
18
|
-
|
|
19
|
-
end
|
|
20
|
-
class Worksheet
|
|
21
|
-
class Cell
|
|
22
|
-
attr_accessor :value, :kind, :numeric, :code, :book,
|
|
23
|
-
:format, :rich, :encoding, :annotation
|
|
24
|
-
def initialize value, format, row, idx
|
|
25
|
-
@format = format
|
|
26
|
-
@idx = idx
|
|
27
|
-
@row = row
|
|
28
|
-
@value = value
|
|
29
|
-
@encoding = Spreadsheet.client_encoding
|
|
30
|
-
end
|
|
31
|
-
def date
|
|
32
|
-
@row.date @idx
|
|
33
|
-
end
|
|
34
|
-
def datetime
|
|
35
|
-
@row.datetime @idx
|
|
36
|
-
end
|
|
37
|
-
def to_i
|
|
38
|
-
@value.to_i
|
|
17
|
+
def self.parse path
|
|
18
|
+
Spreadsheet.open path
|
|
39
19
|
end
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
20
|
+
|
|
21
|
+
class Worksheet
|
|
22
|
+
class Cell
|
|
23
|
+
attr_accessor :value, :kind, :numeric, :code, :book,
|
|
24
|
+
:format, :rich, :encoding, :annotation
|
|
25
|
+
def initialize value, format, row, idx
|
|
26
|
+
@format = format
|
|
27
|
+
@idx = idx
|
|
28
|
+
@row = row
|
|
29
|
+
@value = value
|
|
30
|
+
@encoding = Spreadsheet.client_encoding
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def date
|
|
34
|
+
@row.date @idx
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def datetime
|
|
38
|
+
@row.datetime @idx
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def to_i
|
|
42
|
+
@value.to_i
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def to_f
|
|
46
|
+
@value.to_f
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def to_s(target_encoding = nil)
|
|
50
|
+
if target_encoding
|
|
51
|
+
begin
|
|
52
|
+
Iconv.new(target_encoding, @encoding).iconv(@value)
|
|
53
|
+
rescue
|
|
54
|
+
Iconv.new(target_encoding, "ascii").iconv(@value.to_s)
|
|
55
|
+
end
|
|
56
|
+
else
|
|
57
|
+
@value.to_s
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
def type
|
|
62
|
+
if @format && (@format.date? || @format.time?)
|
|
63
|
+
:date
|
|
64
|
+
elsif @value.is_a?(Numeric)
|
|
65
|
+
:numeric
|
|
66
|
+
else
|
|
67
|
+
:text
|
|
68
|
+
end
|
|
49
69
|
end
|
|
50
|
-
else
|
|
51
|
-
@value.to_s
|
|
52
|
-
end
|
|
53
|
-
end
|
|
54
|
-
def type
|
|
55
|
-
if @format && (@format.date? || @format.time?)
|
|
56
|
-
:date
|
|
57
|
-
elsif @value.is_a?(Numeric)
|
|
58
|
-
:numeric
|
|
59
|
-
else
|
|
60
|
-
:text
|
|
61
70
|
end
|
|
62
71
|
end
|
|
63
72
|
end
|
|
64
|
-
|
|
65
|
-
end
|
|
73
|
+
|
|
66
74
|
module Excel
|
|
67
|
-
class Reader # :nodoc: all
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
end
|
|
75
|
+
class Reader # :nodoc: all
|
|
76
|
+
def set_cell worksheet, row, column, xf, value = nil
|
|
77
|
+
cells = @current_row_block[row] ||= Row.new(nil, row)
|
|
78
|
+
cells.formats[column] = xf = @workbook.format(xf)
|
|
79
|
+
cells[column] = ParseExcel::Worksheet::Cell.new(value, xf, cells, column)
|
|
80
|
+
end
|
|
81
|
+
end
|
|
74
82
|
end
|
|
75
83
|
end
|
data/lib/parseexcel/parser.rb
CHANGED
data/lib/parseexcel.rb
CHANGED
data/lib/spreadsheet/column.rb
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
require
|
|
1
|
+
require "spreadsheet/datatypes"
|
|
2
2
|
|
|
3
3
|
module Spreadsheet
|
|
4
4
|
##
|
|
@@ -20,11 +20,11 @@ module Spreadsheet
|
|
|
20
20
|
class << self
|
|
21
21
|
def updater *keys
|
|
22
22
|
keys.each do |key|
|
|
23
|
-
unless
|
|
23
|
+
unless method_defined?("unupdated_#{key}=")
|
|
24
24
|
alias_method :"unupdated_#{key}=", :"#{key}="
|
|
25
|
-
define_method "#{key}=" do |value|
|
|
26
|
-
send "unupdated_#{key}=", value
|
|
27
|
-
@worksheet
|
|
25
|
+
define_method :"#{key}=" do |value|
|
|
26
|
+
send :"unupdated_#{key}=", value
|
|
27
|
+
@worksheet&.column_updated @idx, self
|
|
28
28
|
value
|
|
29
29
|
end
|
|
30
30
|
end
|
|
@@ -33,28 +33,30 @@ module Spreadsheet
|
|
|
33
33
|
end
|
|
34
34
|
include Datatypes
|
|
35
35
|
include Enumerable
|
|
36
|
+
|
|
36
37
|
attr_accessor :width, :worksheet
|
|
37
38
|
attr_reader :default_format, :idx
|
|
38
39
|
boolean :hidden, :collapsed
|
|
39
40
|
enum :outline_level, 0, Integer
|
|
40
41
|
updater :collapsed, :hidden, :outline_level, :width
|
|
41
|
-
def initialize idx, format, opts={}
|
|
42
|
+
def initialize idx, format, opts = {}
|
|
42
43
|
@worksheet = nil
|
|
43
44
|
@idx = idx
|
|
44
45
|
opts[:width] ||= 10
|
|
45
46
|
opts.each do |key, value|
|
|
46
|
-
|
|
47
|
+
send :"#{key}=", value
|
|
47
48
|
end
|
|
48
49
|
self.default_format = format
|
|
49
50
|
end
|
|
51
|
+
|
|
50
52
|
##
|
|
51
53
|
# Set the default Format for Cells in this Column.
|
|
52
54
|
def default_format= format
|
|
53
|
-
@worksheet
|
|
55
|
+
@worksheet&.add_format format
|
|
54
56
|
@default_format = format
|
|
55
|
-
@worksheet
|
|
56
|
-
format
|
|
57
|
+
@worksheet&.column_updated @idx, self
|
|
57
58
|
end
|
|
59
|
+
|
|
58
60
|
##
|
|
59
61
|
# Iterate over all cells in this column.
|
|
60
62
|
def each
|
|
@@ -62,6 +64,7 @@ module Spreadsheet
|
|
|
62
64
|
yield row[idx]
|
|
63
65
|
end
|
|
64
66
|
end
|
|
67
|
+
|
|
65
68
|
def == other # :nodoc:
|
|
66
69
|
other.is_a?(Column) && default_format == other.default_format \
|
|
67
70
|
&& width == other.width && hidden == other.hidden \
|
|
@@ -4,10 +4,11 @@ module Spreadsheet
|
|
|
4
4
|
# One of the most incisive changes in terms of meta-programming in Ruby 1.9
|
|
5
5
|
# is the switch from representing instance-variable names as Strings to
|
|
6
6
|
# presenting them as Symbols. ivar_name provides compatibility.
|
|
7
|
-
if RUBY_VERSION >=
|
|
7
|
+
if RUBY_VERSION >= "1.9"
|
|
8
8
|
def ivar_name symbol
|
|
9
9
|
:"@#{symbol}"
|
|
10
10
|
end
|
|
11
|
+
|
|
11
12
|
def method_name symbol
|
|
12
13
|
symbol.to_sym
|
|
13
14
|
end
|
|
@@ -15,6 +16,7 @@ module Spreadsheet
|
|
|
15
16
|
def ivar_name symbol
|
|
16
17
|
"@#{symbol}"
|
|
17
18
|
end
|
|
19
|
+
|
|
18
20
|
def method_name symbol
|
|
19
21
|
symbol.to_s
|
|
20
22
|
end
|