writeexcel 0.6.14 → 0.6.15

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.
data/README.rdoc CHANGED
@@ -76,6 +76,9 @@ You must save source file in UTF8 and run ruby with -Ku option or set $KCODE='u'
76
76
  when use urf8 string data.
77
77
 
78
78
  == Recent Changes
79
+ v0.6.15
80
+ * add Worksheet#merge_range_with_date_time : write datetime string to merged cells
81
+
79
82
  v0.6.14
80
83
  * Buf fix Issues 20. If more than 10 sheets, sheet reference mix up
81
84
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.6.14
1
+ 0.6.15
@@ -959,43 +959,39 @@ class Worksheet < BIFFWriter
959
959
  format = args[5]
960
960
  encoding = args[6] ? 1 : 0
961
961
 
962
- # Temp code to prevent merged formats in non-merged cells.
963
- error = "Error: refer to merge_range() in the documentation. " +
964
- "Can't use previously non-merged format in merged cells"
965
-
966
- raise error if format.used_merge == -1
967
- format.used_merge = 0 # Until the end of this function.
968
-
969
- # Set the merge_range property of the format object. For BIFF8+.
970
- format.set_merge_range
962
+ merge_range_core(rwFirst, colFirst, rwLast, colLast, string, format, encoding) do |rwFirst, colFirst, string, format, encoding|
963
+ if encoding != 0
964
+ write_utf16be_string(rwFirst, colFirst, string, format)
965
+ else
966
+ write(rwFirst, colFirst, string, format)
967
+ end
968
+ end
969
+ end
971
970
 
972
- # Excel doesn't allow a single cell to be merged
973
- raise "Can't merge single cell" if rwFirst == rwLast and
974
- colFirst == colLast
971
+ #
972
+ # :call-seq:
973
+ # merge_range_with_date_time(first_row, first_col, last_row, last_col, token, format)
974
+ #
975
+ # Write to meged cells, a datetime string in ISO8601 "yyyy-mm-ddThh:mm:ss.ss" format as a
976
+ # number representing an Excel date. format is optional.
977
+ #
978
+ def merge_range_with_date_time(*args)
979
+ # Check for a cell reference in A1 notation and substitute row and column
980
+ args = row_col_notation(args)
975
981
 
976
- # Swap last row/col with first row/col as necessary
977
- rwFirst, rwLast = rwLast, rwFirst if rwFirst > rwLast
978
- colFirst, colLast = colLast, colFirst if colFirst > colLast
982
+ raise "Incorrect number of arguments" if args.size != 6 and args.size != 7
983
+ raise "Format argument is not a format object" unless args[5].respond_to?(:xf_index)
979
984
 
980
- # Write the first cell
981
- if encoding != 0
982
- write_utf16be_string(rwFirst, colFirst, string, format)
983
- else
984
- write(rwFirst, colFirst, string, format)
985
- end
985
+ rwFirst = args[0]
986
+ colFirst = args[1]
987
+ rwLast = args[2]
988
+ colLast = args[3]
989
+ string = args[4]
990
+ format = args[5]
986
991
 
987
- # Pad out the rest of the area with formatted blank cells.
988
- (rwFirst .. rwLast).each do |row|
989
- (colFirst .. colLast).each do |col|
990
- next if row == rwFirst and col == colFirst
991
- write_blank(row, col, format)
992
- end
992
+ merge_range_core(rwFirst, colFirst, rwLast, colLast, string, format, encoding) do |rwFirst, colFirst, string, format, nil|
993
+ write_date_time(rwFirst, colFirst, string, format)
993
994
  end
994
-
995
- merge_cells(rwFirst, colFirst, rwLast, colLast)
996
-
997
- # Temp code to prevent merged formats in non-merged cells.
998
- format.used_merge = 1
999
995
  end
1000
996
 
1001
997
  #
@@ -4702,6 +4698,42 @@ class Worksheet < BIFFWriter
4702
4698
  end
4703
4699
  end
4704
4700
 
4701
+ def merge_range_core(rwFirst, colFirst, rwLast, colLast, string, format, encoding)
4702
+ # Temp code to prevent merged formats in non-merged cells.
4703
+ error = "Error: refer to merge_range() in the documentation. " +
4704
+ "Can't use previously non-merged format in merged cells"
4705
+
4706
+ raise error if format.used_merge == -1
4707
+ format.used_merge = 0 # Until the end of this function.
4708
+
4709
+ # Set the merge_range property of the format object. For BIFF8+.
4710
+ format.set_merge_range
4711
+
4712
+ # Excel doesn't allow a single cell to be merged
4713
+ raise "Can't merge single cell" if rwFirst == rwLast and
4714
+ colFirst == colLast
4715
+
4716
+ # Swap last row/col with first row/col as necessary
4717
+ rwFirst, rwLast = rwLast, rwFirst if rwFirst > rwLast
4718
+ colFirst, colLast = colLast, colFirst if colFirst > colLast
4719
+
4720
+ # Write the first cell
4721
+ yield(rwFirst, colFirst, string, format, encoding)
4722
+
4723
+ # Pad out the rest of the area with formatted blank cells.
4724
+ (rwFirst .. rwLast).each do |row|
4725
+ (colFirst .. colLast).each do |col|
4726
+ next if row == rwFirst and col == colFirst
4727
+ write_blank(row, col, format)
4728
+ end
4729
+ end
4730
+
4731
+ merge_cells(rwFirst, colFirst, rwLast, colLast)
4732
+
4733
+ # Temp code to prevent merged formats in non-merged cells.
4734
+ format.used_merge = 1
4735
+ end
4736
+
4705
4737
  #
4706
4738
  # Extract the tokens from the filter expression. The tokens are mainly non-
4707
4739
  # whitespace groups. The only tricky part is to extract string tokens that
data/writeexcel.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "writeexcel"
8
- s.version = "0.6.14"
8
+ s.version = "0.6.15"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Hideo NAKAMURA"]
12
- s.date = "2012-07-12"
12
+ s.date = "2012-07-26"
13
13
  s.description = "Multiple worksheets can be added to a workbook and formatting can be applied to cells. Text, numbers, formulas, hyperlinks and images can be written to the cells."
14
14
  s.email = "cxn03651@msj.biglobe.ne.jp"
15
15
  s.extra_rdoc_files = [
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: writeexcel
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.14
4
+ version: 0.6.15
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-07-12 00:00:00.000000000 Z
12
+ date: 2012-07-26 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: Multiple worksheets can be added to a workbook and formatting can be
15
15
  applied to cells. Text, numbers, formulas, hyperlinks and images can be written