writeexcel 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (109) hide show
  1. data/README +103 -0
  2. data/examples/a_simple.rb +42 -0
  3. data/examples/autofilters.rb +266 -0
  4. data/examples/copyformat.rb +51 -0
  5. data/examples/data_validate.rb +278 -0
  6. data/examples/date_time.rb +86 -0
  7. data/examples/demo.rb +118 -0
  8. data/examples/diag_border.rb +35 -0
  9. data/examples/formats.rb +489 -0
  10. data/examples/header.rb +136 -0
  11. data/examples/hidden.rb +28 -0
  12. data/examples/hyperlink.rb +42 -0
  13. data/examples/images.rb +52 -0
  14. data/examples/merge1.rb +39 -0
  15. data/examples/merge2.rb +44 -0
  16. data/examples/merge3.rb +65 -0
  17. data/examples/merge4.rb +82 -0
  18. data/examples/merge5.rb +79 -0
  19. data/examples/protection.rb +46 -0
  20. data/examples/regions.rb +52 -0
  21. data/examples/repeat.rb +42 -0
  22. data/examples/republic.png +0 -0
  23. data/examples/stats.rb +75 -0
  24. data/examples/stocks.rb +80 -0
  25. data/examples/tab_colors.rb +30 -0
  26. data/lib/writeexcel/biffwriter.rb +260 -0
  27. data/lib/writeexcel/chart.rb +217 -0
  28. data/lib/writeexcel/excelformulaparser.rb +573 -0
  29. data/lib/writeexcel/format.rb +1108 -0
  30. data/lib/writeexcel/formula.rb +986 -0
  31. data/lib/writeexcel/olewriter.rb +322 -0
  32. data/lib/writeexcel/properties.rb +250 -0
  33. data/lib/writeexcel/workbook.rb +2630 -0
  34. data/lib/writeexcel/worksheet.rb +6377 -0
  35. data/lib/writeexcel.rb +18 -0
  36. data/test/perl_output/README +31 -0
  37. data/test/perl_output/a_simple.xls +0 -0
  38. data/test/perl_output/biff_add_continue_testdata +0 -0
  39. data/test/perl_output/data_validate.xls +0 -0
  40. data/test/perl_output/date_time.xls +0 -0
  41. data/test/perl_output/demo.xls +0 -0
  42. data/test/perl_output/diag_border.xls +0 -0
  43. data/test/perl_output/f_font_biff +0 -0
  44. data/test/perl_output/f_font_key +1 -0
  45. data/test/perl_output/f_xf_biff +0 -0
  46. data/test/perl_output/file_font_biff +0 -0
  47. data/test/perl_output/file_font_key +1 -0
  48. data/test/perl_output/file_xf_biff +0 -0
  49. data/test/perl_output/headers.xls +0 -0
  50. data/test/perl_output/hidden.xls +0 -0
  51. data/test/perl_output/hyperlink.xls +0 -0
  52. data/test/perl_output/images.xls +0 -0
  53. data/test/perl_output/merge1.xls +0 -0
  54. data/test/perl_output/merge2.xls +0 -0
  55. data/test/perl_output/merge3.xls +0 -0
  56. data/test/perl_output/merge4.xls +0 -0
  57. data/test/perl_output/merge5.xls +0 -0
  58. data/test/perl_output/ole_write_header +0 -0
  59. data/test/perl_output/protection.xls +0 -0
  60. data/test/perl_output/regions.xls +0 -0
  61. data/test/perl_output/stats.xls +0 -0
  62. data/test/perl_output/stocks.xls +0 -0
  63. data/test/perl_output/tab_colors.xls +0 -0
  64. data/test/perl_output/unicode_cyrillic.xls +0 -0
  65. data/test/perl_output/workbook1.xls +0 -0
  66. data/test/perl_output/workbook2.xls +0 -0
  67. data/test/perl_output/ws_colinfo +1 -0
  68. data/test/perl_output/ws_store_colinfo +0 -0
  69. data/test/perl_output/ws_store_dimensions +0 -0
  70. data/test/perl_output/ws_store_filtermode +0 -0
  71. data/test/perl_output/ws_store_filtermode_off +0 -0
  72. data/test/perl_output/ws_store_filtermode_on +0 -0
  73. data/test/perl_output/ws_store_selection +0 -0
  74. data/test/perl_output/ws_store_window2 +1 -0
  75. data/test/republic.png +0 -0
  76. data/test/tc_all.rb +31 -0
  77. data/test/tc_biff.rb +104 -0
  78. data/test/tc_chart.rb +22 -0
  79. data/test/tc_example_match.rb +1280 -0
  80. data/test/tc_format.rb +1267 -0
  81. data/test/tc_formula.rb +63 -0
  82. data/test/tc_ole.rb +110 -0
  83. data/test/tc_workbook.rb +115 -0
  84. data/test/tc_worksheet.rb +115 -0
  85. data/test/test_00_IEEE_double.rb +14 -0
  86. data/test/test_01_add_worksheet.rb +12 -0
  87. data/test/test_02_merge_formats.rb +58 -0
  88. data/test/test_04_dimensions.rb +397 -0
  89. data/test/test_05_rows.rb +182 -0
  90. data/test/test_06_extsst.rb +80 -0
  91. data/test/test_11_date_time.rb +484 -0
  92. data/test/test_12_date_only.rb +506 -0
  93. data/test/test_13_date_seconds.rb +486 -0
  94. data/test/test_21_escher.rb +629 -0
  95. data/test/test_22_mso_drawing_group.rb +739 -0
  96. data/test/test_23_note.rb +78 -0
  97. data/test/test_24_txo.rb +80 -0
  98. data/test/test_26_autofilter.rb +327 -0
  99. data/test/test_27_autofilter.rb +144 -0
  100. data/test/test_28_autofilter.rb +174 -0
  101. data/test/test_29_process_jpg.rb +131 -0
  102. data/test/test_30_validation_dval.rb +82 -0
  103. data/test/test_31_validation_dv_strings.rb +131 -0
  104. data/test/test_32_validation_dv_formula.rb +211 -0
  105. data/test/test_40_property_types.rb +191 -0
  106. data/test/test_41_properties.rb +238 -0
  107. data/test/test_42_set_properties.rb +419 -0
  108. data/test/ts_all.rb +34 -0
  109. 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
@@ -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
@@ -0,0 +1 @@
1
+ 15
Binary file
File without changes
File without changes
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