writeexcel 1.0.1 → 1.0.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 20b416cc3748f15ad174799abf46360206cd2121
4
- data.tar.gz: 75a4470abe845517634c386a89d6b7a147a741cc
3
+ metadata.gz: 5b531b36875f0418a1d22f1eacac9cf7f1e811ff
4
+ data.tar.gz: 0bc6f8b78768aa2e2ce03b97066d10d1b751ff63
5
5
  SHA512:
6
- metadata.gz: 24ebdecf66d38da930c4c6b5b5ab7a242c42838d97651e42ccbaa009f78545cb9819f726ae2d578de14c41617e115da3c933e423de59a6d60520b59397ec18d6
7
- data.tar.gz: e301135144176bb1af2ce65c15ee1f2a03aab117b262a489500b088c7e31920c15d4aa90f4f93d299b0194581e0736bad21bb7b7b30e32f0a5c19a2867d6d86f
6
+ metadata.gz: 6323cf3fab002c0211284e4fe5f0e41038af0ca322d1a79197b7e52cdd23c3d2a36982e7871d52022cbfa467d03f24f9bd56e81442f440ffa633401ada8fe71a
7
+ data.tar.gz: 05e0fc08c9824fb5590f267919fea15c1525bf0c34bae99d01842392885e921ac57a382d3e989ad6d139dbfdd08087f644da3002ef1874e1281a722532ed448e
@@ -82,6 +82,10 @@ Example Code:
82
82
  * and ......
83
83
 
84
84
  == Recent Change
85
+ v1.0.2
86
+ * Bug fix issue 28. bug in non ascii worksheet names.
87
+ * Bug fix in testcase issue 28. fail due to defferent timezone.
88
+
85
89
  v1.0.1
86
90
  * Bug fix issue 25. bug in Chart#set_legend.
87
91
 
@@ -93,7 +97,7 @@ v1.0.0
93
97
  Original was written in Perl by John McNamara (jmcnamara@cpan.org).
94
98
 
95
99
  Convert to ruby by Hideo Nakamura (cxn03651@msj.biglobe.ne.jp)
96
- Copyright (c) 2009-2013 Hideo NAKAMURA. See LICENSE for details.
100
+ Copyright (c) 2009-2013 Hideo NAKAMURA. See LICENSE.txt for details.
97
101
 
98
102
  == License
99
103
 
@@ -134,7 +134,6 @@
134
134
  #
135
135
  txt = 'Select a value from a drop down list'
136
136
  row += 2
137
- bp=1
138
137
  worksheet.write(row, 0, txt)
139
138
  worksheet.data_validation(row, 1,
140
139
  {
@@ -21,7 +21,6 @@
21
21
  worksheet2 = workbook.add_worksheet('Image 2')
22
22
  worksheet3 = workbook.add_worksheet('Image 3')
23
23
  worksheet4 = workbook.add_worksheet('Image 4')
24
- bp=1
25
24
 
26
25
  # Insert a basic image
27
26
  worksheet1.write('A10', "Image inserted into worksheet.")
@@ -24,7 +24,6 @@
24
24
  [1, 3,6,7].each { |row| worksheet.set_row(row, 30) }
25
25
  worksheet.set_column('B:D', 20)
26
26
 
27
- bp=1
28
27
  ###############################################################################
29
28
  #
30
29
  # Example 1: Merge cells containing a hyperlink using write_url_range()
@@ -15,7 +15,7 @@
15
15
 
16
16
  workbook = WriteExcel.new('properties_jp.xls')
17
17
  worksheet = workbook.add_worksheet
18
- bp =1
18
+
19
19
  workbook.set_properties(
20
20
  :title => 'スプレッドシートの作成例',
21
21
  :subject => 'ファイルのプロパティをセット',
@@ -40,7 +40,6 @@
40
40
  west.write(0, 1, 100000)
41
41
 
42
42
  # Set the active worksheet
43
- bp=1
44
43
  south.activate()
45
44
 
46
45
  # Set the width of the first column
@@ -703,7 +703,7 @@ name="sheets"
703
703
  <p>If no arguments are passed the method returns a list of all the worksheets in the workbook. This is useful if you want to repeat an operation on each worksheet:</p>
704
704
 
705
705
  <pre>
706
- workbook.sheets.each do |worksheet|
706
+ workbook.sheets.each do |worksheet|
707
707
  print worksheet.name
708
708
  end
709
709
  </pre>
@@ -5830,6 +5830,7 @@ name="Additional_Examples"
5830
5830
  chart_area.rb A demo of area style charts.
5831
5831
  chart_bar.rb A demo of bar (vertical histogram) style charts.
5832
5832
  chart_column.rb A demo of column (histogram) style charts.
5833
+ chart_legend.rb A demo of chart with/without legend.
5833
5834
  chart_line.rb A demo of line style charts.
5834
5835
  chart_pie.rb A demo of pie style charts.
5835
5836
  chart_scatter.rb A demo of scatter style charts.
@@ -5857,6 +5858,7 @@ name="Additional_Examples"
5857
5858
  outline.rb An example of outlines and grouping.
5858
5859
  outline_collapsed.rb An example of collapsed outlines.
5859
5860
  panes.rb An examples of how to create panes.
5861
+ password_protection.rb An example of sheet protection by password.
5860
5862
  properties.rb Add document properties to a workbook.
5861
5863
  properties_jp.rb Add document properties in Japanese to a workbook.
5862
5864
  protection.rb Example of cell locking and formula hiding.
@@ -5864,6 +5866,7 @@ name="Additional_Examples"
5864
5866
  right_to_left.rb Change default sheet direction to right to left.
5865
5867
  row_wrap.rb How to wrap data from one worksheet onto another.
5866
5868
  sales.rb An example of a simple sales spreadsheet.
5869
+ stats.rb A simple example of how to use functions.
5867
5870
  stocks.rb Demonstrates conditional formatting.
5868
5871
  tab_colors.rb Example of how to set worksheet tab colours.
5869
5872
  write_arrays.rb Example of writing 1D or 2D arrays of data.
@@ -5931,7 +5934,7 @@ name="THE_EXCEL_BINARY_FORMAT"
5931
5934
  <h1><a class='u' href='#___top' title='click to go to top of document'
5932
5935
  name="LICENSE"
5933
5936
  >LICENSE</a></h1>
5934
- <p>Same as Ruby.</p>
5937
+ <p>MIT Lisence.</p>
5935
5938
 
5936
5939
  <h1><a class='u' href='#___top' title='click to go to top of document'
5937
5940
  name="COPYRIGHT"
@@ -1,5 +1,5 @@
1
1
  require 'writeexcel'
2
2
 
3
3
  class WriteExcel < Workbook
4
- VERSION = "1.0.1"
4
+ VERSION = "1.0.2"
5
5
  end
@@ -872,7 +872,7 @@ def check_sheetname(name, name_utf16be = false, chart = nil) #:nodoc:
872
872
  check_sheetname_valid_chars(name, name_utf16be)
873
873
 
874
874
  # Handle utf8 strings
875
- if is_utf8?(name)
875
+ if !name_utf16be && is_utf8?(name)
876
876
  name = utf8_to_16be(name)
877
877
  name_utf16be = true
878
878
  end
@@ -914,19 +914,27 @@ def check_sheetname_even(name) #:nodoc:
914
914
 
915
915
  def check_sheetname_valid_chars(name, name_utf16be) #:nodoc:
916
916
  # Check that sheetname doesn't contain any invalid characters
917
- invalid_char = %r![\[\]:*?/\\]!
918
- if !name_utf16be && name =~ invalid_char
919
- # Check ASCII names
917
+ invalid_chars = %r![\[\]:*?/\\]!
918
+
919
+ if ascii_sheetname_invalid_chars?(name, name_utf16be, invalid_chars) ||
920
+ non_ascii_sheetname_invalid_chars?(name, invalid_chars)
920
921
  raise "Invalid character []:*?/\\ in worksheet name: #{name}"
921
- else
922
- # Extract any 8bit clean chars from the UTF16 name and validate them.
923
- str = name.dup
924
- while str =~ /../m
925
- hi, lo = $~[0].unpack('aa')
926
- if hi == "\0" and lo =~ invalid_char
927
- raise 'Invalid character []:*?/\\ in worksheet name: ' + name
928
- end
929
- str = $~.post_match
922
+ end
923
+ end
924
+
925
+ def ascii_sheetname_invalid_chars?(name, name_utf16be, invalid_chars) # :nodoc:
926
+ # Check ASCII names
927
+ !name_utf16be && name =~ invalid_chars
928
+ end
929
+
930
+ def non_ascii_sheetname_invalid_chars?(name, invalid_chars) # :nodoc:
931
+ # Extract any 8bit clean chars from the UTF16 name and validate them.
932
+ str = ruby_19 { name.dup.force_encoding("binary") } || ruby_18 { name.dup }
933
+ while str =~ /../m
934
+ hi, lo = $~[0].unpack('aa')
935
+ str = $~.post_match
936
+ if hi == "\0" and lo =~ invalid_chars
937
+ raise 'Invalid character []:*?/\\ in worksheet name: ' + name
930
938
  end
931
939
  end
932
940
  end
@@ -1,7 +1,10 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  require 'rubygems'
3
+ require 'simplecov'
3
4
  require 'test/unit'
4
5
 
6
+ SimpleCov.start
7
+
5
8
  $LOAD_PATH.unshift(File.dirname(__FILE__))
6
9
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
7
10
  require 'writeexcel'
@@ -3,8 +3,41 @@
3
3
 
4
4
  class TC_add_worksheet < Test::Unit::TestCase
5
5
 
6
- def test_true
7
- assert(true)
6
+ def setup
7
+ @workbook = WriteExcel.new(StringIO.new)
8
+ end
9
+
10
+ def test_ascii_worksheet_name
11
+
12
+ name = "Test"
13
+
14
+ assert_nothing_raised {
15
+ sheet = @workbook.add_worksheet(name)
16
+ assert_equal name, sheet.name
17
+ }
18
+
19
+ end
20
+
21
+ def test_utf_8_worksheet_name
22
+
23
+ name = "Décembre"
24
+
25
+ assert_nothing_raised {
26
+ sheet = @workbook.add_worksheet(name)
27
+ assert_equal utf8_to_16be(name), sheet.name
28
+ }
29
+
30
+ end
31
+
32
+ def test_utf_16be_worksheet_name
33
+
34
+ name = utf8_to_16be("Décembre")
35
+
36
+ assert_nothing_raised {
37
+ sheet = @workbook.add_worksheet(name, true)
38
+ assert_equal name, sheet.name
39
+ }
40
+
8
41
  end
9
42
 
10
43
  end
@@ -318,7 +318,6 @@ def test_regions
318
318
  west.write(0, 1, 100000)
319
319
 
320
320
  # Set the active worksheet
321
- bp=1
322
321
  south.activate()
323
322
 
324
323
  # Set the width of the first column
@@ -701,7 +700,7 @@ def test_data_validate
701
700
  #
702
701
  txt = 'Select a value from a drop down list'
703
702
  row += 2
704
- bp=1
703
+
705
704
  worksheet.write(row, 0, txt)
706
705
  worksheet.data_validation(row, 1,
707
706
  {
@@ -1156,7 +1155,6 @@ def test_images
1156
1155
  worksheet2 = workbook.add_worksheet('Image 2')
1157
1156
  worksheet3 = workbook.add_worksheet('Image 3')
1158
1157
  worksheet4 = workbook.add_worksheet('Image 4')
1159
- bp=1
1160
1158
 
1161
1159
  # Insert a basic image
1162
1160
  worksheet1.write('A10', "Image inserted into worksheet.")
@@ -3423,14 +3421,16 @@ def test_compatibility_mode_write_number
3423
3421
  end
3424
3422
 
3425
3423
  def test_properties
3424
+ tz = ENV["TZ"]
3426
3425
  workbook = WriteExcel.new(@file)
3427
3426
 
3428
3427
  #
3429
3428
  # adjust @localtime to target xls file.
3430
3429
  #
3430
+ ENV["TZ"] = "Japan"
3431
3431
  workbook.instance_variable_set(
3432
3432
  :@localtime,
3433
- Time.local(2013, 5, 5, 22, 37, 42)
3433
+ Time.gm(2013, 5, 5, 13, 37, 42).localtime
3434
3434
  )
3435
3435
 
3436
3436
  worksheet = workbook.add_worksheet
@@ -3454,6 +3454,8 @@ def test_properties
3454
3454
 
3455
3455
  # do assertion
3456
3456
  compare_file("#{PERL_OUTDIR}/properties.xls", @file)
3457
+
3458
+ ENV["TZ"] = tz
3457
3459
  end
3458
3460
 
3459
3461
  def test_chart_legend
@@ -9,9 +9,10 @@ def setup
9
9
  end
10
10
 
11
11
  def test_pack_VT_FILETIME
12
+ filetime =
12
13
  assert_equal(
13
14
  '40 00 00 00 00 FD 2D ED CE 48 CE 01',
14
- unpack_record(pack_VT_FILETIME(Time.local(2013, 5, 4, 22, 54, 42)))
15
+ unpack_record(pack_VT_FILETIME(Time.gm(2013, 5, 4, 13, 54, 42)))
15
16
  )
16
17
  end
17
18
 
@@ -26,7 +27,7 @@ def test_create_summary_property_set
26
27
  [4, "VT_LPSTR", "Hideo NAKAMURA"],
27
28
  [5, "VT_LPSTR", "Sample, Example, Properties"],
28
29
  [6, "VT_LPSTR", "Created with Ruby and WriteExcel"],
29
- [12, "VT_FILETIME", Time.local(2013, 5, 4, 21, 47, 16)]
30
+ [12, "VT_FILETIME", Time.gm(2013, 5, 4, 12, 47, 16)]
30
31
  ]
31
32
  ))
32
33
  )
@@ -20,4 +20,5 @@ Gem::Specification.new do |gem|
20
20
  "LICENSE.txt",
21
21
  "README.rdoc"
22
22
  ]
23
+ gem.add_development_dependency 'simplecov'
23
24
  end
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: writeexcel
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hideo NAKAMURA
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-06-26 00:00:00.000000000 Z
12
- dependencies: []
11
+ date: 2013-12-08 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: simplecov
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
13
27
  description: Multiple worksheets can be added to a workbook and formatting can be
14
28
  applied to cells. Text, numbers, formulas, hyperlinks and images can be written
15
29
  to the cells.
@@ -299,7 +313,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
299
313
  version: '0'
300
314
  requirements: []
301
315
  rubyforge_project:
302
- rubygems_version: 2.0.3
316
+ rubygems_version: 2.1.11
303
317
  signing_key:
304
318
  specification_version: 4
305
319
  summary: Write to a cross-platform Excel binary file.