writeexcel 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README +103 -0
- data/examples/a_simple.rb +42 -0
- data/examples/autofilters.rb +266 -0
- data/examples/copyformat.rb +51 -0
- data/examples/data_validate.rb +278 -0
- data/examples/date_time.rb +86 -0
- data/examples/demo.rb +118 -0
- data/examples/diag_border.rb +35 -0
- data/examples/formats.rb +489 -0
- data/examples/header.rb +136 -0
- data/examples/hidden.rb +28 -0
- data/examples/hyperlink.rb +42 -0
- data/examples/images.rb +52 -0
- data/examples/merge1.rb +39 -0
- data/examples/merge2.rb +44 -0
- data/examples/merge3.rb +65 -0
- data/examples/merge4.rb +82 -0
- data/examples/merge5.rb +79 -0
- data/examples/protection.rb +46 -0
- data/examples/regions.rb +52 -0
- data/examples/repeat.rb +42 -0
- data/examples/republic.png +0 -0
- data/examples/stats.rb +75 -0
- data/examples/stocks.rb +80 -0
- data/examples/tab_colors.rb +30 -0
- data/lib/writeexcel/biffwriter.rb +260 -0
- data/lib/writeexcel/chart.rb +217 -0
- data/lib/writeexcel/excelformulaparser.rb +573 -0
- data/lib/writeexcel/format.rb +1108 -0
- data/lib/writeexcel/formula.rb +986 -0
- data/lib/writeexcel/olewriter.rb +322 -0
- data/lib/writeexcel/properties.rb +250 -0
- data/lib/writeexcel/workbook.rb +2630 -0
- data/lib/writeexcel/worksheet.rb +6377 -0
- data/lib/writeexcel.rb +18 -0
- data/test/perl_output/README +31 -0
- data/test/perl_output/a_simple.xls +0 -0
- data/test/perl_output/biff_add_continue_testdata +0 -0
- data/test/perl_output/data_validate.xls +0 -0
- data/test/perl_output/date_time.xls +0 -0
- data/test/perl_output/demo.xls +0 -0
- data/test/perl_output/diag_border.xls +0 -0
- data/test/perl_output/f_font_biff +0 -0
- data/test/perl_output/f_font_key +1 -0
- data/test/perl_output/f_xf_biff +0 -0
- data/test/perl_output/file_font_biff +0 -0
- data/test/perl_output/file_font_key +1 -0
- data/test/perl_output/file_xf_biff +0 -0
- data/test/perl_output/headers.xls +0 -0
- data/test/perl_output/hidden.xls +0 -0
- data/test/perl_output/hyperlink.xls +0 -0
- data/test/perl_output/images.xls +0 -0
- data/test/perl_output/merge1.xls +0 -0
- data/test/perl_output/merge2.xls +0 -0
- data/test/perl_output/merge3.xls +0 -0
- data/test/perl_output/merge4.xls +0 -0
- data/test/perl_output/merge5.xls +0 -0
- data/test/perl_output/ole_write_header +0 -0
- data/test/perl_output/protection.xls +0 -0
- data/test/perl_output/regions.xls +0 -0
- data/test/perl_output/stats.xls +0 -0
- data/test/perl_output/stocks.xls +0 -0
- data/test/perl_output/tab_colors.xls +0 -0
- data/test/perl_output/unicode_cyrillic.xls +0 -0
- data/test/perl_output/workbook1.xls +0 -0
- data/test/perl_output/workbook2.xls +0 -0
- data/test/perl_output/ws_colinfo +1 -0
- data/test/perl_output/ws_store_colinfo +0 -0
- data/test/perl_output/ws_store_dimensions +0 -0
- data/test/perl_output/ws_store_filtermode +0 -0
- data/test/perl_output/ws_store_filtermode_off +0 -0
- data/test/perl_output/ws_store_filtermode_on +0 -0
- data/test/perl_output/ws_store_selection +0 -0
- data/test/perl_output/ws_store_window2 +1 -0
- data/test/republic.png +0 -0
- data/test/tc_all.rb +31 -0
- data/test/tc_biff.rb +104 -0
- data/test/tc_chart.rb +22 -0
- data/test/tc_example_match.rb +1280 -0
- data/test/tc_format.rb +1267 -0
- data/test/tc_formula.rb +63 -0
- data/test/tc_ole.rb +110 -0
- data/test/tc_workbook.rb +115 -0
- data/test/tc_worksheet.rb +115 -0
- data/test/test_00_IEEE_double.rb +14 -0
- data/test/test_01_add_worksheet.rb +12 -0
- data/test/test_02_merge_formats.rb +58 -0
- data/test/test_04_dimensions.rb +397 -0
- data/test/test_05_rows.rb +182 -0
- data/test/test_06_extsst.rb +80 -0
- data/test/test_11_date_time.rb +484 -0
- data/test/test_12_date_only.rb +506 -0
- data/test/test_13_date_seconds.rb +486 -0
- data/test/test_21_escher.rb +629 -0
- data/test/test_22_mso_drawing_group.rb +739 -0
- data/test/test_23_note.rb +78 -0
- data/test/test_24_txo.rb +80 -0
- data/test/test_26_autofilter.rb +327 -0
- data/test/test_27_autofilter.rb +144 -0
- data/test/test_28_autofilter.rb +174 -0
- data/test/test_29_process_jpg.rb +131 -0
- data/test/test_30_validation_dval.rb +82 -0
- data/test/test_31_validation_dv_strings.rb +131 -0
- data/test/test_32_validation_dv_formula.rb +211 -0
- data/test/test_40_property_types.rb +191 -0
- data/test/test_41_properties.rb +238 -0
- data/test/test_42_set_properties.rb +419 -0
- data/test/ts_all.rb +34 -0
- metadata +170 -0
data/lib/writeexcel.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
###############################################################################
|
2
|
+
#
|
3
|
+
# WriteExcel.
|
4
|
+
#
|
5
|
+
# Spreadsheet::WriteExcel - Write to a cross-platform Excel binary file.
|
6
|
+
#
|
7
|
+
# Copyright 2000-2008, John McNamara, jmcnamara@cpan.org
|
8
|
+
#
|
9
|
+
# original written in Perl by John McNamara
|
10
|
+
# converted to Ruby by Hideo Nakamura, cxn03651@msj.biglobe.ne.jp
|
11
|
+
#
|
12
|
+
require "writeexcel/workbook"
|
13
|
+
|
14
|
+
class Spreadsheet
|
15
|
+
class WriteExcel < Workbook
|
16
|
+
VERSION = "0.1.0"
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
###############################################################################
|
2
|
+
# This file contains sample output from the Spreadsheet::WriteExcel Perl
|
3
|
+
# module. Used for testing file sizes/contents
|
4
|
+
###############################################################################
|
5
|
+
|
6
|
+
Files:
|
7
|
+
|
8
|
+
ws_ -> from Worksheet.pm
|
9
|
+
f_ -> from Format.pm
|
10
|
+
ole_ -> from OLEWriter.pm
|
11
|
+
|
12
|
+
f_font_biff
|
13
|
+
Output of the _get_font call
|
14
|
+
|
15
|
+
f_font_key
|
16
|
+
Output of the _get_font_key call
|
17
|
+
|
18
|
+
f_xf_biff
|
19
|
+
Output of the _get_xf call
|
20
|
+
|
21
|
+
ws_colinfo
|
22
|
+
Output of the _store_colinfo call (default values)
|
23
|
+
|
24
|
+
ws_store_dimensions
|
25
|
+
Output of the _store_dimensions call
|
26
|
+
|
27
|
+
ws_store_window2
|
28
|
+
Output of the _store_window call
|
29
|
+
|
30
|
+
ws_store_selection
|
31
|
+
Output of the _store_selection call
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1 @@
|
|
1
|
+
Arial100004000000327670
|
Binary file
|
Binary file
|
@@ -0,0 +1 @@
|
|
1
|
+
Arial1000040000003276700
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1 @@
|
|
1
|
+
15
|
Binary file
|
Binary file
|
File without changes
|
File without changes
|
Binary file
|
Binary file
|
@@ -0,0 +1 @@
|
|
1
|
+
14
|
data/test/republic.png
ADDED
Binary file
|
data/test/tc_all.rb
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
require "tc_biff"
|
2
|
+
require "tc_ole"
|
3
|
+
require "tc_workbook"
|
4
|
+
require "tc_worksheet"
|
5
|
+
require "tc_format"
|
6
|
+
require "tc_formula"
|
7
|
+
require 'tc_chart'
|
8
|
+
require "test_00_IEEE_double"
|
9
|
+
require 'test_01_add_worksheet'
|
10
|
+
require 'test_02_merge_formats'
|
11
|
+
require 'test_04_dimensions'
|
12
|
+
require 'test_05_rows'
|
13
|
+
require 'test_06_extsst'
|
14
|
+
require 'test_11_date_time'
|
15
|
+
require 'test_12_date_only'
|
16
|
+
require 'test_13_date_seconds'
|
17
|
+
require 'test_21_escher'
|
18
|
+
require 'test_22_mso_drawing_group'
|
19
|
+
require 'test_23_note'
|
20
|
+
require 'test_24_txo'
|
21
|
+
require 'test_26_autofilter'
|
22
|
+
require 'test_27_autofilter'
|
23
|
+
require 'test_28_autofilter'
|
24
|
+
require 'test_29_process_jpg'
|
25
|
+
require 'test_30_validation_dval'
|
26
|
+
require 'test_31_validation_dv_strings'
|
27
|
+
require 'test_32_validation_dv_formula'
|
28
|
+
require 'test_40_property_types'
|
29
|
+
require 'test_41_properties'
|
30
|
+
require 'test_42_set_properties'
|
31
|
+
require 'tc_example_match'
|
data/test/tc_biff.rb
ADDED
@@ -0,0 +1,104 @@
|
|
1
|
+
$LOAD_PATH.unshift "#{File.dirname(__FILE__)}/../lib"
|
2
|
+
|
3
|
+
require "test/unit"
|
4
|
+
require "writeexcel"
|
5
|
+
|
6
|
+
class TC_BIFFWriter < Test::Unit::TestCase
|
7
|
+
|
8
|
+
TEST_DIR = File.expand_path(File.dirname(__FILE__))
|
9
|
+
PERL_OUTDIR = File.join(TEST_DIR, 'perl_output')
|
10
|
+
|
11
|
+
def setup
|
12
|
+
t = Time.now.strftime("%Y%m%d")
|
13
|
+
path = "temp#{t}-#{$$}-#{rand(0x100000000).to_s(36)}"
|
14
|
+
@test_file = File.join(Dir.tmpdir, path)
|
15
|
+
@biff = BIFFWriter.new
|
16
|
+
@ruby_file = @test_file
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_append_no_error
|
20
|
+
assert_nothing_raised{ @biff.append("World") }
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_prepend_no_error
|
24
|
+
assert_nothing_raised{ @biff.prepend("Hello") }
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_data_added
|
28
|
+
assert_nothing_raised{ @biff.append("Hello", "World") }
|
29
|
+
data = ''
|
30
|
+
while d = @biff.get_data
|
31
|
+
data = data + d
|
32
|
+
end
|
33
|
+
assert_equal("HelloWorld", data, "Bad data contents")
|
34
|
+
assert_equal(10, @biff.datasize, "Bad data size")
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_data_prepended
|
38
|
+
|
39
|
+
assert_nothing_raised{ @biff.append("Hello") }
|
40
|
+
assert_nothing_raised{ @biff.prepend("World") }
|
41
|
+
data = ''
|
42
|
+
while d = @biff.get_data
|
43
|
+
data = data + d
|
44
|
+
end
|
45
|
+
assert_equal("WorldHello", data, "Bad data contents")
|
46
|
+
assert_equal(10, @biff.datasize, "Bad data size")
|
47
|
+
end
|
48
|
+
|
49
|
+
def test_store_bof_length
|
50
|
+
assert_nothing_raised{ @biff.store_bof }
|
51
|
+
assert_equal(20, @biff.datasize, "Bad data size after store_bof call")
|
52
|
+
end
|
53
|
+
|
54
|
+
def test_store_eof_length
|
55
|
+
assert_nothing_raised{ @biff.store_eof }
|
56
|
+
assert_equal(4, @biff.datasize, "Bad data size after store_eof call")
|
57
|
+
end
|
58
|
+
|
59
|
+
def test_datasize_mixed
|
60
|
+
assert_nothing_raised{ @biff.append("Hello") }
|
61
|
+
assert_nothing_raised{ @biff.prepend("World") }
|
62
|
+
assert_nothing_raised{ @biff.store_bof }
|
63
|
+
assert_nothing_raised{ @biff.store_eof }
|
64
|
+
assert_equal(34, @biff.datasize, "Bad data size for mixed data")
|
65
|
+
end
|
66
|
+
|
67
|
+
def test_add_continue
|
68
|
+
perl_file = "#{PERL_OUTDIR}/biff_add_continue_testdata"
|
69
|
+
size = File.size(perl_file)
|
70
|
+
@fh = File.new(@ruby_file,"w+")
|
71
|
+
@fh.print(@biff.add_continue('testdata'))
|
72
|
+
@fh.close
|
73
|
+
rsize = File.size(@ruby_file)
|
74
|
+
assert_equal(size,rsize,"File sizes not the same")
|
75
|
+
compare_file(perl_file, @ruby_file)
|
76
|
+
end
|
77
|
+
|
78
|
+
def teardown
|
79
|
+
@biff = nil
|
80
|
+
File.delete(@ruby_file) if File.exist?(@ruby_file)
|
81
|
+
end
|
82
|
+
|
83
|
+
def compare_file(expected, target)
|
84
|
+
fh_e = File.open(expected, "r")
|
85
|
+
fh_t = File.open(target, "r")
|
86
|
+
while true do
|
87
|
+
e1 = fh_e.read(1)
|
88
|
+
t1 = fh_t.read(1)
|
89
|
+
if e1.nil?
|
90
|
+
assert( t1.nil?, "#{expexted} is EOF but #{target} is NOT EOF.")
|
91
|
+
break
|
92
|
+
elsif t1.nil?
|
93
|
+
assert( e1.nil?, '#{target} is EOF but #{expected} is NOT EOF.')
|
94
|
+
break
|
95
|
+
end
|
96
|
+
assert_equal(e1, t1, sprintf(" #{expected} = '%s' but #{target} = '%s'", e1, t1))
|
97
|
+
break
|
98
|
+
end
|
99
|
+
fh_e.close
|
100
|
+
fh_t.close
|
101
|
+
end
|
102
|
+
|
103
|
+
|
104
|
+
end
|
data/test/tc_chart.rb
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
#####################################################
|
2
|
+
# tc_chart.rb
|
3
|
+
#
|
4
|
+
# Test suite for the Chart class (chart.rb)
|
5
|
+
#####################################################
|
6
|
+
base = File.basename(Dir.pwd)
|
7
|
+
if base == "test" || base =~ /spreadsheet/i
|
8
|
+
Dir.chdir("..") if base == "test"
|
9
|
+
$LOAD_PATH.unshift(Dir.pwd + "/lib/spreadsheet")
|
10
|
+
Dir.chdir("test") rescue nil
|
11
|
+
end
|
12
|
+
|
13
|
+
require "test/unit"
|
14
|
+
require "writeexcel"
|
15
|
+
|
16
|
+
class TC_Chart < Test::Unit::TestCase
|
17
|
+
|
18
|
+
def test_
|
19
|
+
assert(true)
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|