writeexcel 0.6.4 → 0.6.5
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/.gitignore +3 -0
- data/README.rdoc +2 -0
- data/VERSION +1 -1
- data/lib/writeexcel/chart.rb +3 -13
- data/lib/writeexcel/format.rb +4 -12
- data/lib/writeexcel/formula.rb +7 -24
- data/lib/writeexcel/helper.rb +7 -0
- data/lib/writeexcel/workbook.rb +266 -271
- data/lib/writeexcel/worksheet.rb +320 -428
- data/test/test_workbook.rb +20 -15
- data/writeexcel.gemspec +2 -2
- metadata +4 -4
data/lib/writeexcel/worksheet.rb
CHANGED
@@ -19,6 +19,8 @@
|
|
19
19
|
class MaxSizeError < StandardError #:nodoc:
|
20
20
|
end
|
21
21
|
|
22
|
+
module Writeexcel
|
23
|
+
|
22
24
|
#
|
23
25
|
# = class Worksheet
|
24
26
|
#
|
@@ -30,14 +32,9 @@ class MaxSizeError < StandardError #:nodoc:
|
|
30
32
|
# worksheet1 = workbook.add_worksheet
|
31
33
|
# worksheet2 = workbook.add_worksheet
|
32
34
|
#
|
33
|
-
|
34
|
-
module Writeexcel
|
35
|
-
|
36
35
|
class Worksheet < BIFFWriter
|
37
36
|
require 'writeexcel/helper'
|
38
37
|
|
39
|
-
NonAscii = /[^!"#\$%&'\(\)\*\+,\-\.\/\:\;<=>\?@0-9A-Za-z_\[\\\]\{\}^` ~\0\n]/
|
40
|
-
|
41
38
|
RowMax = 65536 # :nodoc:
|
42
39
|
ColMax = 256 # :nodoc:
|
43
40
|
StrMax = 0 # :nodoc:
|
@@ -192,7 +189,7 @@ def initialize(name, index, encoding, url_format, parser, tempdir,
|
|
192
189
|
|
193
190
|
###############################################################################
|
194
191
|
#
|
195
|
-
#
|
192
|
+
# close()
|
196
193
|
#
|
197
194
|
# Add data to the beginning of the workbook (note the reverse order)
|
198
195
|
# and to the end of the workbook.
|
@@ -308,13 +305,13 @@ def close #:nodoc:
|
|
308
305
|
store_bof(0x0010)
|
309
306
|
end
|
310
307
|
|
311
|
-
def cleanup
|
308
|
+
def cleanup # :nodoc:
|
312
309
|
super
|
313
310
|
end
|
314
311
|
|
315
312
|
###############################################################################
|
316
313
|
#
|
317
|
-
#
|
314
|
+
# compatibility_mode()
|
318
315
|
#
|
319
316
|
# Set the compatibility mode.
|
320
317
|
#
|
@@ -642,7 +639,7 @@ def set_row(row, height = nil, format = nil, hidden = 0, level = 0, collapsed =
|
|
642
639
|
#
|
643
640
|
# Set the width of a single column or a range of columns.
|
644
641
|
#--
|
645
|
-
# See also:
|
642
|
+
# See also: store_colinfo
|
646
643
|
#++
|
647
644
|
#
|
648
645
|
# This method can be used to change the default properties of a single
|
@@ -724,7 +721,7 @@ def set_row(row, height = nil, format = nil, hidden = 0, level = 0, collapsed =
|
|
724
721
|
# programs in the examples directory of the distro.
|
725
722
|
#
|
726
723
|
# Excel allows up to 7 outline levels. Therefore the _level_ parameter
|
727
|
-
# should be in the range 0 <=
|
724
|
+
# should be in the range 0 <= level <= 7.
|
728
725
|
#
|
729
726
|
def set_column(*args)
|
730
727
|
data = args
|
@@ -734,12 +731,12 @@ def set_column(*args)
|
|
734
731
|
if cell =~ /^\D/
|
735
732
|
data = substitute_cellref(*args)
|
736
733
|
|
737
|
-
# Returned values
|
738
|
-
data.shift #
|
739
|
-
data.delete_at(1) #
|
734
|
+
# Returned values row1 and row2 aren't required here. Remove them.
|
735
|
+
data.shift # row1
|
736
|
+
data.delete_at(1) # row2
|
740
737
|
end
|
741
738
|
|
742
|
-
return if data.size < 3 # Ensure at least
|
739
|
+
return if data.size < 3 # Ensure at least firstcol, lastcol and width
|
743
740
|
return if data[0].nil? # Columns must be defined.
|
744
741
|
return if data[1].nil?
|
745
742
|
|
@@ -777,7 +774,7 @@ def set_column(*args)
|
|
777
774
|
# set_selection('B3:C8')
|
778
775
|
#
|
779
776
|
# Set which cell or cells are selected in a worksheet: see also the
|
780
|
-
# sub
|
777
|
+
# sub store_selection
|
781
778
|
#
|
782
779
|
# This method can be used to specify which cell or cells are selected in a
|
783
780
|
# worksheet. The most common requirement is to select a single cell, in which
|
@@ -799,9 +796,8 @@ def set_column(*args)
|
|
799
796
|
#
|
800
797
|
def set_selection(*args)
|
801
798
|
# Check for a cell reference in A1 notation and substitute row and column
|
802
|
-
|
803
|
-
|
804
|
-
end
|
799
|
+
args = row_col_notation(args)
|
800
|
+
|
805
801
|
@selection = args
|
806
802
|
end
|
807
803
|
|
@@ -860,7 +856,7 @@ def outline_settings(*args)
|
|
860
856
|
#
|
861
857
|
# Set panes and mark them as frozen.
|
862
858
|
#--
|
863
|
-
# See also
|
859
|
+
# See also store_panes().
|
864
860
|
#++
|
865
861
|
#
|
866
862
|
# This method can be used to divide a worksheet into horizontal or vertical
|
@@ -900,9 +896,8 @@ def outline_settings(*args)
|
|
900
896
|
#
|
901
897
|
def freeze_panes(*args)
|
902
898
|
# Check for a cell reference in A1 notation and substitute row and column
|
903
|
-
|
904
|
-
|
905
|
-
end
|
899
|
+
args = row_col_notation(args)
|
900
|
+
|
906
901
|
# Extra flag indicated a split and freeze.
|
907
902
|
@frozen_no_split = 0 if !args[4].nil? && args[4] != 0
|
908
903
|
|
@@ -917,7 +912,7 @@ def freeze_panes(*args)
|
|
917
912
|
#
|
918
913
|
# Set panes and mark them as split.
|
919
914
|
#--
|
920
|
-
# See also
|
915
|
+
# See also store_panes().
|
921
916
|
#++
|
922
917
|
#
|
923
918
|
# This method can be used to divide a worksheet into horizontal or vertical
|
@@ -929,7 +924,7 @@ def freeze_panes(*args)
|
|
929
924
|
# position of the split. The units for _y_ and _x_ are the same as those
|
930
925
|
# used by Excel to specify row height and column width. However, the
|
931
926
|
# vertical and horizontal units are different from each other. Therefore you
|
932
|
-
# must specify the
|
927
|
+
# must specify the _y_ and _x_ parameters in terms of the row heights and
|
933
928
|
# column widths that you have set or the default values which are 12.75 for
|
934
929
|
# a row and 8.43 for a column.
|
935
930
|
#
|
@@ -1012,9 +1007,8 @@ def split_panes(*args)
|
|
1012
1007
|
#
|
1013
1008
|
def merge_range(*args)
|
1014
1009
|
# Check for a cell reference in A1 notation and substitute row and column
|
1015
|
-
|
1016
|
-
|
1017
|
-
end
|
1010
|
+
args = row_col_notation(args)
|
1011
|
+
|
1018
1012
|
raise "Incorrect number of arguments" if args.size != 6 and args.size != 7
|
1019
1013
|
raise "Format argument is not a format object" unless args[5].respond_to?(:xf_index)
|
1020
1014
|
|
@@ -1066,7 +1060,7 @@ def merge_range(*args)
|
|
1066
1060
|
end
|
1067
1061
|
|
1068
1062
|
#
|
1069
|
-
# Set the worksheet zoom factor in the range 10 <=
|
1063
|
+
# Set the worksheet zoom factor in the range 10 <= scale <= 400:
|
1070
1064
|
#
|
1071
1065
|
# worksheet1.set_zoom(50)
|
1072
1066
|
# worksheet2.set_zoom(75)
|
@@ -1082,7 +1076,7 @@ def merge_range(*args)
|
|
1082
1076
|
def set_zoom(scale = 100)
|
1083
1077
|
# Confine the scale to Excel's range
|
1084
1078
|
if scale < 10 or scale > 400
|
1085
|
-
# carp "Zoom factor
|
1079
|
+
# carp "Zoom factor scale outside range: 10 <= zoom <= 400";
|
1086
1080
|
scale = 100
|
1087
1081
|
end
|
1088
1082
|
|
@@ -1163,9 +1157,7 @@ def set_tab_color(color)
|
|
1163
1157
|
#
|
1164
1158
|
def autofilter(*args)
|
1165
1159
|
# Check for a cell reference in A1 notation and substitute row and column
|
1166
|
-
|
1167
|
-
args = substitute_cellref(*args)
|
1168
|
-
end
|
1160
|
+
args = row_col_notation(args)
|
1169
1161
|
|
1170
1162
|
return if args.size != 4 # Require 4 parameters
|
1171
1163
|
|
@@ -1289,10 +1281,9 @@ def filter_column(col, expression)
|
|
1289
1281
|
# raise "Incorrect number of arguments to filter_column()" unless @_ == 2
|
1290
1282
|
|
1291
1283
|
# Check for a column reference in A1 notation and substitute.
|
1292
|
-
|
1293
|
-
|
1294
|
-
|
1295
|
-
end
|
1284
|
+
# Convert col ref to a cell ref and then to a col number.
|
1285
|
+
no_use, col = substitute_cellref(col + '1') if col =~ /^\D/
|
1286
|
+
|
1296
1287
|
col_first = @filter_area[2]
|
1297
1288
|
col_last = @filter_area[3]
|
1298
1289
|
|
@@ -1674,23 +1665,15 @@ def set_footer(string = '', margin = 0.50, encoding = 0)
|
|
1674
1665
|
set_header_footer_common(:footer, string, margin, encoding)
|
1675
1666
|
end
|
1676
1667
|
|
1677
|
-
def set_header_footer_common(type, string, margin, encoding)
|
1668
|
+
def set_header_footer_common(type, string, margin, encoding) # :nodoc:
|
1678
1669
|
ruby_19 { string = convert_to_ascii_if_ascii(string) }
|
1679
1670
|
|
1680
1671
|
limit = encoding != 0 ? 255 *2 : 255
|
1681
1672
|
|
1682
1673
|
# Handle utf8 strings
|
1683
|
-
|
1684
|
-
|
1685
|
-
|
1686
|
-
encoding = 1
|
1687
|
-
end
|
1688
|
-
end
|
1689
|
-
ruby_19 do
|
1690
|
-
if string.encoding == Encoding::UTF_8
|
1691
|
-
string = utf8_to_16be(string)
|
1692
|
-
encoding = 1
|
1693
|
-
end
|
1674
|
+
if is_utf8?(string)
|
1675
|
+
string = utf8_to_16be(string)
|
1676
|
+
encoding = 1
|
1694
1677
|
end
|
1695
1678
|
|
1696
1679
|
if string.bytesize >= limit
|
@@ -1713,7 +1696,7 @@ def set_header_footer_common(type, string, margin, encoding)
|
|
1713
1696
|
#
|
1714
1697
|
# Set the rows to repeat at the top of each printed page.
|
1715
1698
|
#--
|
1716
|
-
# See also the
|
1699
|
+
# See also the store_name_xxxx() methods in Workbook.rb.
|
1717
1700
|
#++
|
1718
1701
|
#
|
1719
1702
|
# Set the number of rows to repeat at the top of each printed page.
|
@@ -1739,7 +1722,7 @@ def repeat_rows(first_row, last_row = nil)
|
|
1739
1722
|
#
|
1740
1723
|
# Set the columns to repeat at the left hand side of each printed page.
|
1741
1724
|
#--
|
1742
|
-
# See also the
|
1725
|
+
# See also the store_names() methods in Workbook.pm.
|
1743
1726
|
#++
|
1744
1727
|
#
|
1745
1728
|
# For large Excel documents it is often desirable to have the first column
|
@@ -1760,9 +1743,9 @@ def repeat_columns(*args)
|
|
1760
1743
|
if args[0] =~ /^\D/
|
1761
1744
|
args = substitute_cellref(*args)
|
1762
1745
|
|
1763
|
-
# Returned values
|
1764
|
-
args.shift #
|
1765
|
-
args.delete_at(1) #
|
1746
|
+
# Returned values row1 and row2 aren't required here. Remove them.
|
1747
|
+
args.shift # row1
|
1748
|
+
args.delete_at(1) # row2
|
1766
1749
|
end
|
1767
1750
|
|
1768
1751
|
@title_colmin = args[0]
|
@@ -1815,7 +1798,7 @@ def hide_gridlines(option = 1)
|
|
1815
1798
|
|
1816
1799
|
#
|
1817
1800
|
# Set the option to print the row and column headers on the printed page.
|
1818
|
-
# See also the
|
1801
|
+
# See also the store_print_headers() method.
|
1819
1802
|
#
|
1820
1803
|
# An Excel worksheet looks something like the following;
|
1821
1804
|
#
|
@@ -1866,9 +1849,7 @@ def print_row_col_headers(option = nil)
|
|
1866
1849
|
#
|
1867
1850
|
def print_area(*args)
|
1868
1851
|
# Check for a cell reference in A1 notation and substitute row and column
|
1869
|
-
|
1870
|
-
args = substitute_cellref(*args)
|
1871
|
-
end
|
1852
|
+
args = row_col_notation(args)
|
1872
1853
|
|
1873
1854
|
return if args.size != 4 # Require 4 parameters
|
1874
1855
|
|
@@ -1903,7 +1884,7 @@ def print_across
|
|
1903
1884
|
# Store the vertical and horizontal number of pages that will define the
|
1904
1885
|
# maximum area printed.
|
1905
1886
|
#--
|
1906
|
-
# See also
|
1887
|
+
# See also store_setup() and store_wsbool() below.
|
1907
1888
|
#++
|
1908
1889
|
#
|
1909
1890
|
# The fit_to_pages() method is used to fit the printed area to a specific
|
@@ -1957,7 +1938,7 @@ def fit_to_pages(width = 0, height = 0)
|
|
1957
1938
|
def set_print_scale(scale = 100)
|
1958
1939
|
# Confine the scale to Excel's range
|
1959
1940
|
if scale < 10 or scale > 400
|
1960
|
-
# carp "Print scale
|
1941
|
+
# carp "Print scale scale outside range: 10 <= zoom <= 400";
|
1961
1942
|
scale = 100
|
1962
1943
|
end
|
1963
1944
|
|
@@ -2024,7 +2005,7 @@ def set_v_pagebreaks(breaks)
|
|
2024
2005
|
|
2025
2006
|
###############################################################################
|
2026
2007
|
#
|
2027
|
-
#
|
2008
|
+
# extract_filter_tokens(expression)
|
2028
2009
|
#
|
2029
2010
|
# Extract the tokens from the filter expression. The tokens are mainly non-
|
2030
2011
|
# whitespace groups. The only tricky part is to extract string tokens that
|
@@ -2039,8 +2020,6 @@ def set_v_pagebreaks(breaks)
|
|
2039
2020
|
def extract_filter_tokens(expression = nil) #:nodoc:
|
2040
2021
|
return [] unless expression
|
2041
2022
|
|
2042
|
-
# @tokens = ($expression =~ /"(?:[^"]|"")*"|\S+/g); #"
|
2043
|
-
|
2044
2023
|
tokens = []
|
2045
2024
|
str = expression
|
2046
2025
|
while str =~ /"(?:[^"]|"")*"|\S+/
|
@@ -2068,7 +2047,7 @@ def extract_filter_tokens(expression = nil) #:nodoc:
|
|
2068
2047
|
|
2069
2048
|
###############################################################################
|
2070
2049
|
#
|
2071
|
-
#
|
2050
|
+
# parse_filter_expression(expression, @token)
|
2072
2051
|
#
|
2073
2052
|
# Converts the tokens of a possibly conditional expression into 1 or 2
|
2074
2053
|
# sub expressions for further parsing.
|
@@ -2102,7 +2081,7 @@ def parse_filter_expression(expression, tokens) #:nodoc:
|
|
2102
2081
|
|
2103
2082
|
###############################################################################
|
2104
2083
|
#
|
2105
|
-
#
|
2084
|
+
# parse_filter_tokens(@token) # (@expression, @token)
|
2106
2085
|
#
|
2107
2086
|
# Parse the 3 tokens of a filter expression and return the operator and token.
|
2108
2087
|
#
|
@@ -2219,15 +2198,15 @@ def parse_filter_tokens(expression, tokens) #:nodoc:
|
|
2219
2198
|
# worksheet.write('A1', '01209')
|
2220
2199
|
#
|
2221
2200
|
# # Write a zero padded number using a format: 01209
|
2222
|
-
#
|
2223
|
-
#
|
2201
|
+
# format1 = workbook.add_format(:num_format => '00000')
|
2202
|
+
# worksheet.write('A2', '01209', format1)
|
2224
2203
|
#
|
2225
2204
|
# # Write explicitly as a string: 01209
|
2226
|
-
#
|
2205
|
+
# worksheet.write_string('A3', '01209')
|
2227
2206
|
#
|
2228
2207
|
# # Write implicitly as a string: 01209
|
2229
|
-
#
|
2230
|
-
#
|
2208
|
+
# worksheet.keep_leading_zeros()
|
2209
|
+
# worksheet.write('A4', '01209')
|
2231
2210
|
#
|
2232
2211
|
# The above code would generate a worksheet that looked like the following:
|
2233
2212
|
#
|
@@ -2329,6 +2308,7 @@ def set_first_row_column(row = 0, col = 0)
|
|
2329
2308
|
@first_col = col
|
2330
2309
|
end
|
2331
2310
|
|
2311
|
+
#--
|
2332
2312
|
#
|
2333
2313
|
# Allow the user to add their own matches and handlers to the write() method.
|
2334
2314
|
#
|
@@ -2421,11 +2401,12 @@ def set_first_row_column(row = 0, col = 0)
|
|
2421
2401
|
# See the write_handler 1-4 programs in the examples directory for further
|
2422
2402
|
# examples.
|
2423
2403
|
#
|
2424
|
-
|
2425
|
-
|
2426
|
-
|
2427
|
-
|
2428
|
-
|
2404
|
+
#++
|
2405
|
+
# def add_write_handler(regexp, code_ref)
|
2406
|
+
# # return unless ref $_[1] eq 'CODE';
|
2407
|
+
#
|
2408
|
+
# @write_match.push([regexp, code_ref])
|
2409
|
+
# end
|
2429
2410
|
|
2430
2411
|
#
|
2431
2412
|
# :call-seq:
|
@@ -2481,27 +2462,27 @@ def add_write_handler(regexp, code_ref)
|
|
2481
2462
|
#
|
2482
2463
|
# The "looks like" rule is defined by regular expressions:
|
2483
2464
|
#
|
2484
|
-
# write_number() if _token_ is a number based on the following regex:
|
2485
|
-
#
|
2465
|
+
# * write_number() if _token_ is a number based on the following regex:
|
2466
|
+
# token =~ /^([+-]?)(?=\d|\.\d)\d*(\.\d*)?([Ee]([+-]?\d+))?$/.
|
2486
2467
|
#
|
2487
|
-
# write_string() if keep_leading_zeros() is set and _token_ is an integer
|
2488
|
-
#
|
2468
|
+
# * write_string() if keep_leading_zeros() is set and _token_ is an integer
|
2469
|
+
# with leading zeros based on the following regex: token =~ /^0\d+$/.
|
2489
2470
|
#
|
2490
|
-
# write_blank() if _token_ is undef or a blank string: undef, "" or ''.
|
2471
|
+
# * write_blank() if _token_ is undef or a blank string: undef, "" or ''.
|
2491
2472
|
#
|
2492
|
-
# write_url() if _token_ is a http, https, ftp or mailto URL based on the
|
2493
|
-
#
|
2473
|
+
# * write_url() if _token_ is a http, https, ftp or mailto URL based on the
|
2474
|
+
# following regexes: token =~ m|^[fh]tt?ps?://| or $token =~ m|^mailto:|.
|
2494
2475
|
#
|
2495
|
-
# write_url() if _token_ is an internal or external sheet reference based
|
2496
|
-
#
|
2476
|
+
# * write_url() if _token_ is an internal or external sheet reference based
|
2477
|
+
# on the following regex: token =~ m[^(in|ex)ternal:].
|
2497
2478
|
#
|
2498
|
-
# write_formula() if the first character of _token_ is "=".
|
2479
|
+
# * write_formula() if the first character of _token_ is "=".
|
2499
2480
|
#
|
2500
|
-
# write_row() if _token_ is an array.
|
2481
|
+
# * write_row() if _token_ is an array.
|
2501
2482
|
#
|
2502
|
-
# write_col() if _token+ is an array of array.
|
2483
|
+
# * write_col() if _token+ is an array of array.
|
2503
2484
|
#
|
2504
|
-
# write_string() if none of the previous conditions apply.
|
2485
|
+
# * write_string() if none of the previous conditions apply.
|
2505
2486
|
#
|
2506
2487
|
# The format parameter is optional. It should be a valid Format object, see
|
2507
2488
|
# "CELL FORMATTING":
|
@@ -2539,9 +2520,7 @@ def add_write_handler(regexp, code_ref)
|
|
2539
2520
|
#
|
2540
2521
|
def write(*args)
|
2541
2522
|
# Check for a cell reference in A1 notation and substitute row and column
|
2542
|
-
|
2543
|
-
args = substitute_cellref(*args)
|
2544
|
-
end
|
2523
|
+
args = row_col_notation(args)
|
2545
2524
|
|
2546
2525
|
token = args[2]
|
2547
2526
|
|
@@ -2609,9 +2588,7 @@ def write(*args)
|
|
2609
2588
|
#
|
2610
2589
|
def write_number(*args)
|
2611
2590
|
# Check for a cell reference in A1 notation and substitute row and column
|
2612
|
-
|
2613
|
-
args = substitute_cellref(*args)
|
2614
|
-
end
|
2591
|
+
args = row_col_notation(args)
|
2615
2592
|
|
2616
2593
|
return -1 if args.size < 3 # Check the number of args
|
2617
2594
|
|
@@ -2687,9 +2664,7 @@ def write_number(*args)
|
|
2687
2664
|
#
|
2688
2665
|
def write_string(*args)
|
2689
2666
|
# Check for a cell reference in A1 notation and substitute row and column
|
2690
|
-
|
2691
|
-
args = substitute_cellref(*args)
|
2692
|
-
end
|
2667
|
+
args = row_col_notation(args)
|
2693
2668
|
|
2694
2669
|
return -1 if (args.size < 3) # Check the number of args
|
2695
2670
|
|
@@ -2707,17 +2682,9 @@ def write_string(*args)
|
|
2707
2682
|
ruby_19 {str = convert_to_ascii_if_ascii(str) }
|
2708
2683
|
|
2709
2684
|
# Handle utf8 strings
|
2710
|
-
|
2711
|
-
|
2712
|
-
|
2713
|
-
return write_utf16le_string(row, col, str_utf16le, args[3])
|
2714
|
-
end
|
2715
|
-
end
|
2716
|
-
ruby_19 do
|
2717
|
-
if str.encoding == Encoding::UTF_8
|
2718
|
-
str_utf16le = utf8_to_16le(str)
|
2719
|
-
return write_utf16le_string(row, col, str_utf16le, args[3])
|
2720
|
-
end
|
2685
|
+
if is_utf8?(str)
|
2686
|
+
str_utf16le = utf8_to_16le(str)
|
2687
|
+
return write_utf16le_string(row, col, str_utf16le, args[3])
|
2721
2688
|
end
|
2722
2689
|
|
2723
2690
|
# Check that row and col are valid and store max and min values
|
@@ -2749,7 +2716,7 @@ def write_string(*args)
|
|
2749
2716
|
str_error
|
2750
2717
|
end
|
2751
2718
|
|
2752
|
-
def store_with_compatibility(row, col, data)
|
2719
|
+
def store_with_compatibility(row, col, data) # :nodoc:
|
2753
2720
|
if @compatibility != 0
|
2754
2721
|
store_to_table(row, col, data)
|
2755
2722
|
else
|
@@ -2758,7 +2725,7 @@ def store_with_compatibility(row, col, data)
|
|
2758
2725
|
end
|
2759
2726
|
private :store_with_compatibility
|
2760
2727
|
|
2761
|
-
def store_to_table(row, col, data)
|
2728
|
+
def store_to_table(row, col, data) # :nodoc:
|
2762
2729
|
tmp = []
|
2763
2730
|
tmp[col] = data
|
2764
2731
|
@table[row] = tmp
|
@@ -2802,9 +2769,7 @@ def store_to_table(row, col, data)
|
|
2802
2769
|
#
|
2803
2770
|
def write_blank(*args)
|
2804
2771
|
# Check for a cell reference in A1 notation and substitute row and column
|
2805
|
-
|
2806
|
-
args = substitute_cellref(*args)
|
2807
|
-
end
|
2772
|
+
args = row_col_notation(args)
|
2808
2773
|
|
2809
2774
|
# Check the number of args
|
2810
2775
|
return -1 if args.size < 2
|
@@ -3111,9 +3076,7 @@ def write_blank(*args)
|
|
3111
3076
|
# ++
|
3112
3077
|
def write_formula(*args)
|
3113
3078
|
# Check for a cell reference in A1 notation and substitute row and column
|
3114
|
-
|
3115
|
-
args = substitute_cellref(args)
|
3116
|
-
end
|
3079
|
+
args = row_col_notation(args)
|
3117
3080
|
|
3118
3081
|
return -1 if args.size < 3 # Check the number of args
|
3119
3082
|
|
@@ -3216,9 +3179,7 @@ def write_formula(*args)
|
|
3216
3179
|
#
|
3217
3180
|
def write_row(*args)
|
3218
3181
|
# Check for a cell reference in A1 notation and substitute row and column
|
3219
|
-
|
3220
|
-
args = substitute_cellref(*args)
|
3221
|
-
end
|
3182
|
+
args = row_col_notation(args)
|
3222
3183
|
|
3223
3184
|
# Catch non array refs passed by user.
|
3224
3185
|
unless args[2].respond_to?(:to_ary)
|
@@ -3320,9 +3281,7 @@ def write_row(*args)
|
|
3320
3281
|
#
|
3321
3282
|
def write_col(*args)
|
3322
3283
|
# Check for a cell reference in A1 notation and substitute row and column
|
3323
|
-
|
3324
|
-
args = substitute_cellref(*args)
|
3325
|
-
end
|
3284
|
+
args = row_col_notation(args)
|
3326
3285
|
|
3327
3286
|
# Catch non array refs passed by user.
|
3328
3287
|
unless args[2].respond_to?(:to_ary)
|
@@ -3533,9 +3492,7 @@ def write_col(*args)
|
|
3533
3492
|
#
|
3534
3493
|
def write_comment(*args)
|
3535
3494
|
# Check for a cell reference in A1 notation and substitute row and column
|
3536
|
-
|
3537
|
-
args = substitute_cellref(*args)
|
3538
|
-
end
|
3495
|
+
args = row_col_notation(args)
|
3539
3496
|
|
3540
3497
|
return -1 if args.size < 3 # Check the number of args
|
3541
3498
|
|
@@ -3666,7 +3623,7 @@ def image_mso_size=(val) # :nodoc:
|
|
3666
3623
|
|
3667
3624
|
###############################################################################
|
3668
3625
|
#
|
3669
|
-
#
|
3626
|
+
# xf_record_index()
|
3670
3627
|
#
|
3671
3628
|
# Returns an index to the XF record in the workbook.
|
3672
3629
|
#
|
@@ -3693,7 +3650,7 @@ def xf_record_index(row, col, xf=nil) #:nodoc:
|
|
3693
3650
|
|
3694
3651
|
###############################################################################
|
3695
3652
|
#
|
3696
|
-
#
|
3653
|
+
# substitute_cellref()
|
3697
3654
|
#
|
3698
3655
|
# Substitute an Excel cell reference in A1 notation for zero based row and
|
3699
3656
|
# column values in an argument list.
|
@@ -3733,7 +3690,7 @@ def substitute_cellref(cell, *args) #:nodoc:
|
|
3733
3690
|
|
3734
3691
|
###############################################################################
|
3735
3692
|
#
|
3736
|
-
#
|
3693
|
+
# cell_to_rowcol($cell_ref)
|
3737
3694
|
#
|
3738
3695
|
# Convert an Excel cell reference in A1 notation to a zero based row and column
|
3739
3696
|
# reference; converts C1 to (0, 2).
|
@@ -3757,11 +3714,11 @@ def cell_to_rowcol(cell) #:nodoc:
|
|
3757
3714
|
|
3758
3715
|
###############################################################################
|
3759
3716
|
#
|
3760
|
-
#
|
3717
|
+
# sort_pagebreaks()
|
3761
3718
|
#
|
3762
3719
|
#
|
3763
3720
|
# This is an internal method that is used to filter elements of the array of
|
3764
|
-
# pagebreaks used in the
|
3721
|
+
# pagebreaks used in the store_hbreak() and store_vbreak() methods. It:
|
3765
3722
|
# 1. Removes duplicate entries from the list.
|
3766
3723
|
# 2. Sorts the list.
|
3767
3724
|
# 3. Removes 0 from the list if present.
|
@@ -3778,7 +3735,7 @@ def sort_pagebreaks(breaks) #:nodoc:
|
|
3778
3735
|
|
3779
3736
|
###############################################################################
|
3780
3737
|
#
|
3781
|
-
#
|
3738
|
+
# encode_password($password)
|
3782
3739
|
#
|
3783
3740
|
# Based on the algorithm provided by Daniel Rentz of OpenOffice.
|
3784
3741
|
#
|
@@ -3806,7 +3763,7 @@ def encode_password(password) #:nodoc:
|
|
3806
3763
|
|
3807
3764
|
###############################################################################
|
3808
3765
|
#
|
3809
|
-
#
|
3766
|
+
# encode_formula_result()
|
3810
3767
|
# my $value = $_[0]; # Result to be encoded.
|
3811
3768
|
#
|
3812
3769
|
# Encode the user supplied result for a formula.
|
@@ -3857,7 +3814,7 @@ def encode_formula_result(value = nil) #:nodoc:
|
|
3857
3814
|
|
3858
3815
|
###############################################################################
|
3859
3816
|
#
|
3860
|
-
#
|
3817
|
+
# get_formula_string()
|
3861
3818
|
#
|
3862
3819
|
# Pack the string value when a formula evaluates to a string. The value cannot
|
3863
3820
|
# be calculated by the module and thus must be supplied by the user.
|
@@ -3872,17 +3829,9 @@ def get_formula_string(string) #:nodoc:
|
|
3872
3829
|
encoding = 0 # String encoding.
|
3873
3830
|
|
3874
3831
|
# Handle utf8 strings.
|
3875
|
-
|
3876
|
-
|
3877
|
-
|
3878
|
-
encoding = 1
|
3879
|
-
end
|
3880
|
-
end
|
3881
|
-
ruby_19 do
|
3882
|
-
if string.encoding == Encoding::UTF_8
|
3883
|
-
string = utf8_to_16be(string)
|
3884
|
-
encoding = 1
|
3885
|
-
end
|
3832
|
+
if is_utf8?(string)
|
3833
|
+
string = utf8_to_16be(string)
|
3834
|
+
encoding = 1
|
3886
3835
|
end
|
3887
3836
|
|
3888
3837
|
length = 0x03 + string.bytesize # Length of the record data
|
@@ -4076,9 +4025,7 @@ def store_formula(formula) #:nodoc:
|
|
4076
4025
|
#
|
4077
4026
|
def repeat_formula(*args) #:nodoc:
|
4078
4027
|
# Check for a cell reference in A1 notation and substitute row and column
|
4079
|
-
|
4080
|
-
args = substitute_cellref(args)
|
4081
|
-
end
|
4028
|
+
args = row_col_notation(args)
|
4082
4029
|
|
4083
4030
|
return -1 if (args.size < 2) # Check the number of args
|
4084
4031
|
|
@@ -4132,7 +4079,7 @@ def repeat_formula(*args) #:nodoc:
|
|
4132
4079
|
0
|
4133
4080
|
end
|
4134
4081
|
|
4135
|
-
def store_formula_common(row, col, xf, value, formula)
|
4082
|
+
def store_formula_common(row, col, xf, value, formula) # :nodoc:
|
4136
4083
|
# Excel normally stores the last calculated value of the formula in $num.
|
4137
4084
|
# Clearly we are not in a position to calculate this "a priori". Instead
|
4138
4085
|
# we set $num to zero and set the option flags in $grbit to ensure
|
@@ -4251,9 +4198,7 @@ def store_formula_common(row, col, xf, value, formula)
|
|
4251
4198
|
#
|
4252
4199
|
def write_url(*args)
|
4253
4200
|
# Check for a cell reference in A1 notation and substitute row and column
|
4254
|
-
|
4255
|
-
args = substitute_cellref(*args)
|
4256
|
-
end
|
4201
|
+
args = row_col_notation(args)
|
4257
4202
|
|
4258
4203
|
# Check the number of args
|
4259
4204
|
return -1 if args.size < 3
|
@@ -4297,9 +4242,7 @@ def write_url(*args)
|
|
4297
4242
|
#
|
4298
4243
|
def write_url_range(*args)
|
4299
4244
|
# Check for a cell reference in A1 notation and substitute row and column
|
4300
|
-
|
4301
|
-
args = substitute_cellref(*args)
|
4302
|
-
end
|
4245
|
+
args = row_col_notation(args)
|
4303
4246
|
|
4304
4247
|
# Check the number of args
|
4305
4248
|
return -1 if args.size < 5
|
@@ -4320,7 +4263,7 @@ def write_url_range(*args)
|
|
4320
4263
|
|
4321
4264
|
###############################################################################
|
4322
4265
|
#
|
4323
|
-
#
|
4266
|
+
# write_url_web($row1, $col1, $row2, $col2, $url, $string, $format)
|
4324
4267
|
# row1 = $_[0]; # Start row
|
4325
4268
|
# col1 = $_[1]; # Start column
|
4326
4269
|
# row2 = $_[2]; # End row
|
@@ -4360,19 +4303,12 @@ def write_url_web(row1, col1, row2, col2, url, str = nil, format = nil) #:
|
|
4360
4303
|
encoding = 0
|
4361
4304
|
|
4362
4305
|
# Convert an Utf8 URL type and to a null terminated wchar string.
|
4363
|
-
|
4364
|
-
|
4365
|
-
|
4366
|
-
|
4367
|
-
|
4368
|
-
|
4369
|
-
end
|
4370
|
-
ruby_19 do
|
4371
|
-
if url.encoding == Encoding::UTF_8
|
4372
|
-
url = url.encode('UTF-16BE')
|
4373
|
-
url += "\0\0".force_encoding('UTF-16BE') # URL is null terminated.
|
4374
|
-
encoding = 1
|
4375
|
-
end
|
4306
|
+
if is_utf8?(url)
|
4307
|
+
url = utf8_to_16be(url)
|
4308
|
+
# URL is null terminated.
|
4309
|
+
ruby_18 { url += "\0\0" } ||
|
4310
|
+
ruby_19 { url += "\0\0".force_encoding('UTF-16BE') }
|
4311
|
+
encoding = 1
|
4376
4312
|
end
|
4377
4313
|
|
4378
4314
|
# Convert an Ascii URL type and to a null terminated wchar string.
|
@@ -4402,7 +4338,7 @@ def write_url_web(row1, col1, row2, col2, url, str = nil, format = nil) #:
|
|
4402
4338
|
|
4403
4339
|
###############################################################################
|
4404
4340
|
#
|
4405
|
-
#
|
4341
|
+
# write_url_internal($row1, $col1, $row2, $col2, $url, $string, $format)
|
4406
4342
|
# row1 = $_[0]; # Start row
|
4407
4343
|
# col1 = $_[1]; # Start column
|
4408
4344
|
# row2 = $_[2]; # End row
|
@@ -4440,21 +4376,13 @@ def write_url_internal(row1, col1, row2, col2, url, str = nil, format = nil)
|
|
4440
4376
|
encoding = 0
|
4441
4377
|
|
4442
4378
|
# Convert an Utf8 URL type and to a null terminated wchar string.
|
4443
|
-
|
4444
|
-
if
|
4445
|
-
|
4446
|
-
|
4447
|
-
|
4448
|
-
|
4449
|
-
|
4450
|
-
end
|
4451
|
-
ruby_19 do
|
4452
|
-
if str.encoding == Encoding::UTF_8
|
4453
|
-
# Quote sheet name if not already, i.e., Sheet!A1 to 'Sheet!A1'.
|
4454
|
-
url.sub!(/^(.+)!/, "'\1'!") if not url =~ /^'/;
|
4455
|
-
url = url.encode('UTF-16LE') + "\0\0".encode('UTF-16LE') # URL is null terminated.
|
4456
|
-
encoding = 1
|
4457
|
-
end
|
4379
|
+
if is_utf8?(str)
|
4380
|
+
# Quote sheet name if not already, i.e., Sheet!A1 to 'Sheet!A1'.
|
4381
|
+
url.sub!(/^(.+)!/, "'\1'!") if not url =~ /^'/;
|
4382
|
+
# URL is null terminated.
|
4383
|
+
ruby_18 { url = utf8_to_16be(url) + "\0\0" } ||
|
4384
|
+
ruby_19 { url = url.encode('UTF-16LE') + "\0\0".encode('UTF-16LE') }
|
4385
|
+
encoding = 1
|
4458
4386
|
end
|
4459
4387
|
|
4460
4388
|
# Convert an Ascii URL type and to a null terminated wchar string.
|
@@ -4482,7 +4410,7 @@ def write_url_internal(row1, col1, row2, col2, url, str = nil, format = nil)
|
|
4482
4410
|
|
4483
4411
|
###############################################################################
|
4484
4412
|
#
|
4485
|
-
#
|
4413
|
+
# write_url_external($row1, $col1, $row2, $col2, $url, $string, $format)
|
4486
4414
|
#
|
4487
4415
|
# Write links to external directory names such as 'c:\foo.xls',
|
4488
4416
|
# c:\foo.xls#Sheet1!A1', '../../foo.xls'. and '../../foo.xls#Sheet1!A1'.
|
@@ -4582,7 +4510,7 @@ def write_url_external(row1, col1, row2, col2, url, str = nil, format = nil)
|
|
4582
4510
|
|
4583
4511
|
###############################################################################
|
4584
4512
|
#
|
4585
|
-
#
|
4513
|
+
# write_url_external_net($row1, $col1, $row2, $col2, $url, $string, $format)
|
4586
4514
|
#
|
4587
4515
|
# Write links to external MS/Novell network drives and shares such as
|
4588
4516
|
# '//NETWORK/share/foo.xls' and '//NETWORK/share/foo.xls#Sheet1!A1'.
|
@@ -4648,7 +4576,7 @@ def write_url_external_net(row1, col1, row2, col2, url, str, format) #:nod
|
|
4648
4576
|
# parameters accordingly.
|
4649
4577
|
# Split the dir name and sheet name (if it exists)
|
4650
4578
|
#
|
4651
|
-
def analyze_link(url, absolute = nil)
|
4579
|
+
def analyze_link(url, absolute = nil) # :nodoc:
|
4652
4580
|
dir_long , sheet = url.split(/\#/)
|
4653
4581
|
link_type = absolute ? (0x01 | absolute) : 0x0103
|
4654
4582
|
|
@@ -4716,9 +4644,7 @@ def analyze_link(url, absolute = nil)
|
|
4716
4644
|
#
|
4717
4645
|
def write_date_time(*args)
|
4718
4646
|
# Check for a cell reference in A1 notation and substitute row and column
|
4719
|
-
|
4720
|
-
args = substitute_cellref(*args)
|
4721
|
-
end
|
4647
|
+
args = row_col_notation(args)
|
4722
4648
|
|
4723
4649
|
return -1 if (args.size < 3) # Check the number of args
|
4724
4650
|
|
@@ -4863,7 +4789,7 @@ def convert_date_time(date_time_string) #:nodoc:
|
|
4863
4789
|
|
4864
4790
|
###############################################################################
|
4865
4791
|
#
|
4866
|
-
#
|
4792
|
+
# write_row_default()
|
4867
4793
|
# row : Row Number
|
4868
4794
|
# colMic : First defined column
|
4869
4795
|
# colMac : Last defined column
|
@@ -4889,10 +4815,10 @@ def write_row_default(row, colMic, colMac) #:nodoc:
|
|
4889
4815
|
|
4890
4816
|
###############################################################################
|
4891
4817
|
#
|
4892
|
-
#
|
4818
|
+
# check_dimensions($row, $col, $ignore_row, $ignore_col)
|
4893
4819
|
#
|
4894
4820
|
# Check that $row and $col are valid and store max and min values for use in
|
4895
|
-
# DIMENSIONS record. See,
|
4821
|
+
# DIMENSIONS record. See, store_dimensions().
|
4896
4822
|
#
|
4897
4823
|
# The $ignore_row/$ignore_col flags is used to indicate that we wish to
|
4898
4824
|
# perform the dimension check without storing the value.
|
@@ -4932,14 +4858,14 @@ def check_dimensions(row, col, ignore_row = 0, ignore_col = 0) #:nodoc:
|
|
4932
4858
|
|
4933
4859
|
###############################################################################
|
4934
4860
|
#
|
4935
|
-
#
|
4861
|
+
# store_dimensions()
|
4936
4862
|
#
|
4937
4863
|
# Writes Excel DIMENSIONS to define the area in which there is cell data.
|
4938
4864
|
#
|
4939
4865
|
# Notes:
|
4940
4866
|
# Excel stores the max row/col as row/col +1.
|
4941
4867
|
# Max and min values of 0 are used to indicate that no cell data.
|
4942
|
-
# We set the undef member data to 0 since it is used by
|
4868
|
+
# We set the undef member data to 0 since it is used by store_table().
|
4943
4869
|
# Inserting images or charts doesn't change the DIMENSION data.
|
4944
4870
|
#
|
4945
4871
|
def store_dimensions #:nodoc:
|
@@ -4952,7 +4878,7 @@ def store_dimensions #:nodoc:
|
|
4952
4878
|
col_min = @dim_colmin.nil? ? 0 : @dim_colmin
|
4953
4879
|
col_max = @dim_colmax.nil? ? 0 : @dim_colmax + 1
|
4954
4880
|
|
4955
|
-
# Set member data to the new max/min value for use by
|
4881
|
+
# Set member data to the new max/min value for use by store_table().
|
4956
4882
|
@dim_rowmin = row_min
|
4957
4883
|
@dim_rowmax = row_max
|
4958
4884
|
@dim_colmin = col_min
|
@@ -4968,7 +4894,7 @@ def store_dimensions #:nodoc:
|
|
4968
4894
|
|
4969
4895
|
###############################################################################
|
4970
4896
|
#
|
4971
|
-
#
|
4897
|
+
# store_window2()
|
4972
4898
|
#
|
4973
4899
|
# Write BIFF record Window2.
|
4974
4900
|
#
|
@@ -5022,7 +4948,7 @@ def store_window2 #:nodoc:
|
|
5022
4948
|
|
5023
4949
|
###############################################################################
|
5024
4950
|
#
|
5025
|
-
#
|
4951
|
+
# store_page_view()
|
5026
4952
|
#
|
5027
4953
|
# Set page view mode. Only applicable to Mac Excel.
|
5028
4954
|
#
|
@@ -5035,7 +4961,7 @@ def store_page_view #:nodoc:
|
|
5035
4961
|
|
5036
4962
|
###############################################################################
|
5037
4963
|
#
|
5038
|
-
#
|
4964
|
+
# store_tab_color()
|
5039
4965
|
#
|
5040
4966
|
# Write the Tab Color BIFF record.
|
5041
4967
|
#
|
@@ -5057,7 +4983,7 @@ def store_tab_color #:nodoc:
|
|
5057
4983
|
|
5058
4984
|
###############################################################################
|
5059
4985
|
#
|
5060
|
-
#
|
4986
|
+
# store_defrow()
|
5061
4987
|
#
|
5062
4988
|
# Write BIFF record DEFROWHEIGHT.
|
5063
4989
|
#
|
@@ -5077,7 +5003,7 @@ def store_defrow #:nodoc:
|
|
5077
5003
|
|
5078
5004
|
###############################################################################
|
5079
5005
|
#
|
5080
|
-
#
|
5006
|
+
# store_defcol()
|
5081
5007
|
#
|
5082
5008
|
# Write BIFF record DEFCOLWIDTH.
|
5083
5009
|
#
|
@@ -5095,7 +5021,7 @@ def store_defcol #:nodoc:
|
|
5095
5021
|
|
5096
5022
|
###############################################################################
|
5097
5023
|
#
|
5098
|
-
#
|
5024
|
+
# store_colinfo($firstcol, $lastcol, $width, $format, $hidden)
|
5099
5025
|
#
|
5100
5026
|
# firstcol : First formatted column
|
5101
5027
|
# lastcol : Last formatted column
|
@@ -5155,7 +5081,7 @@ def store_colinfo(firstcol=0, lastcol=0, width=8.43, format=nil, hidden=0, level
|
|
5155
5081
|
|
5156
5082
|
###############################################################################
|
5157
5083
|
#
|
5158
|
-
#
|
5084
|
+
# store_filtermode()
|
5159
5085
|
#
|
5160
5086
|
# Write BIFF record FILTERMODE to indicate that the worksheet contains
|
5161
5087
|
# AUTOFILTER record, ie. autofilters with a filter set.
|
@@ -5175,7 +5101,7 @@ def store_filtermode #:nodoc:
|
|
5175
5101
|
|
5176
5102
|
###############################################################################
|
5177
5103
|
#
|
5178
|
-
#
|
5104
|
+
# store_autofilterinfo()
|
5179
5105
|
#
|
5180
5106
|
# Write BIFF record AUTOFILTERINFO.
|
5181
5107
|
#
|
@@ -5196,7 +5122,7 @@ def store_autofilterinfo #:nodoc:
|
|
5196
5122
|
|
5197
5123
|
###############################################################################
|
5198
5124
|
#
|
5199
|
-
#
|
5125
|
+
# store_selection($first_row, $first_col, $last_row, $last_col)
|
5200
5126
|
#
|
5201
5127
|
# Write BIFF record SELECTION.
|
5202
5128
|
#
|
@@ -5238,7 +5164,7 @@ def store_selection(first_row=0, first_col=0, last_row = nil, last_col =nil) #
|
|
5238
5164
|
|
5239
5165
|
###############################################################################
|
5240
5166
|
#
|
5241
|
-
#
|
5167
|
+
# store_externcount($count)
|
5242
5168
|
#
|
5243
5169
|
# Write BIFF record EXTERNCOUNT to indicate the number of external sheet
|
5244
5170
|
# references in a worksheet.
|
@@ -5264,7 +5190,7 @@ def store_externcount(count) #:nodoc:
|
|
5264
5190
|
|
5265
5191
|
###############################################################################
|
5266
5192
|
#
|
5267
|
-
#
|
5193
|
+
# store_externsheet($sheetname)
|
5268
5194
|
# sheetname : Worksheet name
|
5269
5195
|
#
|
5270
5196
|
# Writes the Excel BIFF EXTERNSHEET record. These references are used by
|
@@ -5302,7 +5228,7 @@ def store_externsheet(sheetname) #:nodoc:
|
|
5302
5228
|
|
5303
5229
|
###############################################################################
|
5304
5230
|
#
|
5305
|
-
#
|
5231
|
+
# store_panes(y, x, colLeft, no_split, pnnAct)
|
5306
5232
|
# y = args[0] || 0 # Vertical split position
|
5307
5233
|
# x = $_[1] || 0; # Horizontal split position
|
5308
5234
|
# rwTop = $_[2]; # Top row visible
|
@@ -5350,7 +5276,7 @@ def store_panes(y=0, x=0, rwtop=nil, colleft=nil, no_split=nil, pnnAct=nil) #
|
|
5350
5276
|
pnnAct = 3 if (x == 0 && y == 0) # Top left
|
5351
5277
|
end
|
5352
5278
|
|
5353
|
-
@active_pane = pnnAct # Used in
|
5279
|
+
@active_pane = pnnAct # Used in store_selection
|
5354
5280
|
|
5355
5281
|
store_simple(record, length, x, y, rwtop, colleft, pnnAct)
|
5356
5282
|
end
|
@@ -5358,7 +5284,7 @@ def store_panes(y=0, x=0, rwtop=nil, colleft=nil, no_split=nil, pnnAct=nil) #
|
|
5358
5284
|
|
5359
5285
|
###############################################################################
|
5360
5286
|
#
|
5361
|
-
#
|
5287
|
+
# store_setup()
|
5362
5288
|
#
|
5363
5289
|
# Store the page setup SETUP BIFF record.
|
5364
5290
|
#
|
@@ -5419,7 +5345,7 @@ def store_setup #:nodoc:
|
|
5419
5345
|
|
5420
5346
|
###############################################################################
|
5421
5347
|
#
|
5422
|
-
#
|
5348
|
+
# store_header()
|
5423
5349
|
#
|
5424
5350
|
# Store the header caption BIFF record.
|
5425
5351
|
#
|
@@ -5430,7 +5356,7 @@ def store_header #:nodoc:
|
|
5430
5356
|
|
5431
5357
|
###############################################################################
|
5432
5358
|
#
|
5433
|
-
#
|
5359
|
+
# store_footer()
|
5434
5360
|
#
|
5435
5361
|
# Store the footer caption BIFF record.
|
5436
5362
|
#
|
@@ -5442,7 +5368,7 @@ def store_footer #:nodoc:
|
|
5442
5368
|
#
|
5443
5369
|
# type : :header / :footer
|
5444
5370
|
#
|
5445
|
-
def store_header_footer_common(type)
|
5371
|
+
def store_header_footer_common(type) # :nodoc:
|
5446
5372
|
if type == :header
|
5447
5373
|
record = 0x0014
|
5448
5374
|
str = @header
|
@@ -5471,7 +5397,7 @@ def store_header_footer_common(type)
|
|
5471
5397
|
|
5472
5398
|
###############################################################################
|
5473
5399
|
#
|
5474
|
-
#
|
5400
|
+
# store_hcenter()
|
5475
5401
|
#
|
5476
5402
|
# Store the horizontal centering HCENTER BIFF record.
|
5477
5403
|
#
|
@@ -5482,7 +5408,7 @@ def store_hcenter #:nodoc:
|
|
5482
5408
|
|
5483
5409
|
###############################################################################
|
5484
5410
|
#
|
5485
|
-
#
|
5411
|
+
# store_vcenter()
|
5486
5412
|
#
|
5487
5413
|
# Store the vertical centering VCENTER BIFF record.
|
5488
5414
|
#
|
@@ -5493,7 +5419,7 @@ def store_vcenter #:nodoc:
|
|
5493
5419
|
|
5494
5420
|
###############################################################################
|
5495
5421
|
#
|
5496
|
-
#
|
5422
|
+
# store_margin_left()
|
5497
5423
|
#
|
5498
5424
|
# Store the LEFTMARGIN BIFF record.
|
5499
5425
|
#
|
@@ -5504,7 +5430,7 @@ def store_margin_left #:nodoc:
|
|
5504
5430
|
|
5505
5431
|
###############################################################################
|
5506
5432
|
#
|
5507
|
-
#
|
5433
|
+
# store_margin_right()
|
5508
5434
|
#
|
5509
5435
|
# Store the RIGHTMARGIN BIFF record.
|
5510
5436
|
#
|
@@ -5515,7 +5441,7 @@ def store_margin_right #:nodoc:
|
|
5515
5441
|
|
5516
5442
|
###############################################################################
|
5517
5443
|
#
|
5518
|
-
#
|
5444
|
+
# store_margin_top()
|
5519
5445
|
#
|
5520
5446
|
# Store the TOPMARGIN BIFF record.
|
5521
5447
|
#
|
@@ -5526,7 +5452,7 @@ def store_margin_top #:nodoc:
|
|
5526
5452
|
|
5527
5453
|
###############################################################################
|
5528
5454
|
#
|
5529
|
-
#
|
5455
|
+
# store_margin_bottom()
|
5530
5456
|
#
|
5531
5457
|
# Store the BOTTOMMARGIN BIFF record.
|
5532
5458
|
#
|
@@ -5540,7 +5466,7 @@ def store_margin_bottom #:nodoc:
|
|
5540
5466
|
# length : bytes to follow
|
5541
5467
|
# margin : Margin in inches
|
5542
5468
|
#
|
5543
|
-
def store_margin_common(record, length, margin)
|
5469
|
+
def store_margin_common(record, length, margin) # :nodoc:
|
5544
5470
|
header = [record, length].pack('vv')
|
5545
5471
|
data = [margin].pack('d')
|
5546
5472
|
|
@@ -5559,9 +5485,7 @@ def store_margin_common(record, length, margin)
|
|
5559
5485
|
#
|
5560
5486
|
def merge_cells(*args) #:nodoc:
|
5561
5487
|
# Check for a cell reference in A1 notation and substitute row and column
|
5562
|
-
|
5563
|
-
args = substitute_cellref(*args)
|
5564
|
-
end
|
5488
|
+
args = row_col_notation(args)
|
5565
5489
|
|
5566
5490
|
record = 0x00E5 # Record identifier
|
5567
5491
|
length = 0x000A # Bytes to follow
|
@@ -5584,7 +5508,7 @@ def merge_cells(*args) #:nodoc:
|
|
5584
5508
|
|
5585
5509
|
###############################################################################
|
5586
5510
|
#
|
5587
|
-
#
|
5511
|
+
# store_print_headers()
|
5588
5512
|
#
|
5589
5513
|
# Write the PRINTHEADERS BIFF record.
|
5590
5514
|
#
|
@@ -5595,7 +5519,7 @@ def store_print_headers #:nodoc:
|
|
5595
5519
|
|
5596
5520
|
###############################################################################
|
5597
5521
|
#
|
5598
|
-
#
|
5522
|
+
# store_print_gridlines()
|
5599
5523
|
#
|
5600
5524
|
# Write the PRINTGRIDLINES BIFF record. Must be used in conjunction with the
|
5601
5525
|
# GRIDSET record.
|
@@ -5605,7 +5529,7 @@ def store_print_gridlines #:nodoc:
|
|
5605
5529
|
end
|
5606
5530
|
private :store_print_gridlines
|
5607
5531
|
|
5608
|
-
def store_biff_common(type)
|
5532
|
+
def store_biff_common(type) # :nodoc:
|
5609
5533
|
case type
|
5610
5534
|
when :hcenter
|
5611
5535
|
record = 0x0083
|
@@ -5631,7 +5555,7 @@ def store_biff_common(type)
|
|
5631
5555
|
|
5632
5556
|
###############################################################################
|
5633
5557
|
#
|
5634
|
-
#
|
5558
|
+
# store_gridset()
|
5635
5559
|
#
|
5636
5560
|
# Write the GRIDSET BIFF record. Must be used in conjunction with the
|
5637
5561
|
# PRINTGRIDLINES record.
|
@@ -5651,11 +5575,11 @@ def store_gridset #:nodoc:
|
|
5651
5575
|
|
5652
5576
|
###############################################################################
|
5653
5577
|
#
|
5654
|
-
#
|
5578
|
+
# store_guts()
|
5655
5579
|
#
|
5656
5580
|
# Write the GUTS BIFF record. This is used to configure the gutter margins
|
5657
5581
|
# where Excel outline symbols are displayed. The visibility of the gutters is
|
5658
|
-
# controlled by a flag in WSBOOL. See also
|
5582
|
+
# controlled by a flag in WSBOOL. See also store_wsbool().
|
5659
5583
|
#
|
5660
5584
|
# We are all in the gutter but some of us are looking at the stars.
|
5661
5585
|
#
|
@@ -5696,7 +5620,7 @@ def store_guts #:nodoc:
|
|
5696
5620
|
|
5697
5621
|
###############################################################################
|
5698
5622
|
#
|
5699
|
-
#
|
5623
|
+
# store_wsbool()
|
5700
5624
|
#
|
5701
5625
|
# Write the WSBOOL BIFF record, mainly for fit-to-page. Used in conjunction
|
5702
5626
|
# with the SETUP record.
|
@@ -5724,7 +5648,7 @@ def store_wsbool #:nodoc:
|
|
5724
5648
|
|
5725
5649
|
###############################################################################
|
5726
5650
|
#
|
5727
|
-
#
|
5651
|
+
# store_hbreak()
|
5728
5652
|
#
|
5729
5653
|
# Write the HORIZONTALPAGEBREAKS BIFF record.
|
5730
5654
|
#
|
@@ -5735,7 +5659,7 @@ def store_hbreak #:nodoc:
|
|
5735
5659
|
|
5736
5660
|
###############################################################################
|
5737
5661
|
#
|
5738
|
-
#
|
5662
|
+
# store_vbreak()
|
5739
5663
|
#
|
5740
5664
|
# Write the VERTICALPAGEBREAKS BIFF record.
|
5741
5665
|
#
|
@@ -5744,7 +5668,7 @@ def store_vbreak #:nodoc:
|
|
5744
5668
|
end
|
5745
5669
|
private :store_vbreak
|
5746
5670
|
|
5747
|
-
def store_breaks_common(breaks)
|
5671
|
+
def store_breaks_common(breaks) # :nodoc:
|
5748
5672
|
unless breaks.empty?
|
5749
5673
|
record = breaks == @vbreaks ? 0x001a : 0x001b # Record identifier
|
5750
5674
|
cbrk = breaks.size # Number of page breaks
|
@@ -5765,7 +5689,7 @@ def store_breaks_common(breaks)
|
|
5765
5689
|
|
5766
5690
|
###############################################################################
|
5767
5691
|
#
|
5768
|
-
#
|
5692
|
+
# store_protect()
|
5769
5693
|
#
|
5770
5694
|
# Set the Biff PROTECT record to indicate that the worksheet is protected.
|
5771
5695
|
#
|
@@ -5776,7 +5700,7 @@ def store_protect #:nodoc:
|
|
5776
5700
|
|
5777
5701
|
###############################################################################
|
5778
5702
|
#
|
5779
|
-
#
|
5703
|
+
# store_obj_protect()
|
5780
5704
|
#
|
5781
5705
|
# Set the Biff OBJPROTECT record to indicate that objects are protected.
|
5782
5706
|
#
|
@@ -5785,7 +5709,7 @@ def store_obj_protect #:nodoc:
|
|
5785
5709
|
end
|
5786
5710
|
private :store_obj_protect
|
5787
5711
|
|
5788
|
-
def store_protect_common(type = nil)
|
5712
|
+
def store_protect_common(type = nil) # :nodoc:
|
5789
5713
|
if @protect != 0
|
5790
5714
|
record = if type == :obj # Record identifier
|
5791
5715
|
0x0063 # store_obj_protect
|
@@ -5807,7 +5731,7 @@ def store_protect_common(type = nil)
|
|
5807
5731
|
|
5808
5732
|
###############################################################################
|
5809
5733
|
#
|
5810
|
-
#
|
5734
|
+
# store_password()
|
5811
5735
|
#
|
5812
5736
|
# Write the worksheet PASSWORD record.
|
5813
5737
|
#
|
@@ -5849,7 +5773,7 @@ def store_password #:nodoc:
|
|
5849
5773
|
|
5850
5774
|
###############################################################################
|
5851
5775
|
#
|
5852
|
-
#
|
5776
|
+
# store_table()
|
5853
5777
|
#
|
5854
5778
|
# Write cell data stored in the worksheet row/col table.
|
5855
5779
|
#
|
@@ -5942,9 +5866,9 @@ def store_table #:nodoc:
|
|
5942
5866
|
|
5943
5867
|
###############################################################################
|
5944
5868
|
#
|
5945
|
-
#
|
5869
|
+
# store_dbcell()
|
5946
5870
|
#
|
5947
|
-
# Store the DBCELL record using the offset calculated in
|
5871
|
+
# Store the DBCELL record using the offset calculated in store_table().
|
5948
5872
|
#
|
5949
5873
|
# This is only used when compatibity_mode() is in operation.
|
5950
5874
|
#
|
@@ -5964,9 +5888,9 @@ def store_dbcell(row_offset, cell_offsets) #:nodoc:
|
|
5964
5888
|
|
5965
5889
|
###############################################################################
|
5966
5890
|
#
|
5967
|
-
#
|
5891
|
+
# store_index()
|
5968
5892
|
#
|
5969
|
-
# Store the INDEX record using the DBCELL offsets calculated in
|
5893
|
+
# Store the INDEX record using the DBCELL offsets calculated in store_table().
|
5970
5894
|
#
|
5971
5895
|
# This is only used when compatibity_mode() is in operation.
|
5972
5896
|
#
|
@@ -6047,9 +5971,7 @@ def store_index #:nodoc:
|
|
6047
5971
|
#
|
6048
5972
|
def insert_chart(*args)
|
6049
5973
|
# Check for a cell reference in A1 notation and substitute row and column
|
6050
|
-
|
6051
|
-
args = substitute_cellref(*args)
|
6052
|
-
end
|
5974
|
+
args = row_col_notation(args)
|
6053
5975
|
|
6054
5976
|
row = args[0]
|
6055
5977
|
col = args[1]
|
@@ -6132,9 +6054,7 @@ def insert_chart(*args)
|
|
6132
6054
|
#
|
6133
6055
|
def insert_image(*args)
|
6134
6056
|
# Check for a cell reference in A1 notation and substitute row and column
|
6135
|
-
|
6136
|
-
args = substitute_cellref(*args)
|
6137
|
-
end
|
6057
|
+
args = row_col_notation(args)
|
6138
6058
|
|
6139
6059
|
row = args[0]
|
6140
6060
|
col = args[1]
|
@@ -6159,7 +6079,7 @@ def insert_image(*args)
|
|
6159
6079
|
|
6160
6080
|
###############################################################################
|
6161
6081
|
#
|
6162
|
-
#
|
6082
|
+
# position_object()
|
6163
6083
|
#
|
6164
6084
|
# Calculate the vertices that define the position of a graphical object within
|
6165
6085
|
# the worksheet.
|
@@ -6267,7 +6187,7 @@ def position_object(col_start, row_start, x1, y1, width, height) #:nodoc:
|
|
6267
6187
|
]
|
6268
6188
|
end
|
6269
6189
|
|
6270
|
-
def adjust_col_position(x, col)
|
6190
|
+
def adjust_col_position(x, col) # :nodoc:
|
6271
6191
|
while x >= size_col(col)
|
6272
6192
|
x -= size_col(col)
|
6273
6193
|
col += 1
|
@@ -6276,7 +6196,7 @@ def adjust_col_position(x, col)
|
|
6276
6196
|
end
|
6277
6197
|
private :adjust_col_position
|
6278
6198
|
|
6279
|
-
def adjust_row_position(y, row)
|
6199
|
+
def adjust_row_position(y, row) # :nodoc:
|
6280
6200
|
while y >= size_row(row)
|
6281
6201
|
y -= size_row(row)
|
6282
6202
|
row += 1
|
@@ -6287,7 +6207,7 @@ def adjust_row_position(y, row)
|
|
6287
6207
|
|
6288
6208
|
###############################################################################
|
6289
6209
|
#
|
6290
|
-
#
|
6210
|
+
# size_col($col)
|
6291
6211
|
#
|
6292
6212
|
# Convert the width of a cell from user's units to pixels. Excel rounds the
|
6293
6213
|
# column width to the nearest pixel. If the width hasn't been set by the user
|
@@ -6312,7 +6232,7 @@ def size_col(col) #:nodoc:
|
|
6312
6232
|
|
6313
6233
|
###############################################################################
|
6314
6234
|
#
|
6315
|
-
#
|
6235
|
+
# size_row($row)
|
6316
6236
|
#
|
6317
6237
|
# Convert the height of a cell from user's units to pixels. By interpolation
|
6318
6238
|
# the relationship is: y = 4/3x. If the height hasn't been set by the user we
|
@@ -6335,7 +6255,7 @@ def size_row(row) #:nodoc:
|
|
6335
6255
|
|
6336
6256
|
###############################################################################
|
6337
6257
|
#
|
6338
|
-
#
|
6258
|
+
# store_zoom($zoom)
|
6339
6259
|
#
|
6340
6260
|
#
|
6341
6261
|
# Store the window zoom factor. This should be a reduced fraction but for
|
@@ -6365,9 +6285,7 @@ def store_zoom #:nodoc:
|
|
6365
6285
|
#
|
6366
6286
|
def write_utf16be_string(*args)
|
6367
6287
|
# Check for a cell reference in A1 notation and substitute row and column
|
6368
|
-
|
6369
|
-
args = substitute_cellref(*args)
|
6370
|
-
end
|
6288
|
+
args = row_col_notation(args)
|
6371
6289
|
|
6372
6290
|
return -1 if (args.size < 3) # Check the number of args
|
6373
6291
|
|
@@ -6433,9 +6351,7 @@ def write_utf16be_string(*args)
|
|
6433
6351
|
#
|
6434
6352
|
def write_utf16le_string(*args)
|
6435
6353
|
# Check for a cell reference in A1 notation and substitute row and column
|
6436
|
-
|
6437
|
-
args = substitute_cellref(*args)
|
6438
|
-
end
|
6354
|
+
args = row_col_notation(args)
|
6439
6355
|
|
6440
6356
|
return -1 if (args.size < 3) # Check the number of args
|
6441
6357
|
|
@@ -6460,7 +6376,7 @@ def write_utf16le_string(*args)
|
|
6460
6376
|
|
6461
6377
|
###############################################################################
|
6462
6378
|
#
|
6463
|
-
#
|
6379
|
+
# store_autofilters()
|
6464
6380
|
#
|
6465
6381
|
# Function to iterate through the columns that form part of an autofilter
|
6466
6382
|
# range and write Biff AUTOFILTER records if a filter expression has been set.
|
@@ -6487,7 +6403,7 @@ def store_autofilters #:nodoc:
|
|
6487
6403
|
|
6488
6404
|
###############################################################################
|
6489
6405
|
#
|
6490
|
-
#
|
6406
|
+
# store_autofilter()
|
6491
6407
|
# my $index = $_[0];
|
6492
6408
|
# my $operator_1 = $_[1];
|
6493
6409
|
# my $token_1 = $_[2];
|
@@ -6520,7 +6436,7 @@ def store_autofilter(index, operator_1, token_1, #:nodoc:
|
|
6520
6436
|
optimised_1 = 1 if operator_1 == 2
|
6521
6437
|
optimised_2 = 1 if !operator_2.nil? and operator_2 == 2
|
6522
6438
|
|
6523
|
-
# Convert non-simple equalities back to type 2. See
|
6439
|
+
# Convert non-simple equalities back to type 2. See parse_filter_tokens().
|
6524
6440
|
operator_1 = 2 if operator_1 == 22
|
6525
6441
|
operator_2 = 2 if !operator_2.nil? and operator_2 == 22
|
6526
6442
|
|
@@ -6579,7 +6495,7 @@ def store_autofilter(index, operator_1, token_1, #:nodoc:
|
|
6579
6495
|
|
6580
6496
|
###############################################################################
|
6581
6497
|
#
|
6582
|
-
#
|
6498
|
+
# pack_doper()
|
6583
6499
|
#
|
6584
6500
|
# Create a Biff Doper structure that represents a filter expression. Depending
|
6585
6501
|
# on the type of the token we pack an Empty, String or Number doper.
|
@@ -6605,17 +6521,9 @@ def pack_doper(operator, token) #:nodoc:
|
|
6605
6521
|
length = string.bytesize
|
6606
6522
|
|
6607
6523
|
# Handle utf8 strings
|
6608
|
-
|
6609
|
-
|
6610
|
-
|
6611
|
-
encodign = 1
|
6612
|
-
end
|
6613
|
-
end
|
6614
|
-
ruby_19 do
|
6615
|
-
if string.encoding == Encoding::UTF_8
|
6616
|
-
string = utf8_to_16be(string)
|
6617
|
-
encodign = 1
|
6618
|
-
end
|
6524
|
+
if is_utf8?(string)
|
6525
|
+
string = utf8_to_16be(string)
|
6526
|
+
encodign = 1
|
6619
6527
|
end
|
6620
6528
|
|
6621
6529
|
string =
|
@@ -6633,7 +6541,7 @@ def pack_doper(operator, token) #:nodoc:
|
|
6633
6541
|
|
6634
6542
|
###############################################################################
|
6635
6543
|
#
|
6636
|
-
#
|
6544
|
+
# pack_unused_doper()
|
6637
6545
|
#
|
6638
6546
|
# Pack an empty Doper structure.
|
6639
6547
|
#
|
@@ -6644,7 +6552,7 @@ def pack_unused_doper #:nodoc:
|
|
6644
6552
|
|
6645
6553
|
###############################################################################
|
6646
6554
|
#
|
6647
|
-
#
|
6555
|
+
# pack_blanks_doper()
|
6648
6556
|
#
|
6649
6557
|
# Pack an Blanks/NonBlanks Doper structure.
|
6650
6558
|
#
|
@@ -6666,7 +6574,7 @@ def pack_blanks_doper(operator, token) #:nodoc:
|
|
6666
6574
|
|
6667
6575
|
###############################################################################
|
6668
6576
|
#
|
6669
|
-
#
|
6577
|
+
# pack_string_doper()
|
6670
6578
|
#
|
6671
6579
|
# Pack an string Doper structure.
|
6672
6580
|
#
|
@@ -6682,7 +6590,7 @@ def pack_string_doper(operator, length) #:nodoc:
|
|
6682
6590
|
|
6683
6591
|
###############################################################################
|
6684
6592
|
#
|
6685
|
-
#
|
6593
|
+
# pack_number_doper()
|
6686
6594
|
#
|
6687
6595
|
# Pack an IEEE double number Doper structure.
|
6688
6596
|
#
|
@@ -6701,7 +6609,7 @@ def pack_number_doper(operator, number) #:nodoc:
|
|
6701
6609
|
|
6702
6610
|
###############################################################################
|
6703
6611
|
#
|
6704
|
-
#
|
6612
|
+
# prepare_images()
|
6705
6613
|
#
|
6706
6614
|
# Turn the HoH that stores the images into an array for easier handling.
|
6707
6615
|
#
|
@@ -6712,7 +6620,7 @@ def prepare_images #:nodoc:
|
|
6712
6620
|
|
6713
6621
|
###############################################################################
|
6714
6622
|
#
|
6715
|
-
#
|
6623
|
+
# prepare_comments()
|
6716
6624
|
#
|
6717
6625
|
# Turn the HoH that stores the comments into an array for easier handling.
|
6718
6626
|
#
|
@@ -6723,7 +6631,7 @@ def prepare_comments #:nodoc:
|
|
6723
6631
|
|
6724
6632
|
###############################################################################
|
6725
6633
|
#
|
6726
|
-
#
|
6634
|
+
# prepare_charts()
|
6727
6635
|
#
|
6728
6636
|
# Turn the HoH that stores the charts into an array for easier handling.
|
6729
6637
|
#
|
@@ -6732,7 +6640,7 @@ def prepare_charts #:nodoc:
|
|
6732
6640
|
end
|
6733
6641
|
# private :prepare_charts
|
6734
6642
|
|
6735
|
-
def prepare_common(param)
|
6643
|
+
def prepare_common(param) # :nodoc:
|
6736
6644
|
hash = {
|
6737
6645
|
:images => @images, :comments => @comments, :charts => @charts
|
6738
6646
|
}[param]
|
@@ -6768,7 +6676,7 @@ def prepare_common(param)
|
|
6768
6676
|
|
6769
6677
|
###############################################################################
|
6770
6678
|
#
|
6771
|
-
#
|
6679
|
+
# store_images()
|
6772
6680
|
#
|
6773
6681
|
# Store the collections of records that make up images.
|
6774
6682
|
#
|
@@ -6853,7 +6761,7 @@ def store_images #:nodoc:
|
|
6853
6761
|
end
|
6854
6762
|
private :store_images
|
6855
6763
|
|
6856
|
-
def store_parent_mso_record(dg_length, ids, spgr_length, spid)
|
6764
|
+
def store_parent_mso_record(dg_length, ids, spgr_length, spid) # :nodoc:
|
6857
6765
|
store_mso_dg_container(dg_length) +
|
6858
6766
|
store_mso_dg(*ids) +
|
6859
6767
|
store_mso_spgr_container(spgr_length) +
|
@@ -6863,7 +6771,7 @@ def store_parent_mso_record(dg_length, ids, spgr_length, spid)
|
|
6863
6771
|
end
|
6864
6772
|
private :store_parent_mso_record
|
6865
6773
|
|
6866
|
-
def store_child_mso_record(spid, *vertices)
|
6774
|
+
def store_child_mso_record(spid, *vertices) # :nodoc:
|
6867
6775
|
store_mso_sp_container(88) +
|
6868
6776
|
store_mso_sp(201, spid, 0x0A00) +
|
6869
6777
|
store_mso_opt_filter +
|
@@ -6874,7 +6782,7 @@ def store_child_mso_record(spid, *vertices)
|
|
6874
6782
|
|
6875
6783
|
###############################################################################
|
6876
6784
|
#
|
6877
|
-
#
|
6785
|
+
# store_charts()
|
6878
6786
|
#
|
6879
6787
|
# Store the collections of records that make up charts.
|
6880
6788
|
#
|
@@ -6963,12 +6871,12 @@ def store_charts #:nodoc:
|
|
6963
6871
|
end
|
6964
6872
|
private :store_charts
|
6965
6873
|
|
6966
|
-
def store_mso_sp_container_sp(spid)
|
6874
|
+
def store_mso_sp_container_sp(spid) # :nodoc:
|
6967
6875
|
store_mso_sp_container(112) + store_mso_sp(201, spid, 0x0A00)
|
6968
6876
|
end
|
6969
6877
|
private :store_mso_sp_container_sp
|
6970
6878
|
|
6971
|
-
def store_mso_opt_chart_client_anchor_client_data(*vertices)
|
6879
|
+
def store_mso_opt_chart_client_anchor_client_data(*vertices) # :nodoc:
|
6972
6880
|
store_mso_opt_chart +
|
6973
6881
|
store_mso_client_anchor(0, *vertices) +
|
6974
6882
|
store_mso_client_data
|
@@ -6977,7 +6885,7 @@ def store_mso_opt_chart_client_anchor_client_data(*vertices)
|
|
6977
6885
|
|
6978
6886
|
###############################################################################
|
6979
6887
|
#
|
6980
|
-
#
|
6888
|
+
# store_chart_binary
|
6981
6889
|
#
|
6982
6890
|
# Add the binary data for a chart. This could either be from a Chart object
|
6983
6891
|
# or from an external binary file (for backwards compatibility).
|
@@ -6999,7 +6907,7 @@ def store_chart_binary(chart) #:nodoc:
|
|
6999
6907
|
|
7000
6908
|
###############################################################################
|
7001
6909
|
#
|
7002
|
-
#
|
6910
|
+
# store_filters()
|
7003
6911
|
#
|
7004
6912
|
# Store the collections of records that make up filters.
|
7005
6913
|
#
|
@@ -7064,14 +6972,14 @@ def store_filters #:nodoc:
|
|
7064
6972
|
end
|
7065
6973
|
private :store_filters
|
7066
6974
|
|
7067
|
-
def unpack_record(data)
|
6975
|
+
def unpack_record(data) # :nodoc:
|
7068
6976
|
data.unpack('C*').map! {|c| sprintf("%02X", c) }.join(' ')
|
7069
6977
|
end
|
7070
6978
|
private :unpack_record
|
7071
6979
|
|
7072
6980
|
###############################################################################
|
7073
6981
|
#
|
7074
|
-
#
|
6982
|
+
# store_comments()
|
7075
6983
|
#
|
7076
6984
|
# Store the collections of records that make up cell comments.
|
7077
6985
|
#
|
@@ -7151,7 +7059,7 @@ def store_comments #:nodoc:
|
|
7151
7059
|
|
7152
7060
|
###############################################################################
|
7153
7061
|
#
|
7154
|
-
#
|
7062
|
+
# store_mso_dg_container()
|
7155
7063
|
#
|
7156
7064
|
# Write the Escher DgContainer record that is part of MSODRAWING.
|
7157
7065
|
#
|
@@ -7166,7 +7074,7 @@ def store_mso_dg_container(length) #:nodoc:
|
|
7166
7074
|
|
7167
7075
|
###############################################################################
|
7168
7076
|
#
|
7169
|
-
#
|
7077
|
+
# store_mso_dg()
|
7170
7078
|
#
|
7171
7079
|
# Write the Escher Dg record that is part of MSODRAWING.
|
7172
7080
|
#
|
@@ -7182,7 +7090,7 @@ def store_mso_dg(instance, num_shapes, max_spid) #:nodoc:
|
|
7182
7090
|
|
7183
7091
|
###############################################################################
|
7184
7092
|
#
|
7185
|
-
#
|
7093
|
+
# store_mso_spgr_container()
|
7186
7094
|
#
|
7187
7095
|
# Write the Escher SpgrContainer record that is part of MSODRAWING.
|
7188
7096
|
#
|
@@ -7198,7 +7106,7 @@ def store_mso_spgr_container(length) #:nodoc:
|
|
7198
7106
|
|
7199
7107
|
###############################################################################
|
7200
7108
|
#
|
7201
|
-
#
|
7109
|
+
# store_mso_sp_container()
|
7202
7110
|
#
|
7203
7111
|
# Write the Escher SpContainer record that is part of MSODRAWING.
|
7204
7112
|
#
|
@@ -7214,7 +7122,7 @@ def store_mso_sp_container(length) #:nodoc:
|
|
7214
7122
|
|
7215
7123
|
###############################################################################
|
7216
7124
|
#
|
7217
|
-
#
|
7125
|
+
# store_mso_spgr()
|
7218
7126
|
#
|
7219
7127
|
# Write the Escher Spgr record that is part of MSODRAWING.
|
7220
7128
|
#
|
@@ -7231,7 +7139,7 @@ def store_mso_spgr #:nodoc:
|
|
7231
7139
|
|
7232
7140
|
###############################################################################
|
7233
7141
|
#
|
7234
|
-
#
|
7142
|
+
# store_mso_sp()
|
7235
7143
|
#
|
7236
7144
|
# Write the Escher Sp record that is part of MSODRAWING.
|
7237
7145
|
#
|
@@ -7248,7 +7156,7 @@ def store_mso_sp(instance, spid, options) #:nodoc:
|
|
7248
7156
|
|
7249
7157
|
###############################################################################
|
7250
7158
|
#
|
7251
|
-
#
|
7159
|
+
# store_mso_opt_comment()
|
7252
7160
|
#
|
7253
7161
|
# Write the Escher Opt record that is part of MSODRAWING.
|
7254
7162
|
#
|
@@ -7260,7 +7168,7 @@ def store_mso_opt_comment(spid, visible = nil, colour = 0x50) #:nodoc:
|
|
7260
7168
|
length = 54
|
7261
7169
|
|
7262
7170
|
# Use the visible flag if set by the user or else use the worksheet value.
|
7263
|
-
# Note that the value used is the opposite of
|
7171
|
+
# Note that the value used is the opposite of store_note().
|
7264
7172
|
#
|
7265
7173
|
if !visible.nil?
|
7266
7174
|
visible = visible != 0 ? 0x0000 : 0x0002
|
@@ -7281,7 +7189,7 @@ def store_mso_opt_comment(spid, visible = nil, colour = 0x50) #:nodoc:
|
|
7281
7189
|
|
7282
7190
|
###############################################################################
|
7283
7191
|
#
|
7284
|
-
#
|
7192
|
+
# store_mso_opt_image()
|
7285
7193
|
#
|
7286
7194
|
# Write the Escher Opt record that is part of MSODRAWING.
|
7287
7195
|
#
|
@@ -7305,7 +7213,7 @@ def store_mso_opt_image(spid) #:nodoc:
|
|
7305
7213
|
|
7306
7214
|
###############################################################################
|
7307
7215
|
#
|
7308
|
-
#
|
7216
|
+
# store_mso_opt_chart()
|
7309
7217
|
#
|
7310
7218
|
# Write the Escher Opt record that is part of MSODRAWING.
|
7311
7219
|
#
|
@@ -7339,7 +7247,7 @@ def store_mso_opt_chart #:nodoc:
|
|
7339
7247
|
|
7340
7248
|
###############################################################################
|
7341
7249
|
#
|
7342
|
-
#
|
7250
|
+
# store_mso_opt_filter()
|
7343
7251
|
#
|
7344
7252
|
# Write the Escher Opt record that is part of MSODRAWING.
|
7345
7253
|
#
|
@@ -7362,7 +7270,7 @@ def store_mso_opt_filter #:nodoc:
|
|
7362
7270
|
end
|
7363
7271
|
# private :store_mso_opt_filter
|
7364
7272
|
|
7365
|
-
def store_mso_protection_and_text
|
7273
|
+
def store_mso_protection_and_text # :nodoc:
|
7366
7274
|
[0x007F].pack('v') + # Protection -> fLockAgainstGrouping
|
7367
7275
|
[0x01040104].pack('V') +
|
7368
7276
|
[0x00BF].pack('v') + # Text -> fFitTextToShape
|
@@ -7372,7 +7280,7 @@ def store_mso_protection_and_text
|
|
7372
7280
|
|
7373
7281
|
###############################################################################
|
7374
7282
|
#
|
7375
|
-
#
|
7283
|
+
# store_mso_client_anchor()
|
7376
7284
|
# my flag = shift;
|
7377
7285
|
# my $col_start = $_[0]; # Col containing upper left corner of object
|
7378
7286
|
# my $x1 = $_[1]; # Distance to left side of object
|
@@ -7403,7 +7311,7 @@ def store_mso_client_anchor(flag, col_start, x1, row_start, y1, col_end, x2, row
|
|
7403
7311
|
|
7404
7312
|
###############################################################################
|
7405
7313
|
#
|
7406
|
-
#
|
7314
|
+
# store_mso_client_data()
|
7407
7315
|
#
|
7408
7316
|
# Write the Escher ClientData record that is part of MSODRAWING.
|
7409
7317
|
#
|
@@ -7420,7 +7328,7 @@ def store_mso_client_data #:nodoc:
|
|
7420
7328
|
|
7421
7329
|
###############################################################################
|
7422
7330
|
#
|
7423
|
-
#
|
7331
|
+
# store_obj_comment()
|
7424
7332
|
# my $obj_id = $_[0]; # Object ID number.
|
7425
7333
|
#
|
7426
7334
|
# Write the OBJ record that is part of cell comments.
|
@@ -7465,7 +7373,7 @@ def store_obj_comment(obj_id) #:nodoc:
|
|
7465
7373
|
|
7466
7374
|
###############################################################################
|
7467
7375
|
#
|
7468
|
-
#
|
7376
|
+
# store_obj_image()
|
7469
7377
|
# my $obj_id = $_[0]; # Object ID number.
|
7470
7378
|
#
|
7471
7379
|
# Write the OBJ record that is part of image records.
|
@@ -7516,7 +7424,7 @@ def store_obj_image(obj_id) #:nodoc:
|
|
7516
7424
|
|
7517
7425
|
###############################################################################
|
7518
7426
|
#
|
7519
|
-
#
|
7427
|
+
# store_obj_chart()
|
7520
7428
|
# my $obj_id = $_[0]; # Object ID number.
|
7521
7429
|
#
|
7522
7430
|
# Write the OBJ record that is part of chart records.
|
@@ -7555,7 +7463,7 @@ def store_obj_chart(obj_id) #:nodoc:
|
|
7555
7463
|
|
7556
7464
|
###############################################################################
|
7557
7465
|
#
|
7558
|
-
#
|
7466
|
+
# store_obj_filter()
|
7559
7467
|
# my $obj_id = $_[0]; # Object ID number.
|
7560
7468
|
# my $col = $_[1];
|
7561
7469
|
#
|
@@ -7614,7 +7522,7 @@ def store_obj_filter(obj_id, col) #:nodoc:
|
|
7614
7522
|
|
7615
7523
|
###############################################################################
|
7616
7524
|
#
|
7617
|
-
#
|
7525
|
+
# store_mso_drawing_text_box()
|
7618
7526
|
#
|
7619
7527
|
# Write the MSODRAWING ClientTextbox record that is part of comments.
|
7620
7528
|
#
|
@@ -7631,7 +7539,7 @@ def store_mso_drawing_text_box #:nodoc:
|
|
7631
7539
|
|
7632
7540
|
###############################################################################
|
7633
7541
|
#
|
7634
|
-
#
|
7542
|
+
# store_mso_client_text_box()
|
7635
7543
|
#
|
7636
7544
|
# Write the Escher ClientTextbox record that is part of MSODRAWING.
|
7637
7545
|
#
|
@@ -7648,7 +7556,7 @@ def store_mso_client_text_box #:nodoc:
|
|
7648
7556
|
|
7649
7557
|
###############################################################################
|
7650
7558
|
#
|
7651
|
-
#
|
7559
|
+
# store_txo()
|
7652
7560
|
# my $string_len = $_[0]; # Length of the note text.
|
7653
7561
|
# my $format_len = $_[1] || 16; # Length of the format runs.
|
7654
7562
|
# my $rotation = $_[2] || 0; # Options
|
@@ -7673,7 +7581,7 @@ def store_txo(string_len, format_len = 16, rotation = 0) #:nodoc:
|
|
7673
7581
|
|
7674
7582
|
###############################################################################
|
7675
7583
|
#
|
7676
|
-
#
|
7584
|
+
# store_txo_continue_1()
|
7677
7585
|
# my $string = $_[0]; # Comment string.
|
7678
7586
|
# my $encoding = $_[1] || 0; # Encoding of the string.
|
7679
7587
|
#
|
@@ -7687,7 +7595,7 @@ def store_txo_continue_1(string, encoding = 0) #:nodoc:
|
|
7687
7595
|
# We can't let BIFFwriter::_add_continue() handled this since an extra
|
7688
7596
|
# encoding byte has to be added similar to the SST block.
|
7689
7597
|
#
|
7690
|
-
# We make the limit size smaller than the
|
7598
|
+
# We make the limit size smaller than the add_continue() size and even
|
7691
7599
|
# so that UTF16 chars occur in the same block.
|
7692
7600
|
#
|
7693
7601
|
limit = 8218
|
@@ -7716,7 +7624,7 @@ def store_txo_continue_1(string, encoding = 0) #:nodoc:
|
|
7716
7624
|
|
7717
7625
|
###############################################################################
|
7718
7626
|
#
|
7719
|
-
#
|
7627
|
+
# store_txo_continue_2()
|
7720
7628
|
# my $formats = $_[0]; # Formatting information
|
7721
7629
|
#
|
7722
7630
|
# Write the second CONTINUE record to follow the TXO record. It contains the
|
@@ -7742,7 +7650,7 @@ def store_txo_continue_2(formats) #:nodoc:
|
|
7742
7650
|
|
7743
7651
|
###############################################################################
|
7744
7652
|
#
|
7745
|
-
#
|
7653
|
+
# store_note()
|
7746
7654
|
# my $row = $_[0];
|
7747
7655
|
# my $col = $_[1];
|
7748
7656
|
# my $obj_id = $_[2];
|
@@ -7761,7 +7669,7 @@ def store_note(row, col, obj_id, author = nil, author_enc = nil, visible = nil)
|
|
7761
7669
|
author_enc = @comments_author_enc if author_enc.nil?
|
7762
7670
|
|
7763
7671
|
# Use the visible flag if set by the user or else use the worksheet value.
|
7764
|
-
# The flag is also set in
|
7672
|
+
# The flag is also set in store_mso_opt_comment() but with the opposite
|
7765
7673
|
# value.
|
7766
7674
|
if !visible.nil?
|
7767
7675
|
visible = visible != 0 ? 0x0002 : 0x0000
|
@@ -7790,7 +7698,7 @@ def store_note(row, col, obj_id, author = nil, author_enc = nil, visible = nil)
|
|
7790
7698
|
|
7791
7699
|
###############################################################################
|
7792
7700
|
#
|
7793
|
-
#
|
7701
|
+
# comment_params()
|
7794
7702
|
#
|
7795
7703
|
# This method handles the additional optional parameters to write_comment() as
|
7796
7704
|
# well as calculating the comment object position and vertices.
|
@@ -7834,18 +7742,10 @@ def comment_params(row, col, string, options = {}) #:nodoc:
|
|
7834
7742
|
string = string.unpack('n*').pack('v*')
|
7835
7743
|
# Handle utf8 strings
|
7836
7744
|
else
|
7837
|
-
|
7838
|
-
|
7839
|
-
|
7840
|
-
|
7841
|
-
end
|
7842
|
-
end
|
7843
|
-
ruby_19 do
|
7844
|
-
if string.encoding == Encoding::UTF_8
|
7845
|
-
string = NKF.nkf('-w16L0 -m0 -W', string)
|
7846
|
-
string.force_encoding('UTF-16LE')
|
7847
|
-
params[:encoding] = 1
|
7848
|
-
end
|
7745
|
+
if is_utf8?(string)
|
7746
|
+
string = NKF.nkf('-w16L0 -m0 -W', string)
|
7747
|
+
ruby_19 { string.force_encoding('UTF-16LE') }
|
7748
|
+
params[:encoding] = 1
|
7849
7749
|
end
|
7850
7750
|
end
|
7851
7751
|
|
@@ -7857,18 +7757,10 @@ def comment_params(row, col, string, options = {}) #:nodoc:
|
|
7857
7757
|
# Change from UTF-16BE to UTF-16LE
|
7858
7758
|
params[:author] = params[:author].unpack('n*').pack('v*')
|
7859
7759
|
else
|
7860
|
-
|
7861
|
-
|
7862
|
-
|
7863
|
-
|
7864
|
-
end
|
7865
|
-
end
|
7866
|
-
ruby_19 do
|
7867
|
-
if params[:author].encoding == Encoding::UTF_8
|
7868
|
-
params[:author] = NKF.nkf('-w16L0 -m0 -W', params[:author])
|
7869
|
-
params[:author].force_encoding('UTF-16LE')
|
7870
|
-
params[:author_encoding] = 1
|
7871
|
-
end
|
7760
|
+
if is_utf8?(params[:author])
|
7761
|
+
params[:author] = NKF.nkf('-w16L0 -m0 -W', params[:author])
|
7762
|
+
ruby_19 { params[:author].force_encoding('UTF-16LE') }
|
7763
|
+
params[:author_encoding] = 1
|
7872
7764
|
end
|
7873
7765
|
end
|
7874
7766
|
|
@@ -7968,8 +7860,8 @@ def comment_params(row, col, string, options = {}) #:nodoc:
|
|
7968
7860
|
|
7969
7861
|
#
|
7970
7862
|
# :call-seq:
|
7971
|
-
# data_validation(row, col,
|
7972
|
-
# data_validation(first_row, first_col, last_row, last_col,
|
7863
|
+
# data_validation(row, col, params)
|
7864
|
+
# data_validation(first_row, first_col, last_row, last_col, params)
|
7973
7865
|
#
|
7974
7866
|
# This method handles the interface to Excel data validation.
|
7975
7867
|
# Somewhat ironically the this requires a lot of validation code since the
|
@@ -8076,70 +7968,71 @@ def comment_params(row, col, string, options = {}) #:nodoc:
|
|
8076
7968
|
# length
|
8077
7969
|
# custom
|
8078
7970
|
#
|
8079
|
-
#
|
8080
|
-
#
|
8081
|
-
#
|
7971
|
+
# * any is used to specify that the type of data is unrestricted. This
|
7972
|
+
# is the same as not applying a data validation. It is only provided for
|
7973
|
+
# completeness and isn't used very often in the context of WriteExcel.
|
8082
7974
|
#
|
8083
|
-
#
|
8084
|
-
#
|
7975
|
+
# * integer restricts the cell to integer values. Excel refers to this
|
7976
|
+
# as 'whole number'.
|
8085
7977
|
#
|
8086
|
-
#
|
8087
|
-
#
|
8088
|
-
#
|
7978
|
+
# :validate => 'integer',
|
7979
|
+
# :criteria => '>',
|
7980
|
+
# :value => 100,
|
8089
7981
|
#
|
8090
|
-
#
|
7982
|
+
# * decimal restricts the cell to decimal values.
|
8091
7983
|
#
|
8092
|
-
#
|
8093
|
-
#
|
8094
|
-
#
|
7984
|
+
# :validate => 'decimal',
|
7985
|
+
# :criteria => '>',
|
7986
|
+
# :value => 38.6,
|
8095
7987
|
#
|
8096
|
-
#
|
8097
|
-
#
|
8098
|
-
#
|
7988
|
+
# * list restricts the cell to a set of user specified values. These
|
7989
|
+
# can be passed in an array ref or as a cell range (named ranges aren't
|
7990
|
+
# currently supported):
|
8099
7991
|
#
|
8100
|
-
#
|
8101
|
-
#
|
8102
|
-
#
|
8103
|
-
#
|
7992
|
+
# :validate => 'list',
|
7993
|
+
# :value => ['open', 'high', 'close'],
|
7994
|
+
# # Or like this:
|
7995
|
+
# :value => 'B1:B3',
|
8104
7996
|
#
|
8105
|
-
#
|
7997
|
+
# Excel requires that range references are only to cells on the
|
8106
7998
|
# same worksheet.
|
8107
|
-
# * date restricts the cell to date values. Dates in Excel are expressed
|
8108
|
-
# as integer values but you can also pass an ISO860 style string as used in
|
8109
|
-
# write_date_time(). See also "DATES AND TIME IN EXCEL" for more information
|
8110
|
-
# about working with Excel's dates.
|
8111
7999
|
#
|
8112
|
-
#
|
8113
|
-
#
|
8114
|
-
#
|
8115
|
-
#
|
8116
|
-
# :value => '2008-07-24T',
|
8000
|
+
# * date restricts the cell to date values. Dates in Excel are expressed
|
8001
|
+
# as integer values but you can also pass an ISO860 style string as used in
|
8002
|
+
# write_date_time(). See also "DATES AND TIME IN EXCEL" for more information
|
8003
|
+
# about working with Excel's dates.
|
8117
8004
|
#
|
8118
|
-
#
|
8119
|
-
#
|
8120
|
-
#
|
8121
|
-
#
|
8005
|
+
# :validate => 'date',
|
8006
|
+
# :criteria => '>',
|
8007
|
+
# :value => 39653, # 24 July 2008
|
8008
|
+
# # Or like this:
|
8009
|
+
# :value => '2008-07-24T',
|
8122
8010
|
#
|
8123
|
-
#
|
8124
|
-
#
|
8125
|
-
#
|
8126
|
-
#
|
8127
|
-
# :value => 'T12:00:00',
|
8011
|
+
# * time restricts the cell to time values. Times in Excel are expressed
|
8012
|
+
# as decimal values but you can also pass an ISO860 style string as used in
|
8013
|
+
# write_date_time(). See also "DATES AND TIME IN EXCEL" for more information
|
8014
|
+
# about working with Excel's times.
|
8128
8015
|
#
|
8129
|
-
#
|
8130
|
-
#
|
8016
|
+
# :validate => 'time',
|
8017
|
+
# :criteria => '>',
|
8018
|
+
# :value => 0.5, # Noon
|
8019
|
+
# # Or like this:
|
8020
|
+
# :value => 'T12:00:00',
|
8021
|
+
#
|
8022
|
+
# * length restricts the cell data based on an integer string length.
|
8023
|
+
# Excel refers to this as 'Text length'.
|
8131
8024
|
#
|
8132
|
-
#
|
8133
|
-
#
|
8134
|
-
#
|
8025
|
+
# :validate => 'length',
|
8026
|
+
# :criteria => '>',
|
8027
|
+
# :value => 10,
|
8135
8028
|
#
|
8136
|
-
#
|
8137
|
-
#
|
8029
|
+
# * custom restricts the cell based on an external Excel formula that
|
8030
|
+
# returns a TRUE/FALSE value.
|
8138
8031
|
#
|
8139
|
-
#
|
8140
|
-
#
|
8032
|
+
# :validate => 'custom',
|
8033
|
+
# :value => '=IF(A10>B10,TRUE,FALSE)',
|
8141
8034
|
#
|
8142
|
-
# criteria
|
8035
|
+
# ===criteria
|
8143
8036
|
#
|
8144
8037
|
# This parameter is passed in a hash ref to data_validation().
|
8145
8038
|
#
|
@@ -8177,7 +8070,7 @@ def comment_params(row, col, string, options = {}) #:nodoc:
|
|
8177
8070
|
# :validate => 'custom',
|
8178
8071
|
# :value => '=IF(A10>B10,TRUE,FALSE)',
|
8179
8072
|
#
|
8180
|
-
#
|
8073
|
+
# ===value | minimum | source
|
8181
8074
|
#
|
8182
8075
|
# This parameter is passed in a hash ref to data_validation().
|
8183
8076
|
#
|
@@ -8201,7 +8094,7 @@ def comment_params(row, col, string, options = {}) #:nodoc:
|
|
8201
8094
|
# :validate => 'list',
|
8202
8095
|
# :source => 'B1:B3',
|
8203
8096
|
#
|
8204
|
-
#
|
8097
|
+
# ===maximum
|
8205
8098
|
#
|
8206
8099
|
# This parameter is passed in a hash ref to data_validation().
|
8207
8100
|
#
|
@@ -8213,7 +8106,7 @@ def comment_params(row, col, string, options = {}) #:nodoc:
|
|
8213
8106
|
# :minimum => 1,
|
8214
8107
|
# :maximum => 100,
|
8215
8108
|
#
|
8216
|
-
#
|
8109
|
+
# ===ignore_blank
|
8217
8110
|
#
|
8218
8111
|
# This parameter is passed in a hash ref to data_validation().
|
8219
8112
|
#
|
@@ -8224,7 +8117,7 @@ def comment_params(row, col, string, options = {}) #:nodoc:
|
|
8224
8117
|
#
|
8225
8118
|
# :ignore_blank => 0, # Turn the option off
|
8226
8119
|
#
|
8227
|
-
#
|
8120
|
+
# ===dropdown
|
8228
8121
|
#
|
8229
8122
|
# This parameter is passed in a hash ref to data_validation().
|
8230
8123
|
#
|
@@ -8234,7 +8127,7 @@ def comment_params(row, col, string, options = {}) #:nodoc:
|
|
8234
8127
|
#
|
8235
8128
|
# :dropdown => 0, # Turn the option off
|
8236
8129
|
#
|
8237
|
-
#
|
8130
|
+
# ===input_title
|
8238
8131
|
#
|
8239
8132
|
# This parameter is passed in a hash ref to data_validation().
|
8240
8133
|
#
|
@@ -8248,7 +8141,7 @@ def comment_params(row, col, string, options = {}) #:nodoc:
|
|
8248
8141
|
# The maximum title length is 32 characters. UTF8 strings are handled
|
8249
8142
|
# automatically.
|
8250
8143
|
#
|
8251
|
-
#
|
8144
|
+
# ===input_message
|
8252
8145
|
#
|
8253
8146
|
# This parameter is passed in a hash ref to data_validation().
|
8254
8147
|
#
|
@@ -8270,7 +8163,7 @@ def comment_params(row, col, string, options = {}) #:nodoc:
|
|
8270
8163
|
# The maximum message length is 255 characters. UTF8 strings are handled
|
8271
8164
|
# automatically.
|
8272
8165
|
#
|
8273
|
-
#
|
8166
|
+
# ===show_input
|
8274
8167
|
#
|
8275
8168
|
# This parameter is passed in a hash ref to data_validation().
|
8276
8169
|
#
|
@@ -8281,7 +8174,7 @@ def comment_params(row, col, string, options = {}) #:nodoc:
|
|
8281
8174
|
#
|
8282
8175
|
# :show_input => 0, # Turn the option off
|
8283
8176
|
#
|
8284
|
-
#
|
8177
|
+
# ===error_title
|
8285
8178
|
#
|
8286
8179
|
# This parameter is passed in a hash ref to data_validation().
|
8287
8180
|
#
|
@@ -8294,7 +8187,7 @@ def comment_params(row, col, string, options = {}) #:nodoc:
|
|
8294
8187
|
# The maximum title length is 32 characters. UTF8 strings are handled
|
8295
8188
|
# automatically.
|
8296
8189
|
#
|
8297
|
-
#
|
8190
|
+
# ===error_message
|
8298
8191
|
#
|
8299
8192
|
# This parameter is passed in a hash ref to data_validation().
|
8300
8193
|
#
|
@@ -8318,7 +8211,7 @@ def comment_params(row, col, string, options = {}) #:nodoc:
|
|
8318
8211
|
# The maximum message length is 255 characters. UTF8 strings are handled
|
8319
8212
|
# automatically.
|
8320
8213
|
#
|
8321
|
-
#
|
8214
|
+
# ===error_type
|
8322
8215
|
#
|
8323
8216
|
# This parameter is passed in a hash ref to data_validation().
|
8324
8217
|
#
|
@@ -8331,7 +8224,7 @@ def comment_params(row, col, string, options = {}) #:nodoc:
|
|
8331
8224
|
#
|
8332
8225
|
# The default is 'stop'.
|
8333
8226
|
#
|
8334
|
-
#
|
8227
|
+
# ===show_error
|
8335
8228
|
#
|
8336
8229
|
# This parameter is passed in a hash ref to data_validation().
|
8337
8230
|
#
|
@@ -8342,7 +8235,7 @@ def comment_params(row, col, string, options = {}) #:nodoc:
|
|
8342
8235
|
#
|
8343
8236
|
# :show_error => 0, # Turn the option off
|
8344
8237
|
#
|
8345
|
-
# Examples
|
8238
|
+
# ===Examples
|
8346
8239
|
#
|
8347
8240
|
# Example 1. Limiting input to an integer greater than a fixed value.
|
8348
8241
|
#
|
@@ -8416,9 +8309,7 @@ def comment_params(row, col, string, options = {}) #:nodoc:
|
|
8416
8309
|
#
|
8417
8310
|
def data_validation(*args)
|
8418
8311
|
# Check for a cell reference in A1 notation and substitute row and column
|
8419
|
-
|
8420
|
-
args = substitute_cellref(*args)
|
8421
|
-
end
|
8312
|
+
args = row_col_notation(args)
|
8422
8313
|
|
8423
8314
|
# Check for a valid number of args.
|
8424
8315
|
return -1 if args.size != 5 && args.size != 3
|
@@ -8627,11 +8518,11 @@ def data_validation(*args)
|
|
8627
8518
|
|
8628
8519
|
###############################################################################
|
8629
8520
|
#
|
8630
|
-
#
|
8521
|
+
# store_validation_count()
|
8631
8522
|
#
|
8632
8523
|
# Store the count of the DV records to follow.
|
8633
8524
|
#
|
8634
|
-
# Note, this could be wrapped into
|
8525
|
+
# Note, this could be wrapped into store_dv() but we may require separate
|
8635
8526
|
# handling of the object id at a later stage.
|
8636
8527
|
#
|
8637
8528
|
def store_validation_count #:nodoc:
|
@@ -8646,7 +8537,7 @@ def store_validation_count #:nodoc:
|
|
8646
8537
|
|
8647
8538
|
###############################################################################
|
8648
8539
|
#
|
8649
|
-
#
|
8540
|
+
# store_validations()
|
8650
8541
|
#
|
8651
8542
|
# Store the data_validation records.
|
8652
8543
|
#
|
@@ -8676,7 +8567,7 @@ def store_validations #:nodoc:
|
|
8676
8567
|
|
8677
8568
|
###############################################################################
|
8678
8569
|
#
|
8679
|
-
#
|
8570
|
+
# store_dval()
|
8680
8571
|
# my $obj_id = $_[0]; # Object ID number.
|
8681
8572
|
# my $dv_count = $_[1]; # Count of DV structs to follow.
|
8682
8573
|
#
|
@@ -8701,7 +8592,7 @@ def store_dval(obj_id, dv_count) #:nodoc:
|
|
8701
8592
|
|
8702
8593
|
###############################################################################
|
8703
8594
|
#
|
8704
|
-
#
|
8595
|
+
# store_dv()
|
8705
8596
|
# my $cells = $_[0]; # Aref of cells to which DV applies.
|
8706
8597
|
# my $validation_type = $_[1]; # Type of data validation.
|
8707
8598
|
# my $criteria_type = $_[2]; # Validation criteria.
|
@@ -8786,7 +8677,7 @@ def store_dv(cells, validation_type, criteria_type, #:nodoc:
|
|
8786
8677
|
|
8787
8678
|
###############################################################################
|
8788
8679
|
#
|
8789
|
-
#
|
8680
|
+
# pack_dv_string()
|
8790
8681
|
#
|
8791
8682
|
# Pack the strings used in the input and error dialog captions and messages.
|
8792
8683
|
# Captions are limited to 32 characters. Messages are limited to 255 chars.
|
@@ -8811,19 +8702,10 @@ def pack_dv_string(string = nil, max_length = 0) #:nodoc:
|
|
8811
8702
|
ruby_19 { string = convert_to_ascii_if_ascii(string) }
|
8812
8703
|
|
8813
8704
|
# Handle utf8 strings
|
8814
|
-
|
8815
|
-
|
8816
|
-
|
8817
|
-
|
8818
|
-
encoding = 1
|
8819
|
-
end
|
8820
|
-
end
|
8821
|
-
ruby_19 do
|
8822
|
-
if string.encoding == Encoding::UTF_8
|
8823
|
-
str_length = string.gsub(/[^\Wa-zA-Z_\d]/, ' ').bytesize # jlength
|
8824
|
-
string = utf8_to_16le(string)
|
8825
|
-
encoding = 1
|
8826
|
-
end
|
8705
|
+
if is_utf8?(string)
|
8706
|
+
str_length = string.gsub(/[^\Wa-zA-Z_\d]/, ' ').bytesize # jlength
|
8707
|
+
string = utf8_to_16le(string)
|
8708
|
+
encoding = 1
|
8827
8709
|
end
|
8828
8710
|
|
8829
8711
|
ruby_18 { [str_length, encoding].pack('vC') + string } ||
|
@@ -8833,7 +8715,7 @@ def pack_dv_string(string = nil, max_length = 0) #:nodoc:
|
|
8833
8715
|
|
8834
8716
|
###############################################################################
|
8835
8717
|
#
|
8836
|
-
#
|
8718
|
+
# pack_dv_formula()
|
8837
8719
|
#
|
8838
8720
|
# Pack the formula used in the DV record. This is the same as an cell formula
|
8839
8721
|
# with some additional header information. Note, DV formulas in Excel use
|
@@ -8888,6 +8770,16 @@ def pack_dv_formula(formula = nil) #:nodoc:
|
|
8888
8770
|
|
8889
8771
|
[formula.length, unused].pack('vv') + formula
|
8890
8772
|
end
|
8773
|
+
|
8774
|
+
# Check for a cell reference in A1 notation and substitute row and column
|
8775
|
+
def row_col_notation(args) # :nodoc:
|
8776
|
+
if args[0] =~ /^\D/
|
8777
|
+
substitute_cellref(*args)
|
8778
|
+
else
|
8779
|
+
args
|
8780
|
+
end
|
8781
|
+
end
|
8782
|
+
private :row_col_notation
|
8891
8783
|
end # class Worksheet
|
8892
8784
|
|
8893
8785
|
end # module Writeexcel
|