writeexcel 1.0.5 → 1.0.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (69) hide show
  1. checksums.yaml +5 -5
  2. data/.travis.yml +8 -0
  3. data/README.rdoc +5 -0
  4. data/lib/writeexcel/biffwriter.rb +2 -1
  5. data/lib/writeexcel/chart.rb +2 -3
  6. data/lib/writeexcel/charts/area.rb +1 -1
  7. data/lib/writeexcel/charts/pie.rb +1 -1
  8. data/lib/writeexcel/charts/scatter.rb +1 -1
  9. data/lib/writeexcel/charts/stock.rb +1 -1
  10. data/lib/writeexcel/col_info.rb +2 -2
  11. data/lib/writeexcel/comments.rb +1 -1
  12. data/lib/writeexcel/convert_date_time.rb +7 -7
  13. data/lib/writeexcel/excelformulaparser.rb +49 -49
  14. data/lib/writeexcel/format.rb +1 -1
  15. data/lib/writeexcel/formula.rb +1 -1
  16. data/lib/writeexcel/helper.rb +3 -3
  17. data/lib/writeexcel/properties.rb +1 -1
  18. data/lib/writeexcel/shared_string_table.rb +5 -5
  19. data/lib/writeexcel/storage_lite.rb +2 -9
  20. data/lib/writeexcel/version.rb +1 -1
  21. data/lib/writeexcel/workbook.rb +13 -14
  22. data/lib/writeexcel/worksheet.rb +43 -35
  23. data/test/helper.rb +12 -4
  24. data/test/test_00_IEEE_double.rb +1 -1
  25. data/test/test_04_dimensions.rb +2 -2
  26. data/test/test_05_rows.rb +1 -1
  27. data/test/test_06_extsst.rb +1 -1
  28. data/test/test_11_date_time.rb +1 -1
  29. data/test/test_12_date_only.rb +1 -1
  30. data/test/test_13_date_seconds.rb +1 -1
  31. data/test/test_21_escher.rb +1 -1
  32. data/test/test_22_mso_drawing_group.rb +1 -1
  33. data/test/test_23_note.rb +1 -1
  34. data/test/test_24_txo.rb +1 -1
  35. data/test/test_25_position_object.rb +1 -1
  36. data/test/test_26_autofilter.rb +1 -1
  37. data/test/test_27_autofilter.rb +1 -1
  38. data/test/test_28_autofilter.rb +1 -1
  39. data/test/test_29_process_jpg.rb +1 -43
  40. data/test/test_30_validation_dval.rb +1 -1
  41. data/test/test_31_validation_dv_strings.rb +1 -1
  42. data/test/test_32_validation_dv_formula.rb +1 -1
  43. data/test/test_40_property_types.rb +1 -1
  44. data/test/test_41_properties.rb +1 -1
  45. data/test/test_42_set_properties.rb +2 -2
  46. data/test/test_50_name_stored.rb +1 -9
  47. data/test/test_51_name_print_area.rb +3 -13
  48. data/test/test_52_name_print_titles.rb +3 -21
  49. data/test/test_53_autofilter.rb +1 -5
  50. data/test/test_60_chart_generic.rb +3 -3
  51. data/test/test_61_chart_subclasses.rb +2 -1
  52. data/test/test_62_chart_formats.rb +9 -21
  53. data/test/test_63_chart_area_formats.rb +1 -1
  54. data/test/test_compatibility.rb +1 -1
  55. data/test/test_example_match.rb +835 -835
  56. data/test/test_format.rb +1 -114
  57. data/test/test_formula.rb +1 -1
  58. data/test/test_properties.rb +1 -2
  59. data/test/test_storage_lite.rb +2 -2
  60. data/test/test_workbook.rb +1 -66
  61. data/test/test_worksheet.rb +1 -18
  62. data/test/test_write_formula_does_not_change_formula_string.rb +1 -1
  63. data/writeexcel.gemspec +3 -2
  64. metadata +23 -20
  65. data/test/test_01_add_worksheet.rb +0 -43
  66. data/test/test_02_merge_formats.rb +0 -49
  67. data/test/test_biff.rb +0 -71
  68. data/test/test_big_workbook.rb +0 -17
  69. data/test/test_ole.rb +0 -102
@@ -2,7 +2,7 @@
2
2
  require 'helper'
3
3
  require 'stringio'
4
4
 
5
- class TC_example_match < Test::Unit::TestCase
5
+ class TC_example_match < Minitest::Test
6
6
 
7
7
  TEST_DIR = File.expand_path(File.dirname(__FILE__))
8
8
  PERL_OUTDIR = File.join(TEST_DIR, 'perl_output')
@@ -62,9 +62,9 @@ class TC_example_match < Test::Unit::TestCase
62
62
 
63
63
  # Set up several sheets with the same data.
64
64
  workbook.sheets.each do |worksheet|
65
- worksheet.set_column('A:D', 12)
66
- worksheet.set_row(0, 20, bold)
67
- worksheet.write('A1', headings)
65
+ worksheet.set_column('A:D', 12)
66
+ worksheet.set_row(0, 20, bold)
67
+ worksheet.write('A1', headings)
68
68
  end
69
69
 
70
70
  ###############################################################################
@@ -95,17 +95,17 @@ class TC_example_match < Test::Unit::TestCase
95
95
  row = 1
96
96
 
97
97
  data.each do |row_data|
98
- region = row_data[0]
98
+ region = row_data[0]
99
99
 
100
- if region == 'East'
101
- # Row is visible.
102
- else
103
- # Hide row.
104
- worksheet2.set_row(row, nil, nil, 1)
105
- end
100
+ if region == 'East'
101
+ # Row is visible.
102
+ else
103
+ # Hide row.
104
+ worksheet2.set_row(row, nil, nil, 1)
105
+ end
106
106
 
107
- worksheet2.write(row, 0, row_data)
108
- row += 1
107
+ worksheet2.write(row, 0, row_data)
108
+ row += 1
109
109
  end
110
110
 
111
111
 
@@ -125,17 +125,17 @@ class TC_example_match < Test::Unit::TestCase
125
125
  row = 1
126
126
 
127
127
  data.each do |row_data|
128
- region = row_data[0]
128
+ region = row_data[0]
129
129
 
130
- if region == 'East' || region == 'South'
131
- # Row is visible.
132
- else
133
- # Hide row.
134
- worksheet3.set_row(row, nil, nil, 1)
135
- end
130
+ if region == 'East' || region == 'South'
131
+ # Row is visible.
132
+ else
133
+ # Hide row.
134
+ worksheet3.set_row(row, nil, nil, 1)
135
+ end
136
136
 
137
- worksheet3.write(row, 0, row_data)
138
- row += 1
137
+ worksheet3.write(row, 0, row_data)
138
+ row += 1
139
139
  end
140
140
 
141
141
 
@@ -156,18 +156,18 @@ class TC_example_match < Test::Unit::TestCase
156
156
  row = 1
157
157
 
158
158
  data.each do |row_data|
159
- region = row_data[0]
160
- volume = row_data[2]
161
-
162
- if region == 'East' && volume > 3000 && volume < 8000
163
- # Row is visible.
164
- else
165
- # Hide row.
166
- worksheet4.set_row(row, nil, nil, 1)
167
- end
168
-
169
- worksheet4.write(row, 0, row_data)
170
- row += 1
159
+ region = row_data[0]
160
+ volume = row_data[2]
161
+
162
+ if region == 'East' && volume > 3000 && volume < 8000
163
+ # Row is visible.
164
+ else
165
+ # Hide row.
166
+ worksheet4.set_row(row, nil, nil, 1)
167
+ end
168
+
169
+ worksheet4.write(row, 0, row_data)
170
+ row += 1
171
171
  end
172
172
 
173
173
 
@@ -189,17 +189,17 @@ class TC_example_match < Test::Unit::TestCase
189
189
  row = 1
190
190
 
191
191
  data.each do |row_data|
192
- region = row_data[0]
192
+ region = row_data[0]
193
193
 
194
- if region == ''
195
- # Row is visible.
196
- else
197
- # Hide row.
198
- worksheet5.set_row(row, nil, nil, 1)
199
- end
194
+ if region == ''
195
+ # Row is visible.
196
+ else
197
+ # Hide row.
198
+ worksheet5.set_row(row, nil, nil, 1)
199
+ end
200
200
 
201
- worksheet5.write(row, 0, row_data)
202
- row += 1
201
+ worksheet5.write(row, 0, row_data)
202
+ row += 1
203
203
  end
204
204
 
205
205
 
@@ -218,17 +218,17 @@ class TC_example_match < Test::Unit::TestCase
218
218
  row = 1
219
219
 
220
220
  data.each do |row_data|
221
- region = row_data[0]
221
+ region = row_data[0]
222
222
 
223
- if region != ''
224
- # Row is visible.
225
- else
226
- # Hide row.
227
- worksheet6.set_row(row, nil, nil, 1)
228
- end
223
+ if region != ''
224
+ # Row is visible.
225
+ else
226
+ # Hide row.
227
+ worksheet6.set_row(row, nil, nil, 1)
228
+ end
229
229
 
230
- worksheet6.write(row, 0, row_data)
231
- row += 1
230
+ worksheet6.write(row, 0, row_data)
231
+ row += 1
232
232
  end
233
233
 
234
234
  workbook.close
@@ -308,7 +308,7 @@ class TC_example_match < Test::Unit::TestCase
308
308
 
309
309
  # Add a caption to each worksheet
310
310
  workbook.sheets.each do |worksheet|
311
- worksheet.write(0, 0, "Sales", format)
311
+ worksheet.write(0, 0, "Sales", format)
312
312
  end
313
313
 
314
314
  # Write some data
@@ -436,7 +436,7 @@ class TC_example_match < Test::Unit::TestCase
436
436
  italy = WriteExcel.new(file2)
437
437
  ita_links = italy.add_worksheet('Links')
438
438
  ita_sales = italy.add_worksheet('Sales')
439
- ita_data = italy.add_worksheet('Product Data')
439
+ italy.add_worksheet('Product Data')
440
440
 
441
441
  file3 = StringIO.new
442
442
  china = WriteExcel.new(file3)
@@ -586,13 +586,13 @@ class TC_example_match < Test::Unit::TestCase
586
586
 
587
587
  # Add a format for the header cells.
588
588
  header_format = workbook.add_format(
589
- :border => 1,
590
- :bg_color => 43,
591
- :bold => 1,
592
- :text_wrap => 1,
593
- :valign => 'vcenter',
594
- :indent => 1
595
- )
589
+ :border => 1,
590
+ :bg_color => 43,
591
+ :bold => 1,
592
+ :text_wrap => 1,
593
+ :valign => 'vcenter',
594
+ :indent => 1
595
+ )
596
596
 
597
597
  # Set up layout of the worksheet.
598
598
  worksheet.set_column('A:A', 64)
@@ -625,12 +625,12 @@ class TC_example_match < Test::Unit::TestCase
625
625
 
626
626
  worksheet.write(row, 0, txt)
627
627
  worksheet.data_validation(row, 1,
628
- {
629
- :validate => 'integer',
630
- :criteria => 'between',
631
- :minimum => 1,
632
- :maximum => 10
633
- })
628
+ {
629
+ :validate => 'integer',
630
+ :criteria => 'between',
631
+ :minimum => 1,
632
+ :maximum => 10
633
+ })
634
634
 
635
635
 
636
636
  #
@@ -641,12 +641,12 @@ class TC_example_match < Test::Unit::TestCase
641
641
 
642
642
  worksheet.write(row, 0, txt)
643
643
  worksheet.data_validation(row, 1,
644
- {
645
- :validate => 'integer',
646
- :criteria => 'not between',
647
- :minimum => '=E3',
648
- :maximum => '=F3'
649
- })
644
+ {
645
+ :validate => 'integer',
646
+ :criteria => 'not between',
647
+ :minimum => '=E3',
648
+ :maximum => '=F3'
649
+ })
650
650
 
651
651
 
652
652
  #
@@ -657,11 +657,11 @@ class TC_example_match < Test::Unit::TestCase
657
657
 
658
658
  worksheet.write(row, 0, txt)
659
659
  worksheet.data_validation(row, 1,
660
- {
661
- :validate => 'integer',
662
- :criteria => '>',
663
- :value => 0
664
- })
660
+ {
661
+ :validate => 'integer',
662
+ :criteria => '>',
663
+ :value => 0
664
+ })
665
665
 
666
666
 
667
667
  #
@@ -672,11 +672,11 @@ class TC_example_match < Test::Unit::TestCase
672
672
 
673
673
  worksheet.write(row, 0, txt)
674
674
  worksheet.data_validation(row, 1,
675
- {
676
- :validate => 'integer',
677
- :criteria => '<',
678
- :value => 10
679
- })
675
+ {
676
+ :validate => 'integer',
677
+ :criteria => '<',
678
+ :value => 10
679
+ })
680
680
 
681
681
 
682
682
  #
@@ -687,12 +687,12 @@ class TC_example_match < Test::Unit::TestCase
687
687
 
688
688
  worksheet.write(row, 0, txt)
689
689
  worksheet.data_validation(row, 1,
690
- {
691
- :validate => 'decimal',
692
- :criteria => 'between',
693
- :minimum => 0.1,
694
- :maximum => 0.5
695
- })
690
+ {
691
+ :validate => 'decimal',
692
+ :criteria => 'between',
693
+ :minimum => 0.1,
694
+ :maximum => 0.5
695
+ })
696
696
 
697
697
 
698
698
  #
@@ -703,10 +703,10 @@ class TC_example_match < Test::Unit::TestCase
703
703
 
704
704
  worksheet.write(row, 0, txt)
705
705
  worksheet.data_validation(row, 1,
706
- {
707
- :validate => 'list',
708
- :source => ['open', 'high', 'close']
709
- })
706
+ {
707
+ :validate => 'list',
708
+ :source => ['open', 'high', 'close']
709
+ })
710
710
 
711
711
 
712
712
  #
@@ -717,10 +717,10 @@ class TC_example_match < Test::Unit::TestCase
717
717
 
718
718
  worksheet.write(row, 0, txt)
719
719
  worksheet.data_validation(row, 1,
720
- {
721
- :validate => 'list',
722
- :source => '=E4:G4'
723
- })
720
+ {
721
+ :validate => 'list',
722
+ :source => '=E4:G4'
723
+ })
724
724
 
725
725
 
726
726
  #
@@ -731,12 +731,12 @@ class TC_example_match < Test::Unit::TestCase
731
731
 
732
732
  worksheet.write(row, 0, txt)
733
733
  worksheet.data_validation(row, 1,
734
- {
735
- :validate => 'date',
736
- :criteria => 'between',
737
- :minimum => '2008-01-01T',
738
- :maximum => '2008-12-12T'
739
- })
734
+ {
735
+ :validate => 'date',
736
+ :criteria => 'between',
737
+ :minimum => '2008-01-01T',
738
+ :maximum => '2008-12-12T'
739
+ })
740
740
 
741
741
 
742
742
  #
@@ -747,12 +747,12 @@ class TC_example_match < Test::Unit::TestCase
747
747
 
748
748
  worksheet.write(row, 0, txt)
749
749
  worksheet.data_validation(row, 1,
750
- {
751
- :validate => 'time',
752
- :criteria => 'between',
753
- :minimum => 'T06:00',
754
- :maximum => 'T12:00'
755
- })
750
+ {
751
+ :validate => 'time',
752
+ :criteria => 'between',
753
+ :minimum => 'T06:00',
754
+ :maximum => 'T12:00'
755
+ })
756
756
 
757
757
 
758
758
  #
@@ -763,11 +763,11 @@ class TC_example_match < Test::Unit::TestCase
763
763
 
764
764
  worksheet.write(row, 0, txt)
765
765
  worksheet.data_validation(row, 1,
766
- {
767
- :validate => 'length',
768
- :criteria => '>',
769
- :value => 3
770
- })
766
+ {
767
+ :validate => 'length',
768
+ :criteria => '>',
769
+ :value => 3
770
+ })
771
771
 
772
772
 
773
773
  #
@@ -778,10 +778,10 @@ class TC_example_match < Test::Unit::TestCase
778
778
 
779
779
  worksheet.write(row, 0, txt)
780
780
  worksheet.data_validation(row, 1,
781
- {
782
- :validate => 'custom',
783
- :value => '=AND(F5=50,G5=60)'
784
- })
781
+ {
782
+ :validate => 'custom',
783
+ :value => '=AND(F5=50,G5=60)'
784
+ })
785
785
 
786
786
 
787
787
  #
@@ -792,14 +792,14 @@ class TC_example_match < Test::Unit::TestCase
792
792
 
793
793
  worksheet.write(row, 0, txt)
794
794
  worksheet.data_validation(row, 1,
795
- {
796
- :validate => 'integer',
797
- :criteria => 'between',
798
- :minimum => 1,
799
- :maximum => 100,
800
- :input_title => 'Enter an integer:',
801
- :input_message => 'between 1 and 100'
802
- })
795
+ {
796
+ :validate => 'integer',
797
+ :criteria => 'between',
798
+ :minimum => 1,
799
+ :maximum => 100,
800
+ :input_title => 'Enter an integer:',
801
+ :input_message => 'between 1 and 100'
802
+ })
803
803
 
804
804
 
805
805
  #
@@ -810,16 +810,16 @@ class TC_example_match < Test::Unit::TestCase
810
810
 
811
811
  worksheet.write(row, 0, txt)
812
812
  worksheet.data_validation(row, 1,
813
- {
814
- :validate => 'integer',
815
- :criteria => 'between',
816
- :minimum => 1,
817
- :maximum => 100,
818
- :input_title => 'Enter an integer:',
819
- :input_message => 'between 1 and 100',
820
- :error_title => 'Input value is not valid!',
821
- :error_message => 'It should be an integer between 1 and 100'
822
- })
813
+ {
814
+ :validate => 'integer',
815
+ :criteria => 'between',
816
+ :minimum => 1,
817
+ :maximum => 100,
818
+ :input_title => 'Enter an integer:',
819
+ :input_message => 'between 1 and 100',
820
+ :error_title => 'Input value is not valid!',
821
+ :error_message => 'It should be an integer between 1 and 100'
822
+ })
823
823
 
824
824
 
825
825
  #
@@ -830,17 +830,17 @@ class TC_example_match < Test::Unit::TestCase
830
830
 
831
831
  worksheet.write(row, 0, txt)
832
832
  worksheet.data_validation(row, 1,
833
- {
834
- :validate => 'integer',
835
- :criteria => 'between',
836
- :minimum => 1,
837
- :maximum => 100,
838
- :input_title => 'Enter an integer:',
839
- :input_message => 'between 1 and 100',
840
- :error_title => 'Input value is not valid!',
841
- :error_message => 'It should be an integer between 1 and 100',
842
- :error_type => 'information'
843
- })
833
+ {
834
+ :validate => 'integer',
835
+ :criteria => 'between',
836
+ :minimum => 1,
837
+ :maximum => 100,
838
+ :input_title => 'Enter an integer:',
839
+ :input_message => 'between 1 and 100',
840
+ :error_title => 'Input value is not valid!',
841
+ :error_message => 'It should be an integer between 1 and 100',
842
+ :error_type => 'information'
843
+ })
844
844
 
845
845
  workbook.close
846
846
 
@@ -880,16 +880,16 @@ class TC_example_match < Test::Unit::TestCase
880
880
 
881
881
  # Create a merged format
882
882
  format = workbook.add_format(
883
- :center_across => 1,
884
- :bold => 1,
885
- :size => 15,
886
- :pattern => 1,
887
- :border => 6,
888
- :color => 'white',
889
- :fg_color => 'green',
890
- :border_color => 'yellow',
891
- :align => 'vcenter'
892
- )
883
+ :center_across => 1,
884
+ :bold => 1,
885
+ :size => 15,
886
+ :pattern => 1,
887
+ :border => 6,
888
+ :color => 'white',
889
+ :fg_color => 'green',
890
+ :border_color => 'yellow',
891
+ :align => 'vcenter'
892
+ )
893
893
 
894
894
  # Only one cell should contain text, the others should be blank.
895
895
  worksheet.write(2, 1, "Center across selection", format)
@@ -914,11 +914,11 @@ class TC_example_match < Test::Unit::TestCase
914
914
  # and the standard Excel 5+ merge property.
915
915
  #
916
916
  format1 = workbook.add_format(
917
- :center_across => 1,
918
- :border => 1,
919
- :underline => 1,
920
- :color => 'blue'
921
- )
917
+ :center_across => 1,
918
+ :border => 1,
919
+ :underline => 1,
920
+ :color => 'blue'
921
+ )
922
922
 
923
923
  # Write the cells to be merged
924
924
  worksheet.write_url_range('B2:D2', 'http://www.perl.com', format1)
@@ -932,12 +932,12 @@ class TC_example_match < Test::Unit::TestCase
932
932
  # Example 2: Merge cells containing a hyperlink using merge_range().
933
933
  #
934
934
  format2 = workbook.add_format(
935
- :border => 1,
936
- :underline => 1,
937
- :color => 'blue',
938
- :align => 'center',
939
- :valign => 'vcenter'
940
- )
935
+ :border => 1,
936
+ :underline => 1,
937
+ :color => 'blue',
938
+ :align => 'center',
939
+ :valign => 'vcenter'
940
+ )
941
941
 
942
942
  # Merge 3 cells
943
943
  worksheet.merge_range('B4:D4', 'http://www.perl.com', format2)
@@ -966,12 +966,12 @@ class TC_example_match < Test::Unit::TestCase
966
966
  # Example 1: Text centered vertically and horizontally
967
967
  #
968
968
  format1 = workbook.add_format(
969
- :border => 6,
970
- :bold => 1,
971
- :color => 'red',
972
- :valign => 'vcenter',
973
- :align => 'center'
974
- )
969
+ :border => 6,
970
+ :bold => 1,
971
+ :color => 'red',
972
+ :valign => 'vcenter',
973
+ :align => 'center'
974
+ )
975
975
 
976
976
  worksheet.merge_range('B2:D3', 'Vertical and horizontal', format1)
977
977
 
@@ -981,12 +981,12 @@ class TC_example_match < Test::Unit::TestCase
981
981
  # Example 2: Text aligned to the top and left
982
982
  #
983
983
  format2 = workbook.add_format(
984
- :border => 6,
985
- :bold => 1,
986
- :color => 'red',
987
- :valign => 'top',
988
- :align => 'left'
989
- )
984
+ :border => 6,
985
+ :bold => 1,
986
+ :color => 'red',
987
+ :valign => 'top',
988
+ :align => 'left'
989
+ )
990
990
 
991
991
  worksheet.merge_range('B5:D6', 'Aligned to the top and left', format2)
992
992
 
@@ -995,12 +995,12 @@ class TC_example_match < Test::Unit::TestCase
995
995
  # Example 3: Text aligned to the bottom and right
996
996
  #
997
997
  format3 = workbook.add_format(
998
- :border => 6,
999
- :bold => 1,
1000
- :color => 'red',
1001
- :valign => 'bottom',
1002
- :align => 'right'
1003
- )
998
+ :border => 6,
999
+ :bold => 1,
1000
+ :color => 'red',
1001
+ :valign => 'bottom',
1002
+ :align => 'right'
1003
+ )
1004
1004
 
1005
1005
  worksheet.merge_range('B8:D9', 'Aligned to the bottom and right', format3)
1006
1006
 
@@ -1009,12 +1009,12 @@ class TC_example_match < Test::Unit::TestCase
1009
1009
  # Example 4: Text justified (i.e. wrapped) in the cell
1010
1010
  #
1011
1011
  format4 = workbook.add_format(
1012
- :border => 6,
1013
- :bold => 1,
1014
- :color => 'red',
1015
- :valign => 'top',
1016
- :align => 'justify'
1017
- )
1012
+ :border => 6,
1013
+ :bold => 1,
1014
+ :color => 'red',
1015
+ :valign => 'top',
1016
+ :align => 'justify'
1017
+ )
1018
1018
 
1019
1019
  worksheet.merge_range('B11:D12', 'Justified: '+'so on and '*18, format4)
1020
1020
 
@@ -1040,13 +1040,13 @@ class TC_example_match < Test::Unit::TestCase
1040
1040
  # Rotation 1, letters run from top to bottom
1041
1041
  #
1042
1042
  format1 = workbook.add_format(
1043
- :border => 6,
1044
- :bold => 1,
1045
- :color => 'red',
1046
- :valign => 'vcentre',
1047
- :align => 'centre',
1048
- :rotation => 270
1049
- )
1043
+ :border => 6,
1044
+ :bold => 1,
1045
+ :color => 'red',
1046
+ :valign => 'vcentre',
1047
+ :align => 'centre',
1048
+ :rotation => 270
1049
+ )
1050
1050
 
1051
1051
 
1052
1052
  worksheet.merge_range('B4:B9', 'Rotation 270', format1)
@@ -1057,13 +1057,13 @@ class TC_example_match < Test::Unit::TestCase
1057
1057
  # Rotation 2, 90° anticlockwise
1058
1058
  #
1059
1059
  format2 = workbook.add_format(
1060
- :border => 6,
1061
- :bold => 1,
1062
- :color => 'red',
1063
- :valign => 'vcentre',
1064
- :align => 'centre',
1065
- :rotation => 90
1066
- )
1060
+ :border => 6,
1061
+ :bold => 1,
1062
+ :color => 'red',
1063
+ :valign => 'vcentre',
1064
+ :align => 'centre',
1065
+ :rotation => 90
1066
+ )
1067
1067
 
1068
1068
 
1069
1069
  worksheet.merge_range('D4:D9', 'Rotation 90', format2)
@@ -1075,13 +1075,13 @@ class TC_example_match < Test::Unit::TestCase
1075
1075
  # Rotation 3, 90° clockwise
1076
1076
  #
1077
1077
  format3 = workbook.add_format(
1078
- :border => 6,
1079
- :bold => 1,
1080
- :color => 'red',
1081
- :valign => 'vcentre',
1082
- :align => 'centre',
1083
- :rotation => -90
1084
- )
1078
+ :border => 6,
1079
+ :bold => 1,
1080
+ :color => 'red',
1081
+ :valign => 'vcentre',
1082
+ :align => 'centre',
1083
+ :rotation => -90
1084
+ )
1085
1085
 
1086
1086
 
1087
1087
  worksheet.merge_range('F4:F9', 'Rotation -90', format3)
@@ -1103,14 +1103,14 @@ class TC_example_match < Test::Unit::TestCase
1103
1103
 
1104
1104
  # Format for the merged cells.
1105
1105
  format = workbook.add_format(
1106
- :border => 6,
1107
- :bold => 1,
1108
- :color => 'red',
1109
- :size => 20,
1110
- :valign => 'vcentre',
1111
- :align => 'left',
1112
- :indent => 1
1113
- )
1106
+ :border => 6,
1107
+ :bold => 1,
1108
+ :color => 'red',
1109
+ :size => 20,
1110
+ :valign => 'vcentre',
1111
+ :align => 'left',
1112
+ :indent => 1
1113
+ )
1114
1114
 
1115
1115
  ###############################################################################
1116
1116
  #
@@ -1192,7 +1192,7 @@ class TC_example_match < Test::Unit::TestCase
1192
1192
  def test_tab_colors
1193
1193
  workbook = WriteExcel.new(@file)
1194
1194
 
1195
- worksheet1 = workbook.add_worksheet
1195
+ workbook.add_worksheet
1196
1196
  worksheet2 = workbook.add_worksheet
1197
1197
  worksheet3 = workbook.add_worksheet
1198
1198
  worksheet4 = workbook.add_worksheet
@@ -1363,31 +1363,31 @@ class TC_example_match < Test::Unit::TestCase
1363
1363
  # the format codes change the appearance of the date.
1364
1364
  #
1365
1365
  date_formats = [
1366
- 'dd/mm/yy',
1367
- 'mm/dd/yy',
1368
- '',
1369
- 'd mm yy',
1370
- 'dd mm yy',
1371
- '',
1372
- 'dd m yy',
1373
- 'dd mm yy',
1374
- 'dd mmm yy',
1375
- 'dd mmmm yy',
1376
- '',
1377
- 'dd mm y',
1378
- 'dd mm yyy',
1379
- 'dd mm yyyy',
1380
- '',
1381
- 'd mmmm yyyy',
1382
- '',
1383
- 'dd/mm/yy',
1384
- 'dd/mm/yy hh:mm',
1385
- 'dd/mm/yy hh:mm:ss',
1386
- 'dd/mm/yy hh:mm:ss.000',
1387
- '',
1388
- 'hh:mm',
1389
- 'hh:mm:ss',
1390
- 'hh:mm:ss.000',
1366
+ 'dd/mm/yy',
1367
+ 'mm/dd/yy',
1368
+ '',
1369
+ 'd mm yy',
1370
+ 'dd mm yy',
1371
+ '',
1372
+ 'dd m yy',
1373
+ 'dd mm yy',
1374
+ 'dd mmm yy',
1375
+ 'dd mmmm yy',
1376
+ '',
1377
+ 'dd mm y',
1378
+ 'dd mm yyy',
1379
+ 'dd mm yyyy',
1380
+ '',
1381
+ 'd mmmm yyyy',
1382
+ '',
1383
+ 'dd/mm/yy',
1384
+ 'dd/mm/yy hh:mm',
1385
+ 'dd/mm/yy hh:mm:ss',
1386
+ 'dd/mm/yy hh:mm:ss.000',
1387
+ '',
1388
+ 'hh:mm',
1389
+ 'hh:mm:ss',
1390
+ 'hh:mm:ss.000',
1391
1391
  ]
1392
1392
 
1393
1393
  # Write the same date and time using each of the above formats. The empty
@@ -1400,9 +1400,9 @@ class TC_example_match < Test::Unit::TestCase
1400
1400
 
1401
1401
  # Create a format for the date or time.
1402
1402
  format = workbook.add_format(
1403
- :num_format => date_format,
1404
- :align => 'left'
1405
- )
1403
+ :num_format => date_format,
1404
+ :align => 'left'
1405
+ )
1406
1406
 
1407
1407
  # Write the same date using different formats.
1408
1408
  worksheet.write_date_time(row, 0, '2004-08-01T12:30:45.123', format)
@@ -1430,10 +1430,10 @@ class TC_example_match < Test::Unit::TestCase
1430
1430
  format2 = workbook.add_format(:diag_type => 2)
1431
1431
  format3 = workbook.add_format(:diag_type => 3)
1432
1432
  format4 = workbook.add_format(
1433
- :diag_type => 3,
1434
- :diag_border => 7,
1435
- :diag_color => 'red'
1436
- )
1433
+ :diag_type => 3,
1434
+ :diag_border => 7,
1435
+ :diag_color => 'red'
1436
+ )
1437
1437
 
1438
1438
  worksheet.write('B3', 'Text', format1)
1439
1439
  worksheet.write('B6', 'Text', format2)
@@ -1476,11 +1476,11 @@ class TC_example_match < Test::Unit::TestCase
1476
1476
  worksheet2 = workbook.add_worksheet('Variables')
1477
1477
 
1478
1478
  header2 = '&LPage &P of &N'+
1479
- '&CFilename: &F' +
1480
- '&RSheetname: &A'
1479
+ '&CFilename: &F' +
1480
+ '&RSheetname: &A'
1481
1481
 
1482
1482
  footer2 = '&LCurrent date: &D'+
1483
- '&RCurrent time: &T'
1483
+ '&RCurrent time: &T'
1484
1484
 
1485
1485
  worksheet2.set_header(header2)
1486
1486
  worksheet2.set_footer(footer2)
@@ -1499,12 +1499,12 @@ class TC_example_match < Test::Unit::TestCase
1499
1499
  worksheet3 = workbook.add_worksheet('Mixed fonts')
1500
1500
 
1501
1501
  header3 = '&C' +
1502
- '&"Courier New,Bold"Hello ' +
1503
- '&"Arial,Italic"World'
1502
+ '&"Courier New,Bold"Hello ' +
1503
+ '&"Arial,Italic"World'
1504
1504
 
1505
1505
  footer3 = '&C' +
1506
- '&"Symbol"e' +
1507
- '&"Arial" = mc&X2'
1506
+ '&"Symbol"e' +
1507
+ '&"Arial" = mc&X2'
1508
1508
 
1509
1509
  worksheet3.set_header(header3)
1510
1510
  worksheet3.set_footer(footer3)
@@ -1548,106 +1548,106 @@ class TC_example_match < Test::Unit::TestCase
1548
1548
 
1549
1549
  def test_demo
1550
1550
  workbook = WriteExcel.new(@file)
1551
- worksheet = workbook.add_worksheet('Demo')
1552
- worksheet2 = workbook.add_worksheet('Another sheet')
1553
- worksheet3 = workbook.add_worksheet('And another')
1554
-
1555
- bold = workbook.add_format(:bold => 1)
1556
-
1557
- #######################################################################
1558
- #
1559
- # Write a general heading
1560
- #
1561
- worksheet.set_column('A:A', 36, bold)
1562
- worksheet.set_column('B:B', 20 )
1563
- worksheet.set_row(0, 40 )
1564
-
1565
- heading = workbook.add_format(
1566
- :bold => 1,
1567
- :color => 'blue',
1568
- :size => 16,
1569
- :merge => 1,
1570
- :align => 'vcenter'
1571
- )
1572
-
1573
- headings = ['Features of Spreadsheet::WriteExcel', '']
1574
- worksheet.write_row('A1', headings, heading)
1575
-
1576
-
1577
- #######################################################################
1578
- #
1579
- # Some text examples
1580
- #
1581
- text_format = workbook.add_format(
1582
- :bold => 1,
1583
- :italic => 1,
1584
- :color => 'red',
1585
- :size => 18,
1586
- :font =>'Lucida Calligraphy'
1587
- )
1588
-
1589
- # A phrase in Cyrillic
1590
- unicode = [
1591
- "042d0442043e002004440440043004370430002004"+
1592
- "3d043000200440044304410441043a043e043c0021"
1593
- ].pack('H*')
1594
-
1595
- worksheet.write('A2', "Text")
1596
- worksheet.write('B2', "Hello Excel")
1597
- worksheet.write('A3', "Formatted text")
1598
- worksheet.write('B3', "Hello Excel", text_format)
1599
- worksheet.write('A4', "Unicode text")
1600
- worksheet.write_utf16be_string('B4', unicode)
1601
-
1602
-
1603
- #######################################################################
1604
- #
1605
- # Some numeric examples
1606
- #
1607
- num1_format = workbook.add_format(:num_format => '$#,##0.00')
1608
- num2_format = workbook.add_format(:num_format => ' d mmmm yyy')
1609
-
1610
- worksheet.write('A5', "Numbers")
1611
- worksheet.write('B5', 1234.56)
1612
- worksheet.write('A6', "Formatted numbers")
1613
- worksheet.write('B6', 1234.56, num1_format)
1614
- worksheet.write('A7', "Formatted numbers")
1615
- worksheet.write('B7', 37257, num2_format)
1616
-
1617
-
1618
- #######################################################################
1619
- #
1620
- # Formulae
1621
- #
1622
- worksheet.set_selection('B8')
1623
- worksheet.write('A8', 'Formulas and functions, "=SIN(PI()/4)"')
1624
- worksheet.write('B8', '=SIN(PI()/4)')
1625
-
1626
-
1627
- #######################################################################
1628
- #
1629
- # Hyperlinks
1630
- #
1631
- worksheet.write('A9', "Hyperlinks")
1632
- worksheet.write('B9', 'http://www.perl.com/' )
1633
-
1634
-
1635
- #######################################################################
1636
- #
1637
- # Images
1638
- #
1639
- worksheet.write('A10', "Images")
1640
- worksheet.insert_image('B10', "#{TEST_DIR}/republic.png", 16, 8)
1641
-
1642
-
1643
- #######################################################################
1644
- #
1645
- # Misc
1646
- #
1647
- worksheet.write('A18', "Page/printer setup")
1648
- worksheet.write('A19', "Multiple worksheets")
1649
-
1650
- workbook.close
1551
+ worksheet = workbook.add_worksheet('Demo')
1552
+ workbook.add_worksheet('Another sheet')
1553
+ workbook.add_worksheet('And another')
1554
+
1555
+ bold = workbook.add_format(:bold => 1)
1556
+
1557
+ #######################################################################
1558
+ #
1559
+ # Write a general heading
1560
+ #
1561
+ worksheet.set_column('A:A', 36, bold)
1562
+ worksheet.set_column('B:B', 20 )
1563
+ worksheet.set_row(0, 40 )
1564
+
1565
+ heading = workbook.add_format(
1566
+ :bold => 1,
1567
+ :color => 'blue',
1568
+ :size => 16,
1569
+ :merge => 1,
1570
+ :align => 'vcenter'
1571
+ )
1572
+
1573
+ headings = ['Features of Spreadsheet::WriteExcel', '']
1574
+ worksheet.write_row('A1', headings, heading)
1575
+
1576
+
1577
+ #######################################################################
1578
+ #
1579
+ # Some text examples
1580
+ #
1581
+ text_format = workbook.add_format(
1582
+ :bold => 1,
1583
+ :italic => 1,
1584
+ :color => 'red',
1585
+ :size => 18,
1586
+ :font =>'Lucida Calligraphy'
1587
+ )
1588
+
1589
+ # A phrase in Cyrillic
1590
+ unicode = [
1591
+ "042d0442043e002004440440043004370430002004"+
1592
+ "3d043000200440044304410441043a043e043c0021"
1593
+ ].pack('H*')
1594
+
1595
+ worksheet.write('A2', "Text")
1596
+ worksheet.write('B2', "Hello Excel")
1597
+ worksheet.write('A3', "Formatted text")
1598
+ worksheet.write('B3', "Hello Excel", text_format)
1599
+ worksheet.write('A4', "Unicode text")
1600
+ worksheet.write_utf16be_string('B4', unicode)
1601
+
1602
+
1603
+ #######################################################################
1604
+ #
1605
+ # Some numeric examples
1606
+ #
1607
+ num1_format = workbook.add_format(:num_format => '$#,##0.00')
1608
+ num2_format = workbook.add_format(:num_format => ' d mmmm yyy')
1609
+
1610
+ worksheet.write('A5', "Numbers")
1611
+ worksheet.write('B5', 1234.56)
1612
+ worksheet.write('A6', "Formatted numbers")
1613
+ worksheet.write('B6', 1234.56, num1_format)
1614
+ worksheet.write('A7', "Formatted numbers")
1615
+ worksheet.write('B7', 37257, num2_format)
1616
+
1617
+
1618
+ #######################################################################
1619
+ #
1620
+ # Formulae
1621
+ #
1622
+ worksheet.set_selection('B8')
1623
+ worksheet.write('A8', 'Formulas and functions, "=SIN(PI()/4)"')
1624
+ worksheet.write('B8', '=SIN(PI()/4)')
1625
+
1626
+
1627
+ #######################################################################
1628
+ #
1629
+ # Hyperlinks
1630
+ #
1631
+ worksheet.write('A9', "Hyperlinks")
1632
+ worksheet.write('B9', 'http://www.perl.com/' )
1633
+
1634
+
1635
+ #######################################################################
1636
+ #
1637
+ # Images
1638
+ #
1639
+ worksheet.write('A10', "Images")
1640
+ worksheet.insert_image('B10', "#{TEST_DIR}/republic.png", 16, 8)
1641
+
1642
+
1643
+ #######################################################################
1644
+ #
1645
+ # Misc
1646
+ #
1647
+ worksheet.write('A18', "Page/printer setup")
1648
+ worksheet.write('A19', "Multiple worksheets")
1649
+
1650
+ workbook.close
1651
1651
 
1652
1652
  # do assertion
1653
1653
  compare_file("#{PERL_OUTDIR}/demo.xls", @file)
@@ -1656,12 +1656,12 @@ workbook.close
1656
1656
  def test_unicode_cyrillic
1657
1657
  # Create a Russian worksheet name in utf8.
1658
1658
  sheet = [0x0421, 0x0442, 0x0440, 0x0430, 0x043D, 0x0438,
1659
- 0x0446, 0x0430].pack("U*")
1659
+ 0x0446, 0x0430].pack("U*")
1660
1660
 
1661
1661
  # Create a Russian string.
1662
1662
  str = [0x0417, 0x0434, 0x0440, 0x0430, 0x0432, 0x0441,
1663
- 0x0442, 0x0432, 0x0443, 0x0439, 0x0020, 0x041C,
1664
- 0x0438, 0x0440, 0x0021].pack("U*")
1663
+ 0x0442, 0x0432, 0x0443, 0x0439, 0x0020, 0x041C,
1664
+ 0x0438, 0x0440, 0x0021].pack("U*")
1665
1665
 
1666
1666
  workbook = WriteExcel.new(@file)
1667
1667
  worksheet = workbook.add_worksheet(sheet + '1')
@@ -1678,7 +1678,7 @@ workbook.close
1678
1678
  def test_defined_name
1679
1679
  workbook = WriteExcel.new(@file)
1680
1680
  worksheet1 = workbook.add_worksheet
1681
- worksheet2 = workbook.add_worksheet
1681
+ workbook.add_worksheet
1682
1682
 
1683
1683
  workbook.define_name('Exchange_rate', '=0.96')
1684
1684
  workbook.define_name('Sales', '=Sheet1!$G$1:$H$10')
@@ -1699,444 +1699,444 @@ workbook.close
1699
1699
  end
1700
1700
 
1701
1701
  def test_chart_area
1702
- workbook = WriteExcel.new(@file)
1703
- worksheet = workbook.add_worksheet
1704
- bold = workbook.add_format(:bold => 1)
1705
-
1706
- # Add the data to the worksheet that the charts will refer to.
1707
- headings = [ 'Category', 'Values 1', 'Values 2' ]
1708
- data = [
1709
- [ 2, 3, 4, 5, 6, 7 ],
1710
- [ 1, 4, 5, 2, 1, 5 ],
1711
- [ 3, 6, 7, 5, 4, 3 ]
1712
- ]
1713
-
1714
- worksheet.write('A1', headings, bold)
1715
- worksheet.write('A2', data)
1716
-
1717
-
1718
- ###############################################################################
1719
- #
1720
- # Example 1. A minimal chart.
1721
- #
1722
- chart1 = workbook.add_chart(:type => 'Chart::Area')
1723
-
1724
- # Add values only. Use the default categories.
1725
- chart1.add_series( :values => '=Sheet1!$B$2:$B$7' )
1726
-
1727
- ###############################################################################
1728
- #
1729
- # Example 2. A minimal chart with user specified categories (X axis)
1730
- # and a series name.
1731
- #
1732
- chart2 = workbook.add_chart(:type => 'Chart::Area')
1733
-
1734
- # Configure the series.
1735
- chart2.add_series(
1736
- :categories => '=Sheet1!$A$2:$A$7',
1737
- :values => '=Sheet1!$B$2:$B$7',
1738
- :name => 'Test data series 1'
1739
- )
1740
-
1741
- ###############################################################################
1742
- #
1743
- # Example 3. Same as previous chart but with added title and axes labels.
1744
- #
1745
- chart3 = workbook.add_chart(:type => 'Chart::Area')
1746
-
1747
- # Configure the series.
1748
- chart3.add_series(
1749
- :categories => '=Sheet1!$A$2:$A$7',
1750
- :values => '=Sheet1!$B$2:$B$7',
1751
- :name => 'Test data series 1'
1752
- )
1753
-
1754
- # Add some labels.
1755
- chart3.set_title( :name => 'Results of sample analysis' )
1756
- chart3.set_x_axis( :name => 'Sample number' )
1757
- chart3.set_y_axis( :name => 'Sample length (cm)' )
1758
-
1759
- ###############################################################################
1760
- #
1761
- # Example 4. Same as previous chart but with an added series
1762
- #
1763
- chart4 = workbook.add_chart(:name => 'Results Chart', :type => 'Chart::Area')
1764
-
1765
- # Configure the series.
1766
- chart4.add_series(
1767
- :categories => '=Sheet1!$A$2:$A$7',
1768
- :values => '=Sheet1!$B$2:$B$7',
1769
- :name => 'Test data series 1'
1770
- )
1771
-
1772
- # Add another series.
1773
- chart4.add_series(
1774
- :categories => '=Sheet1!$A$2:$A$7',
1775
- :values => '=Sheet1!$C$2:$C$7',
1776
- :name => 'Test data series 2'
1777
- )
1778
-
1779
- # Add some labels.
1780
- chart4.set_title( :name => 'Results of sample analysis' )
1781
- chart4.set_x_axis( :name => 'Sample number' )
1782
- chart4.set_y_axis( :name => 'Sample length (cm)' )
1783
-
1784
- ###############################################################################
1785
- #
1786
- # Example 5. Same as Example 3 but as an embedded chart.
1787
- #
1788
- chart5 = workbook.add_chart(:type => 'Chart::Area', :embedded => 1)
1789
-
1790
- # Configure the series.
1791
- chart5.add_series(
1792
- :categories => '=Sheet1!$A$2:$A$7',
1793
- :values => '=Sheet1!$B$2:$B$7',
1794
- :name => 'Test data series 1'
1795
- )
1796
-
1797
- # Add some labels.
1798
- chart5.set_title(:name => 'Results of sample analysis' )
1799
- chart5.set_x_axis(:name => 'Sample number')
1800
- chart5.set_y_axis(:name => 'Sample length (cm)')
1801
-
1802
- # Insert the chart into the main worksheet.
1803
- worksheet.insert_chart('E2', chart5)
1804
-
1805
- # File save
1806
- workbook.close
1702
+ workbook = WriteExcel.new(@file)
1703
+ worksheet = workbook.add_worksheet
1704
+ bold = workbook.add_format(:bold => 1)
1705
+
1706
+ # Add the data to the worksheet that the charts will refer to.
1707
+ headings = [ 'Category', 'Values 1', 'Values 2' ]
1708
+ data = [
1709
+ [ 2, 3, 4, 5, 6, 7 ],
1710
+ [ 1, 4, 5, 2, 1, 5 ],
1711
+ [ 3, 6, 7, 5, 4, 3 ]
1712
+ ]
1713
+
1714
+ worksheet.write('A1', headings, bold)
1715
+ worksheet.write('A2', data)
1716
+
1717
+
1718
+ ###############################################################################
1719
+ #
1720
+ # Example 1. A minimal chart.
1721
+ #
1722
+ chart1 = workbook.add_chart(:type => 'Chart::Area')
1723
+
1724
+ # Add values only. Use the default categories.
1725
+ chart1.add_series( :values => '=Sheet1!$B$2:$B$7' )
1726
+
1727
+ ###############################################################################
1728
+ #
1729
+ # Example 2. A minimal chart with user specified categories (X axis)
1730
+ # and a series name.
1731
+ #
1732
+ chart2 = workbook.add_chart(:type => 'Chart::Area')
1733
+
1734
+ # Configure the series.
1735
+ chart2.add_series(
1736
+ :categories => '=Sheet1!$A$2:$A$7',
1737
+ :values => '=Sheet1!$B$2:$B$7',
1738
+ :name => 'Test data series 1'
1739
+ )
1740
+
1741
+ ###############################################################################
1742
+ #
1743
+ # Example 3. Same as previous chart but with added title and axes labels.
1744
+ #
1745
+ chart3 = workbook.add_chart(:type => 'Chart::Area')
1746
+
1747
+ # Configure the series.
1748
+ chart3.add_series(
1749
+ :categories => '=Sheet1!$A$2:$A$7',
1750
+ :values => '=Sheet1!$B$2:$B$7',
1751
+ :name => 'Test data series 1'
1752
+ )
1753
+
1754
+ # Add some labels.
1755
+ chart3.set_title( :name => 'Results of sample analysis' )
1756
+ chart3.set_x_axis( :name => 'Sample number' )
1757
+ chart3.set_y_axis( :name => 'Sample length (cm)' )
1758
+
1759
+ ###############################################################################
1760
+ #
1761
+ # Example 4. Same as previous chart but with an added series
1762
+ #
1763
+ chart4 = workbook.add_chart(:name => 'Results Chart', :type => 'Chart::Area')
1764
+
1765
+ # Configure the series.
1766
+ chart4.add_series(
1767
+ :categories => '=Sheet1!$A$2:$A$7',
1768
+ :values => '=Sheet1!$B$2:$B$7',
1769
+ :name => 'Test data series 1'
1770
+ )
1771
+
1772
+ # Add another series.
1773
+ chart4.add_series(
1774
+ :categories => '=Sheet1!$A$2:$A$7',
1775
+ :values => '=Sheet1!$C$2:$C$7',
1776
+ :name => 'Test data series 2'
1777
+ )
1778
+
1779
+ # Add some labels.
1780
+ chart4.set_title( :name => 'Results of sample analysis' )
1781
+ chart4.set_x_axis( :name => 'Sample number' )
1782
+ chart4.set_y_axis( :name => 'Sample length (cm)' )
1783
+
1784
+ ###############################################################################
1785
+ #
1786
+ # Example 5. Same as Example 3 but as an embedded chart.
1787
+ #
1788
+ chart5 = workbook.add_chart(:type => 'Chart::Area', :embedded => 1)
1789
+
1790
+ # Configure the series.
1791
+ chart5.add_series(
1792
+ :categories => '=Sheet1!$A$2:$A$7',
1793
+ :values => '=Sheet1!$B$2:$B$7',
1794
+ :name => 'Test data series 1'
1795
+ )
1796
+
1797
+ # Add some labels.
1798
+ chart5.set_title(:name => 'Results of sample analysis' )
1799
+ chart5.set_x_axis(:name => 'Sample number')
1800
+ chart5.set_y_axis(:name => 'Sample length (cm)')
1801
+
1802
+ # Insert the chart into the main worksheet.
1803
+ worksheet.insert_chart('E2', chart5)
1804
+
1805
+ # File save
1806
+ workbook.close
1807
1807
 
1808
1808
  # do assertion
1809
1809
  compare_file("#{PERL_OUTDIR}/chart_area.xls", @file)
1810
1810
  end
1811
1811
 
1812
1812
  def test_chart_bar
1813
- workbook = WriteExcel.new(@file)
1814
- worksheet = workbook.add_worksheet
1815
- bold = workbook.add_format(:bold => 1)
1816
-
1817
- # Add the data to the worksheet that the charts will refer to.
1818
- headings = [ 'Category', 'Values 1', 'Values 2' ]
1819
- data = [
1820
- [ 2, 3, 4, 5, 6, 7 ],
1821
- [ 1, 4, 5, 2, 1, 5 ],
1822
- [ 3, 6, 7, 5, 4, 3 ]
1823
- ]
1824
-
1825
- worksheet.write('A1', headings, bold)
1826
- worksheet.write('A2', data)
1827
-
1828
-
1829
- ###############################################################################
1830
- #
1831
- # Example 1. A minimal chart.
1832
- #
1833
- chart1 = workbook.add_chart(:type => 'Chart::Bar')
1834
-
1835
- # Add values only. Use the default categories.
1836
- chart1.add_series( :values => '=Sheet1!$B$2:$B$7' )
1837
-
1838
- ###############################################################################
1839
- #
1840
- # Example 2. A minimal chart with user specified categories (X axis)
1841
- # and a series name.
1842
- #
1843
- chart2 = workbook.add_chart(:type => 'Chart::Bar')
1844
-
1845
- # Configure the series.
1846
- chart2.add_series(
1847
- :categories => '=Sheet1!$A$2:$A$7',
1848
- :values => '=Sheet1!$B$2:$B$7',
1849
- :name => 'Test data series 1'
1850
- )
1851
-
1852
- ###############################################################################
1853
- #
1854
- # Example 3. Same as previous chart but with added title and axes labels.
1855
- #
1856
- chart3 = workbook.add_chart(:type => 'Chart::Bar')
1857
-
1858
- # Configure the series.
1859
- chart3.add_series(
1860
- :categories => '=Sheet1!$A$2:$A$7',
1861
- :values => '=Sheet1!$B$2:$B$7',
1862
- :name => 'Test data series 1'
1863
- )
1864
-
1865
- # Add some labels.
1866
- chart3.set_title( :name => 'Results of sample analysis' )
1867
- chart3.set_x_axis( :name => 'Sample number' )
1868
- chart3.set_y_axis( :name => 'Sample length (cm)' )
1869
-
1870
- ###############################################################################
1871
- #
1872
- # Example 4. Same as previous chart but with an added series
1873
- #
1874
- chart4 = workbook.add_chart(:name => 'Results Chart', :type => 'Chart::Bar')
1875
-
1876
- # Configure the series.
1877
- chart4.add_series(
1878
- :categories => '=Sheet1!$A$2:$A$7',
1879
- :values => '=Sheet1!$B$2:$B$7',
1880
- :name => 'Test data series 1'
1881
- )
1882
-
1883
- # Add another series.
1884
- chart4.add_series(
1885
- :categories => '=Sheet1!$A$2:$A$7',
1886
- :values => '=Sheet1!$C$2:$C$7',
1887
- :name => 'Test data series 2'
1888
- )
1889
-
1890
- # Add some labels.
1891
- chart4.set_title( :name => 'Results of sample analysis' )
1892
- chart4.set_x_axis( :name => 'Sample number' )
1893
- chart4.set_y_axis( :name => 'Sample length (cm)' )
1894
-
1895
- ###############################################################################
1896
- #
1897
- # Example 5. Same as Example 3 but as an embedded chart.
1898
- #
1899
- chart5 = workbook.add_chart(:type => 'Chart::Bar', :embedded => 1)
1900
-
1901
- # Configure the series.
1902
- chart5.add_series(
1903
- :categories => '=Sheet1!$A$2:$A$7',
1904
- :values => '=Sheet1!$B$2:$B$7',
1905
- :name => 'Test data series 1'
1906
- )
1907
-
1908
- # Add some labels.
1909
- chart5.set_title(:name => 'Results of sample analysis' )
1910
- chart5.set_x_axis(:name => 'Sample number')
1911
- chart5.set_y_axis(:name => 'Sample length (cm)')
1912
-
1913
- # Insert the chart into the main worksheet.
1914
- worksheet.insert_chart('E2', chart5)
1915
-
1916
- # File save
1917
- workbook.close
1813
+ workbook = WriteExcel.new(@file)
1814
+ worksheet = workbook.add_worksheet
1815
+ bold = workbook.add_format(:bold => 1)
1816
+
1817
+ # Add the data to the worksheet that the charts will refer to.
1818
+ headings = [ 'Category', 'Values 1', 'Values 2' ]
1819
+ data = [
1820
+ [ 2, 3, 4, 5, 6, 7 ],
1821
+ [ 1, 4, 5, 2, 1, 5 ],
1822
+ [ 3, 6, 7, 5, 4, 3 ]
1823
+ ]
1824
+
1825
+ worksheet.write('A1', headings, bold)
1826
+ worksheet.write('A2', data)
1827
+
1828
+
1829
+ ###############################################################################
1830
+ #
1831
+ # Example 1. A minimal chart.
1832
+ #
1833
+ chart1 = workbook.add_chart(:type => 'Chart::Bar')
1834
+
1835
+ # Add values only. Use the default categories.
1836
+ chart1.add_series( :values => '=Sheet1!$B$2:$B$7' )
1837
+
1838
+ ###############################################################################
1839
+ #
1840
+ # Example 2. A minimal chart with user specified categories (X axis)
1841
+ # and a series name.
1842
+ #
1843
+ chart2 = workbook.add_chart(:type => 'Chart::Bar')
1844
+
1845
+ # Configure the series.
1846
+ chart2.add_series(
1847
+ :categories => '=Sheet1!$A$2:$A$7',
1848
+ :values => '=Sheet1!$B$2:$B$7',
1849
+ :name => 'Test data series 1'
1850
+ )
1851
+
1852
+ ###############################################################################
1853
+ #
1854
+ # Example 3. Same as previous chart but with added title and axes labels.
1855
+ #
1856
+ chart3 = workbook.add_chart(:type => 'Chart::Bar')
1857
+
1858
+ # Configure the series.
1859
+ chart3.add_series(
1860
+ :categories => '=Sheet1!$A$2:$A$7',
1861
+ :values => '=Sheet1!$B$2:$B$7',
1862
+ :name => 'Test data series 1'
1863
+ )
1864
+
1865
+ # Add some labels.
1866
+ chart3.set_title( :name => 'Results of sample analysis' )
1867
+ chart3.set_x_axis( :name => 'Sample number' )
1868
+ chart3.set_y_axis( :name => 'Sample length (cm)' )
1869
+
1870
+ ###############################################################################
1871
+ #
1872
+ # Example 4. Same as previous chart but with an added series
1873
+ #
1874
+ chart4 = workbook.add_chart(:name => 'Results Chart', :type => 'Chart::Bar')
1875
+
1876
+ # Configure the series.
1877
+ chart4.add_series(
1878
+ :categories => '=Sheet1!$A$2:$A$7',
1879
+ :values => '=Sheet1!$B$2:$B$7',
1880
+ :name => 'Test data series 1'
1881
+ )
1882
+
1883
+ # Add another series.
1884
+ chart4.add_series(
1885
+ :categories => '=Sheet1!$A$2:$A$7',
1886
+ :values => '=Sheet1!$C$2:$C$7',
1887
+ :name => 'Test data series 2'
1888
+ )
1889
+
1890
+ # Add some labels.
1891
+ chart4.set_title( :name => 'Results of sample analysis' )
1892
+ chart4.set_x_axis( :name => 'Sample number' )
1893
+ chart4.set_y_axis( :name => 'Sample length (cm)' )
1894
+
1895
+ ###############################################################################
1896
+ #
1897
+ # Example 5. Same as Example 3 but as an embedded chart.
1898
+ #
1899
+ chart5 = workbook.add_chart(:type => 'Chart::Bar', :embedded => 1)
1900
+
1901
+ # Configure the series.
1902
+ chart5.add_series(
1903
+ :categories => '=Sheet1!$A$2:$A$7',
1904
+ :values => '=Sheet1!$B$2:$B$7',
1905
+ :name => 'Test data series 1'
1906
+ )
1907
+
1908
+ # Add some labels.
1909
+ chart5.set_title(:name => 'Results of sample analysis' )
1910
+ chart5.set_x_axis(:name => 'Sample number')
1911
+ chart5.set_y_axis(:name => 'Sample length (cm)')
1912
+
1913
+ # Insert the chart into the main worksheet.
1914
+ worksheet.insert_chart('E2', chart5)
1915
+
1916
+ # File save
1917
+ workbook.close
1918
1918
 
1919
1919
  # do assertion
1920
1920
  compare_file("#{PERL_OUTDIR}/chart_bar.xls", @file)
1921
1921
  end
1922
1922
 
1923
1923
  def test_chart_column
1924
- workbook = WriteExcel.new(@file)
1925
- worksheet = workbook.add_worksheet
1926
- bold = workbook.add_format(:bold => 1)
1927
-
1928
- # Add the data to the worksheet that the charts will refer to.
1929
- headings = [ 'Category', 'Values 1', 'Values 2' ]
1930
- data = [
1931
- [ 2, 3, 4, 5, 6, 7 ],
1932
- [ 1, 4, 5, 2, 1, 5 ],
1933
- [ 3, 6, 7, 5, 4, 3 ]
1934
- ]
1935
-
1936
- worksheet.write('A1', headings, bold)
1937
- worksheet.write('A2', data)
1938
-
1939
-
1940
- ###############################################################################
1941
- #
1942
- # Example 1. A minimal chart.
1943
- #
1944
- chart1 = workbook.add_chart(:type => 'Chart::Column')
1945
-
1946
- # Add values only. Use the default categories.
1947
- chart1.add_series( :values => '=Sheet1!$B$2:$B$7' )
1948
-
1949
- ###############################################################################
1950
- #
1951
- # Example 2. A minimal chart with user specified categories (X axis)
1952
- # and a series name.
1953
- #
1954
- chart2 = workbook.add_chart(:type => 'Chart::Column')
1955
-
1956
- # Configure the series.
1957
- chart2.add_series(
1958
- :categories => '=Sheet1!$A$2:$A$7',
1959
- :values => '=Sheet1!$B$2:$B$7',
1960
- :name => 'Test data series 1'
1961
- )
1962
-
1963
- ###############################################################################
1964
- #
1965
- # Example 3. Same as previous chart but with added title and axes labels.
1966
- #
1967
- chart3 = workbook.add_chart(:type => 'Chart::Column')
1968
-
1969
- # Configure the series.
1970
- chart3.add_series(
1971
- :categories => '=Sheet1!$A$2:$A$7',
1972
- :values => '=Sheet1!$B$2:$B$7',
1973
- :name => 'Test data series 1'
1974
- )
1975
-
1976
- # Add some labels.
1977
- chart3.set_title( :name => 'Results of sample analysis' )
1978
- chart3.set_x_axis( :name => 'Sample number' )
1979
- chart3.set_y_axis( :name => 'Sample length (cm)' )
1980
-
1981
- ###############################################################################
1982
- #
1983
- # Example 4. Same as previous chart but with an added series
1984
- #
1985
- chart4 = workbook.add_chart(:name => 'Results Chart', :type => 'Chart::Column')
1986
-
1987
- # Configure the series.
1988
- chart4.add_series(
1989
- :categories => '=Sheet1!$A$2:$A$7',
1990
- :values => '=Sheet1!$B$2:$B$7',
1991
- :name => 'Test data series 1'
1992
- )
1993
-
1994
- # Add another series.
1995
- chart4.add_series(
1996
- :categories => '=Sheet1!$A$2:$A$7',
1997
- :values => '=Sheet1!$C$2:$C$7',
1998
- :name => 'Test data series 2'
1999
- )
2000
-
2001
- # Add some labels.
2002
- chart4.set_title( :name => 'Results of sample analysis' )
2003
- chart4.set_x_axis( :name => 'Sample number' )
2004
- chart4.set_y_axis( :name => 'Sample length (cm)' )
2005
-
2006
- ###############################################################################
2007
- #
2008
- # Example 5. Same as Example 3 but as an embedded chart.
2009
- #
2010
- chart5 = workbook.add_chart(:type => 'Chart::Column', :embedded => 1)
2011
-
2012
- # Configure the series.
2013
- chart5.add_series(
2014
- :categories => '=Sheet1!$A$2:$A$7',
2015
- :values => '=Sheet1!$B$2:$B$7',
2016
- :name => 'Test data series 1'
2017
- )
2018
-
2019
- # Add some labels.
2020
- chart5.set_title(:name => 'Results of sample analysis' )
2021
- chart5.set_x_axis(:name => 'Sample number')
2022
- chart5.set_y_axis(:name => 'Sample length (cm)')
2023
-
2024
- # Insert the chart into the main worksheet.
2025
- worksheet.insert_chart('E2', chart5)
2026
-
2027
- # File save
2028
- workbook.close
1924
+ workbook = WriteExcel.new(@file)
1925
+ worksheet = workbook.add_worksheet
1926
+ bold = workbook.add_format(:bold => 1)
1927
+
1928
+ # Add the data to the worksheet that the charts will refer to.
1929
+ headings = [ 'Category', 'Values 1', 'Values 2' ]
1930
+ data = [
1931
+ [ 2, 3, 4, 5, 6, 7 ],
1932
+ [ 1, 4, 5, 2, 1, 5 ],
1933
+ [ 3, 6, 7, 5, 4, 3 ]
1934
+ ]
1935
+
1936
+ worksheet.write('A1', headings, bold)
1937
+ worksheet.write('A2', data)
1938
+
1939
+
1940
+ ###############################################################################
1941
+ #
1942
+ # Example 1. A minimal chart.
1943
+ #
1944
+ chart1 = workbook.add_chart(:type => 'Chart::Column')
1945
+
1946
+ # Add values only. Use the default categories.
1947
+ chart1.add_series( :values => '=Sheet1!$B$2:$B$7' )
1948
+
1949
+ ###############################################################################
1950
+ #
1951
+ # Example 2. A minimal chart with user specified categories (X axis)
1952
+ # and a series name.
1953
+ #
1954
+ chart2 = workbook.add_chart(:type => 'Chart::Column')
1955
+
1956
+ # Configure the series.
1957
+ chart2.add_series(
1958
+ :categories => '=Sheet1!$A$2:$A$7',
1959
+ :values => '=Sheet1!$B$2:$B$7',
1960
+ :name => 'Test data series 1'
1961
+ )
1962
+
1963
+ ###############################################################################
1964
+ #
1965
+ # Example 3. Same as previous chart but with added title and axes labels.
1966
+ #
1967
+ chart3 = workbook.add_chart(:type => 'Chart::Column')
1968
+
1969
+ # Configure the series.
1970
+ chart3.add_series(
1971
+ :categories => '=Sheet1!$A$2:$A$7',
1972
+ :values => '=Sheet1!$B$2:$B$7',
1973
+ :name => 'Test data series 1'
1974
+ )
1975
+
1976
+ # Add some labels.
1977
+ chart3.set_title( :name => 'Results of sample analysis' )
1978
+ chart3.set_x_axis( :name => 'Sample number' )
1979
+ chart3.set_y_axis( :name => 'Sample length (cm)' )
1980
+
1981
+ ###############################################################################
1982
+ #
1983
+ # Example 4. Same as previous chart but with an added series
1984
+ #
1985
+ chart4 = workbook.add_chart(:name => 'Results Chart', :type => 'Chart::Column')
1986
+
1987
+ # Configure the series.
1988
+ chart4.add_series(
1989
+ :categories => '=Sheet1!$A$2:$A$7',
1990
+ :values => '=Sheet1!$B$2:$B$7',
1991
+ :name => 'Test data series 1'
1992
+ )
1993
+
1994
+ # Add another series.
1995
+ chart4.add_series(
1996
+ :categories => '=Sheet1!$A$2:$A$7',
1997
+ :values => '=Sheet1!$C$2:$C$7',
1998
+ :name => 'Test data series 2'
1999
+ )
2000
+
2001
+ # Add some labels.
2002
+ chart4.set_title( :name => 'Results of sample analysis' )
2003
+ chart4.set_x_axis( :name => 'Sample number' )
2004
+ chart4.set_y_axis( :name => 'Sample length (cm)' )
2005
+
2006
+ ###############################################################################
2007
+ #
2008
+ # Example 5. Same as Example 3 but as an embedded chart.
2009
+ #
2010
+ chart5 = workbook.add_chart(:type => 'Chart::Column', :embedded => 1)
2011
+
2012
+ # Configure the series.
2013
+ chart5.add_series(
2014
+ :categories => '=Sheet1!$A$2:$A$7',
2015
+ :values => '=Sheet1!$B$2:$B$7',
2016
+ :name => 'Test data series 1'
2017
+ )
2018
+
2019
+ # Add some labels.
2020
+ chart5.set_title(:name => 'Results of sample analysis' )
2021
+ chart5.set_x_axis(:name => 'Sample number')
2022
+ chart5.set_y_axis(:name => 'Sample length (cm)')
2023
+
2024
+ # Insert the chart into the main worksheet.
2025
+ worksheet.insert_chart('E2', chart5)
2026
+
2027
+ # File save
2028
+ workbook.close
2029
2029
 
2030
2030
  # do assertion
2031
2031
  compare_file("#{PERL_OUTDIR}/chart_column.xls", @file)
2032
2032
  end
2033
2033
 
2034
2034
  def test_chart_line
2035
- workbook = WriteExcel.new(@file)
2036
- worksheet = workbook.add_worksheet
2037
- bold = workbook.add_format(:bold => 1)
2038
-
2039
- # Add the data to the worksheet that the charts will refer to.
2040
- headings = [ 'Category', 'Values 1', 'Values 2' ]
2041
- data = [
2042
- [ 2, 3, 4, 5, 6, 7 ],
2043
- [ 1, 4, 5, 2, 1, 5 ],
2044
- [ 3, 6, 7, 5, 4, 3 ]
2045
- ]
2046
-
2047
- worksheet.write('A1', headings, bold)
2048
- worksheet.write('A2', data)
2049
-
2050
-
2051
- ###############################################################################
2052
- #
2053
- # Example 1. A minimal chart.
2054
- #
2055
- chart1 = workbook.add_chart(:type => 'Chart::Line')
2056
-
2057
- # Add values only. Use the default categories.
2058
- chart1.add_series( :values => '=Sheet1!$B$2:$B$7' )
2059
-
2060
- ###############################################################################
2061
- #
2062
- # Example 2. A minimal chart with user specified categories (X axis)
2063
- # and a series name.
2064
- #
2065
- chart2 = workbook.add_chart(:type => 'Chart::Line')
2066
-
2067
- # Configure the series.
2068
- chart2.add_series(
2069
- :categories => '=Sheet1!$A$2:$A$7',
2070
- :values => '=Sheet1!$B$2:$B$7',
2071
- :name => 'Test data series 1'
2072
- )
2073
-
2074
- ###############################################################################
2075
- #
2076
- # Example 3. Same as previous chart but with added title and axes labels.
2077
- #
2078
- chart3 = workbook.add_chart(:type => 'Chart::Line')
2079
-
2080
- # Configure the series.
2081
- chart3.add_series(
2082
- :categories => '=Sheet1!$A$2:$A$7',
2083
- :values => '=Sheet1!$B$2:$B$7',
2084
- :name => 'Test data series 1'
2085
- )
2086
-
2087
- # Add some labels.
2088
- chart3.set_title( :name => 'Results of sample analysis' )
2089
- chart3.set_x_axis( :name => 'Sample number' )
2090
- chart3.set_y_axis( :name => 'Sample length (cm)' )
2091
-
2092
- ###############################################################################
2093
- #
2094
- # Example 4. Same as previous chart but with an added series
2095
- #
2096
- chart4 = workbook.add_chart(:name => 'Results Chart', :type => 'Chart::Line')
2097
-
2098
- # Configure the series.
2099
- chart4.add_series(
2100
- :categories => '=Sheet1!$A$2:$A$7',
2101
- :values => '=Sheet1!$B$2:$B$7',
2102
- :name => 'Test data series 1'
2103
- )
2104
-
2105
- # Add another series.
2106
- chart4.add_series(
2107
- :categories => '=Sheet1!$A$2:$A$7',
2108
- :values => '=Sheet1!$C$2:$C$7',
2109
- :name => 'Test data series 2'
2110
- )
2111
-
2112
- # Add some labels.
2113
- chart4.set_title( :name => 'Results of sample analysis' )
2114
- chart4.set_x_axis( :name => 'Sample number' )
2115
- chart4.set_y_axis( :name => 'Sample length (cm)' )
2116
-
2117
- ###############################################################################
2118
- #
2119
- # Example 5. Same as Example 3 but as an embedded chart.
2120
- #
2121
- chart5 = workbook.add_chart(:type => 'Chart::Line', :embedded => 1)
2122
-
2123
- # Configure the series.
2124
- chart5.add_series(
2125
- :categories => '=Sheet1!$A$2:$A$7',
2126
- :values => '=Sheet1!$B$2:$B$7',
2127
- :name => 'Test data series 1'
2128
- )
2129
-
2130
- # Add some labels.
2131
- chart5.set_title(:name => 'Results of sample analysis' )
2132
- chart5.set_x_axis(:name => 'Sample number')
2133
- chart5.set_y_axis(:name => 'Sample length (cm)')
2134
-
2135
- # Insert the chart into the main worksheet.
2136
- worksheet.insert_chart('E2', chart5)
2137
-
2138
- # File save
2139
- workbook.close
2035
+ workbook = WriteExcel.new(@file)
2036
+ worksheet = workbook.add_worksheet
2037
+ bold = workbook.add_format(:bold => 1)
2038
+
2039
+ # Add the data to the worksheet that the charts will refer to.
2040
+ headings = [ 'Category', 'Values 1', 'Values 2' ]
2041
+ data = [
2042
+ [ 2, 3, 4, 5, 6, 7 ],
2043
+ [ 1, 4, 5, 2, 1, 5 ],
2044
+ [ 3, 6, 7, 5, 4, 3 ]
2045
+ ]
2046
+
2047
+ worksheet.write('A1', headings, bold)
2048
+ worksheet.write('A2', data)
2049
+
2050
+
2051
+ ###############################################################################
2052
+ #
2053
+ # Example 1. A minimal chart.
2054
+ #
2055
+ chart1 = workbook.add_chart(:type => 'Chart::Line')
2056
+
2057
+ # Add values only. Use the default categories.
2058
+ chart1.add_series( :values => '=Sheet1!$B$2:$B$7' )
2059
+
2060
+ ###############################################################################
2061
+ #
2062
+ # Example 2. A minimal chart with user specified categories (X axis)
2063
+ # and a series name.
2064
+ #
2065
+ chart2 = workbook.add_chart(:type => 'Chart::Line')
2066
+
2067
+ # Configure the series.
2068
+ chart2.add_series(
2069
+ :categories => '=Sheet1!$A$2:$A$7',
2070
+ :values => '=Sheet1!$B$2:$B$7',
2071
+ :name => 'Test data series 1'
2072
+ )
2073
+
2074
+ ###############################################################################
2075
+ #
2076
+ # Example 3. Same as previous chart but with added title and axes labels.
2077
+ #
2078
+ chart3 = workbook.add_chart(:type => 'Chart::Line')
2079
+
2080
+ # Configure the series.
2081
+ chart3.add_series(
2082
+ :categories => '=Sheet1!$A$2:$A$7',
2083
+ :values => '=Sheet1!$B$2:$B$7',
2084
+ :name => 'Test data series 1'
2085
+ )
2086
+
2087
+ # Add some labels.
2088
+ chart3.set_title( :name => 'Results of sample analysis' )
2089
+ chart3.set_x_axis( :name => 'Sample number' )
2090
+ chart3.set_y_axis( :name => 'Sample length (cm)' )
2091
+
2092
+ ###############################################################################
2093
+ #
2094
+ # Example 4. Same as previous chart but with an added series
2095
+ #
2096
+ chart4 = workbook.add_chart(:name => 'Results Chart', :type => 'Chart::Line')
2097
+
2098
+ # Configure the series.
2099
+ chart4.add_series(
2100
+ :categories => '=Sheet1!$A$2:$A$7',
2101
+ :values => '=Sheet1!$B$2:$B$7',
2102
+ :name => 'Test data series 1'
2103
+ )
2104
+
2105
+ # Add another series.
2106
+ chart4.add_series(
2107
+ :categories => '=Sheet1!$A$2:$A$7',
2108
+ :values => '=Sheet1!$C$2:$C$7',
2109
+ :name => 'Test data series 2'
2110
+ )
2111
+
2112
+ # Add some labels.
2113
+ chart4.set_title( :name => 'Results of sample analysis' )
2114
+ chart4.set_x_axis( :name => 'Sample number' )
2115
+ chart4.set_y_axis( :name => 'Sample length (cm)' )
2116
+
2117
+ ###############################################################################
2118
+ #
2119
+ # Example 5. Same as Example 3 but as an embedded chart.
2120
+ #
2121
+ chart5 = workbook.add_chart(:type => 'Chart::Line', :embedded => 1)
2122
+
2123
+ # Configure the series.
2124
+ chart5.add_series(
2125
+ :categories => '=Sheet1!$A$2:$A$7',
2126
+ :values => '=Sheet1!$B$2:$B$7',
2127
+ :name => 'Test data series 1'
2128
+ )
2129
+
2130
+ # Add some labels.
2131
+ chart5.set_title(:name => 'Results of sample analysis' )
2132
+ chart5.set_x_axis(:name => 'Sample number')
2133
+ chart5.set_y_axis(:name => 'Sample length (cm)')
2134
+
2135
+ # Insert the chart into the main worksheet.
2136
+ worksheet.insert_chart('E2', chart5)
2137
+
2138
+ # File save
2139
+ workbook.close
2140
2140
 
2141
2141
  # do assertion
2142
2142
  compare_file("#{PERL_OUTDIR}/chart_line.xls", @file)
@@ -2154,9 +2154,9 @@ workbook.close
2154
2154
  # Define the property hashes
2155
2155
  #
2156
2156
  black = {
2157
- 'fg_color' => 'black',
2158
- 'pattern' => 1,
2159
- }
2157
+ 'fg_color' => 'black',
2158
+ 'pattern' => 1,
2159
+ }
2160
2160
 
2161
2161
  top = { 'top' => 6 }
2162
2162
  bottom = { 'bottom' => 6 }
@@ -2294,23 +2294,23 @@ workbook.close
2294
2294
  ]
2295
2295
 
2296
2296
  colors = {
2297
- 0x08 => 'black',
2298
- 0x0C => 'blue',
2299
- 0x10 => 'brown',
2300
- 0x0F => 'cyan',
2301
- 0x17 => 'gray',
2302
- 0x11 => 'green',
2303
- 0x0B => 'lime',
2304
- 0x0E => 'magenta',
2305
- 0x12 => 'navy',
2306
- 0x35 => 'orange',
2307
- 0x21 => 'pink',
2308
- 0x14 => 'purple',
2309
- 0x0A => 'red',
2310
- 0x16 => 'silver',
2311
- 0x09 => 'white',
2312
- 0x0D => 'yellow',
2313
- }
2297
+ 0x08 => 'black',
2298
+ 0x0C => 'blue',
2299
+ 0x10 => 'brown',
2300
+ 0x0F => 'cyan',
2301
+ 0x17 => 'gray',
2302
+ 0x11 => 'green',
2303
+ 0x0B => 'lime',
2304
+ 0x0E => 'magenta',
2305
+ 0x12 => 'navy',
2306
+ 0x35 => 'orange',
2307
+ 0x21 => 'pink',
2308
+ 0x14 => 'purple',
2309
+ 0x0A => 'red',
2310
+ 0x16 => 'silver',
2311
+ 0x09 => 'white',
2312
+ 0x0D => 'yellow',
2313
+ }
2314
2314
 
2315
2315
  worksheet1 = workbook.add_worksheet('Named colors')
2316
2316
 
@@ -2329,9 +2329,9 @@ workbook.close
2329
2329
  #
2330
2330
  order.each do |index|
2331
2331
  format = workbook.add_format(
2332
- :fg_color => colors[index],
2333
- :pattern => 1,
2334
- :border => 1
2332
+ :fg_color => colors[index],
2333
+ :pattern => 1,
2334
+ :border => 1
2335
2335
  )
2336
2336
 
2337
2337
  worksheet1.write(i + 1, 0, index, center)
@@ -2357,9 +2357,9 @@ workbook.close
2357
2357
 
2358
2358
  (8..63).each do |i|
2359
2359
  format = workbook.add_format(
2360
- :fg_color => i,
2361
- :pattern => 1,
2362
- :border => 1
2360
+ :fg_color => i,
2361
+ :pattern => 1,
2362
+ :border => 1
2363
2363
  )
2364
2364
 
2365
2365
  worksheet2.write((i - 7), 0, i, center)
@@ -2699,7 +2699,7 @@ workbook.close
2699
2699
 
2700
2700
  worksheet7.write(cell, cell_text, text_wrap)
2701
2701
  worksheet7.write_comment(cell, comment, :author => author,
2702
- :author_encoding => 1)
2702
+ :author_encoding => 1)
2703
2703
 
2704
2704
  # UTF-8 string.
2705
2705
  author = '☺' # smiley
@@ -2922,12 +2922,12 @@ workbook.close
2922
2922
  # Example 3: Create a worksheet with outlined columns.
2923
2923
  #
2924
2924
  data = [
2925
- ['Month', 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', ' Total'],
2926
- ['North', 50, 20, 15, 25, 65, 80, '=SUM(B2:G2)'],
2927
- ['South', 10, 20, 30, 50, 50, 50, '=SUM(B3:G3)'],
2928
- ['East', 45, 75, 50, 15, 75, 100, '=SUM(B4:G4)'],
2929
- ['West', 15, 15, 55, 35, 20, 50, '=SUM(B5:G6)']
2930
- ]
2925
+ ['Month', 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', ' Total'],
2926
+ ['North', 50, 20, 15, 25, 65, 80, '=SUM(B2:G2)'],
2927
+ ['South', 10, 20, 30, 50, 50, 50, '=SUM(B3:G3)'],
2928
+ ['East', 45, 75, 50, 15, 75, 100, '=SUM(B4:G4)'],
2929
+ ['West', 15, 15, 55, 35, 20, 50, '=SUM(B5:G6)']
2930
+ ]
2931
2931
 
2932
2932
  # Add bold format to the first row
2933
2933
  worksheet3.set_row(0, nil, bold)
@@ -3218,7 +3218,7 @@ workbook.close
3218
3218
 
3219
3219
  (0..8).each { |i| worksheet1.write(0, i, 'Scroll down', header) }
3220
3220
  (1..100).each do |i|
3221
- (0..8).each { |j| worksheet1.write(i, j, i + 1, center) }
3221
+ (0..8).each { |j| worksheet1.write(i, j, i + 1, center) }
3222
3222
  end
3223
3223
 
3224
3224
  #######################################################################
@@ -3449,22 +3449,22 @@ workbook.close
3449
3449
  #
3450
3450
  ENV["TZ"] = "Japan"
3451
3451
  workbook.instance_variable_set(
3452
- :@localtime,
3453
- Time.gm(2013, 5, 5, 13, 37, 42).localtime
3454
- )
3452
+ :@localtime,
3453
+ Time.gm(2013, 5, 5, 13, 37, 42).localtime
3454
+ )
3455
3455
 
3456
3456
  worksheet = workbook.add_worksheet
3457
3457
 
3458
3458
  workbook.set_properties(
3459
- :title => 'This is an example spreadsheet',
3460
- :subject => 'With document properties',
3461
- :author => 'Hideo NAKAMURA',
3462
- :manager => 'John McNamara',
3463
- :company => 'Rubygem',
3464
- :category => 'Example spreadsheets',
3465
- :keywords => 'Sample, Example, Properties',
3466
- :comments => 'Created with Ruby and WriteExcel'
3467
- )
3459
+ :title => 'This is an example spreadsheet',
3460
+ :subject => 'With document properties',
3461
+ :author => 'Hideo NAKAMURA',
3462
+ :manager => 'John McNamara',
3463
+ :company => 'Rubygem',
3464
+ :category => 'Example spreadsheets',
3465
+ :keywords => 'Sample, Example, Properties',
3466
+ :comments => 'Created with Ruby and WriteExcel'
3467
+ )
3468
3468
 
3469
3469
 
3470
3470
  worksheet.set_column('A:A', 50)
@@ -3486,10 +3486,10 @@ workbook.close
3486
3486
  # Add the worksheet data that the charts will refer to.
3487
3487
  headings = [ 'Category', 'Values 1', 'Values 2' ]
3488
3488
  data = [
3489
- [ 2, 3, 4, 5, 6, 7 ],
3490
- [ 1, 4, 5, 2, 1, 5 ],
3491
- [ 3, 6, 7, 5, 4, 3 ]
3492
- ]
3489
+ [ 2, 3, 4, 5, 6, 7 ],
3490
+ [ 1, 4, 5, 2, 1, 5 ],
3491
+ [ 3, 6, 7, 5, 4, 3 ]
3492
+ ]
3493
3493
 
3494
3494
  worksheet.write('A1', headings, bold)
3495
3495
  worksheet.write('A2', data)