writeexcel 1.0.5 → 1.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/.travis.yml +8 -0
- data/README.rdoc +5 -0
- data/lib/writeexcel/biffwriter.rb +2 -1
- data/lib/writeexcel/chart.rb +2 -3
- data/lib/writeexcel/charts/area.rb +1 -1
- data/lib/writeexcel/charts/pie.rb +1 -1
- data/lib/writeexcel/charts/scatter.rb +1 -1
- data/lib/writeexcel/charts/stock.rb +1 -1
- data/lib/writeexcel/col_info.rb +2 -2
- data/lib/writeexcel/comments.rb +1 -1
- data/lib/writeexcel/convert_date_time.rb +7 -7
- data/lib/writeexcel/excelformulaparser.rb +49 -49
- data/lib/writeexcel/format.rb +1 -1
- data/lib/writeexcel/formula.rb +1 -1
- data/lib/writeexcel/helper.rb +3 -3
- data/lib/writeexcel/properties.rb +1 -1
- data/lib/writeexcel/shared_string_table.rb +5 -5
- data/lib/writeexcel/storage_lite.rb +2 -9
- data/lib/writeexcel/version.rb +1 -1
- data/lib/writeexcel/workbook.rb +13 -14
- data/lib/writeexcel/worksheet.rb +43 -35
- data/test/helper.rb +12 -4
- data/test/test_00_IEEE_double.rb +1 -1
- data/test/test_04_dimensions.rb +2 -2
- data/test/test_05_rows.rb +1 -1
- data/test/test_06_extsst.rb +1 -1
- data/test/test_11_date_time.rb +1 -1
- data/test/test_12_date_only.rb +1 -1
- data/test/test_13_date_seconds.rb +1 -1
- data/test/test_21_escher.rb +1 -1
- data/test/test_22_mso_drawing_group.rb +1 -1
- data/test/test_23_note.rb +1 -1
- data/test/test_24_txo.rb +1 -1
- data/test/test_25_position_object.rb +1 -1
- data/test/test_26_autofilter.rb +1 -1
- data/test/test_27_autofilter.rb +1 -1
- data/test/test_28_autofilter.rb +1 -1
- data/test/test_29_process_jpg.rb +1 -43
- data/test/test_30_validation_dval.rb +1 -1
- data/test/test_31_validation_dv_strings.rb +1 -1
- data/test/test_32_validation_dv_formula.rb +1 -1
- data/test/test_40_property_types.rb +1 -1
- data/test/test_41_properties.rb +1 -1
- data/test/test_42_set_properties.rb +2 -2
- data/test/test_50_name_stored.rb +1 -9
- data/test/test_51_name_print_area.rb +3 -13
- data/test/test_52_name_print_titles.rb +3 -21
- data/test/test_53_autofilter.rb +1 -5
- data/test/test_60_chart_generic.rb +3 -3
- data/test/test_61_chart_subclasses.rb +2 -1
- data/test/test_62_chart_formats.rb +9 -21
- data/test/test_63_chart_area_formats.rb +1 -1
- data/test/test_compatibility.rb +1 -1
- data/test/test_example_match.rb +835 -835
- data/test/test_format.rb +1 -114
- data/test/test_formula.rb +1 -1
- data/test/test_properties.rb +1 -2
- data/test/test_storage_lite.rb +2 -2
- data/test/test_workbook.rb +1 -66
- data/test/test_worksheet.rb +1 -18
- data/test/test_write_formula_does_not_change_formula_string.rb +1 -1
- data/writeexcel.gemspec +3 -2
- metadata +23 -20
- data/test/test_01_add_worksheet.rb +0 -43
- data/test/test_02_merge_formats.rb +0 -49
- data/test/test_biff.rb +0 -71
- data/test/test_big_workbook.rb +0 -17
- data/test/test_ole.rb +0 -102
data/lib/writeexcel/workbook.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
|
+
# frozen_string_literal: true
|
2
3
|
###############################################################################
|
3
4
|
#
|
4
5
|
# Workbook - A writer class for Excel Workbooks.
|
@@ -652,7 +653,6 @@ class Workbook < BIFFWriter
|
|
652
653
|
#
|
653
654
|
def define_name(name, formula, encoding = 0)
|
654
655
|
sheet_index = 0
|
655
|
-
full_name = name.downcase
|
656
656
|
|
657
657
|
if name =~ /^(.*)!(.*)$/
|
658
658
|
sheetname = $1
|
@@ -1266,7 +1266,7 @@ class Workbook < BIFFWriter
|
|
1266
1266
|
# Add the length of the MSODRAWINGGROUP records including an extra 4 bytes
|
1267
1267
|
# for any CONTINUE headers. See add_mso_drawing_group_continue().
|
1268
1268
|
mso_size = @mso_size
|
1269
|
-
mso_size += 4 * Integer((mso_size -1) / Float(@limit))
|
1269
|
+
mso_size += 4 * Integer((mso_size - 1) / Float(@limit))
|
1270
1270
|
offset += mso_size
|
1271
1271
|
|
1272
1272
|
@worksheets.each do |sheet|
|
@@ -1374,7 +1374,7 @@ class Workbook < BIFFWriter
|
|
1374
1374
|
image_id += 1
|
1375
1375
|
else
|
1376
1376
|
# We've processed this file already.
|
1377
|
-
index = images_seen[image.filename] -1
|
1377
|
+
index = images_seen[image.filename] - 1
|
1378
1378
|
|
1379
1379
|
# Increase image reference count.
|
1380
1380
|
image_data[index].ref_count += 1
|
@@ -2053,7 +2053,6 @@ class Workbook < BIFFWriter
|
|
2053
2053
|
def store_shared_strings #:nodoc:
|
2054
2054
|
record = 0x00FC # Record identifier
|
2055
2055
|
length = 0x0008 # Number of bytes to follow
|
2056
|
-
total = 0x0000
|
2057
2056
|
|
2058
2057
|
# Iterate through the strings to calculate the CONTINUE block sizes
|
2059
2058
|
continue_limit = 8208
|
@@ -2136,10 +2135,10 @@ class Workbook < BIFFWriter
|
|
2136
2135
|
append(tmp)
|
2137
2136
|
|
2138
2137
|
# The remainder will be written in the next block(s)
|
2139
|
-
string = string[space_remaining .. string.length-1]
|
2138
|
+
string = string[space_remaining .. string.length - 1]
|
2140
2139
|
|
2141
2140
|
# Reduce the current block length by the amount written
|
2142
|
-
block_length -= continue_limit -continue -align
|
2141
|
+
block_length -= continue_limit - continue - align
|
2143
2142
|
|
2144
2143
|
# If the current string was split then the next CONTINUE block
|
2145
2144
|
# should have the string continue flag (grbit) set unless the
|
@@ -2152,7 +2151,7 @@ class Workbook < BIFFWriter
|
|
2152
2151
|
end
|
2153
2152
|
else
|
2154
2153
|
# Not enough space to start the string in the current block
|
2155
|
-
block_length -= continue_limit -space_remaining -continue
|
2154
|
+
block_length -= continue_limit - space_remaining - continue
|
2156
2155
|
continue = 0
|
2157
2156
|
end
|
2158
2157
|
|
@@ -2206,7 +2205,7 @@ class Workbook < BIFFWriter
|
|
2206
2205
|
bucket_size = 1 + Integer(unique_strings / 128.0)
|
2207
2206
|
end
|
2208
2207
|
|
2209
|
-
buckets = Integer((unique_strings + bucket_size -1)
|
2208
|
+
buckets = Integer((unique_strings + bucket_size - 1) / Float(bucket_size))
|
2210
2209
|
|
2211
2210
|
@extsst_buckets = buckets
|
2212
2211
|
@extsst_bucket_size = bucket_size
|
@@ -2278,7 +2277,7 @@ class Workbook < BIFFWriter
|
|
2278
2277
|
# Case 3: > 2*8224 bytes 2 MSODRAWINGGROUP + n CONTINUE
|
2279
2278
|
#
|
2280
2279
|
def add_mso_drawing_group_continue(data) #:nodoc:
|
2281
|
-
limit = 8228 -4
|
2280
|
+
limit = 8228 - 4
|
2282
2281
|
mso_group = 0x00EB # Record identifier
|
2283
2282
|
continue = 0x003C # Record identifier
|
2284
2283
|
block_count = 1
|
@@ -2334,7 +2333,7 @@ class Workbook < BIFFWriter
|
|
2334
2333
|
version = 15
|
2335
2334
|
instance = 0
|
2336
2335
|
data = ''
|
2337
|
-
length = @mso_size -12 # -4 (biff header) -8 (for this).
|
2336
|
+
length = @mso_size - 12 # -4 (biff header) -8 (for this).
|
2338
2337
|
|
2339
2338
|
add_mso_generic(type, version, instance, data, length)
|
2340
2339
|
end
|
@@ -2372,7 +2371,7 @@ class Workbook < BIFFWriter
|
|
2372
2371
|
version = 15
|
2373
2372
|
instance = @images_data.size # Number of images.
|
2374
2373
|
data = ''
|
2375
|
-
length = @images_size +8 *instance
|
2374
|
+
length = @images_size + 8 * instance
|
2376
2375
|
|
2377
2376
|
add_mso_generic(type, version, instance, data, length)
|
2378
2377
|
end
|
@@ -2399,12 +2398,12 @@ class Workbook < BIFFWriter
|
|
2399
2398
|
type = 0xF007
|
2400
2399
|
version = 2
|
2401
2400
|
instance = image_type
|
2402
|
-
length = size +61
|
2401
|
+
length = size + 61
|
2403
2402
|
data = [image_type].pack('C') + # Win32
|
2404
2403
|
[image_type].pack('C') + # Mac
|
2405
2404
|
[checksum1].pack('H*') + # Uid checksum
|
2406
2405
|
[0xFF].pack('v') + # Tag
|
2407
|
-
[size +25].pack('V')
|
2406
|
+
[size + 25].pack('V') + # Next Blip size
|
2408
2407
|
[ref_count].pack('V') + # Image ref count
|
2409
2408
|
[0x00000000].pack('V') + # File offset
|
2410
2409
|
[0x00].pack('C') + # Usage
|
@@ -2430,7 +2429,7 @@ class Workbook < BIFFWriter
|
|
2430
2429
|
|
2431
2430
|
type = 0xF018 + image_type
|
2432
2431
|
version = 0x0000
|
2433
|
-
length = size +17
|
2432
|
+
length = size + 17
|
2434
2433
|
data = [checksum1].pack('H*') + # Uid checksum
|
2435
2434
|
[0xFF].pack('C') + # Tag
|
2436
2435
|
image_data # Image
|
data/lib/writeexcel/worksheet.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
|
+
# frozen_string_literal: true
|
2
3
|
###############################################################################
|
3
4
|
#
|
4
5
|
# Worksheet - A writer class for Excel Worksheets.
|
@@ -536,7 +537,7 @@ class Worksheet < BIFFWriter
|
|
536
537
|
# not be obtained exactly due to rounding in Excel.
|
537
538
|
#
|
538
539
|
if height
|
539
|
-
miyRw = height *20
|
540
|
+
miyRw = height * 20
|
540
541
|
else
|
541
542
|
miyRw = 0xff # The default row height
|
542
543
|
height = 0
|
@@ -672,8 +673,11 @@ class Worksheet < BIFFWriter
|
|
672
673
|
#
|
673
674
|
def set_column(*args)
|
674
675
|
# Check for a cell reference in A1 notation and substitute row and column
|
675
|
-
if args[0] =~ /^\D/
|
676
|
-
|
676
|
+
if args[0].respond_to?(:=~) && args[0] =~ /^\D/
|
677
|
+
array = substitute_cellref(*args)
|
678
|
+
firstcol = array[1]
|
679
|
+
lastcol = array[3]
|
680
|
+
*data = array[4, array.length - 4]
|
677
681
|
else
|
678
682
|
firstcol, lastcol, *data = args
|
679
683
|
end
|
@@ -1211,7 +1215,7 @@ class Worksheet < BIFFWriter
|
|
1211
1215
|
|
1212
1216
|
# Check for a column reference in A1 notation and substitute.
|
1213
1217
|
# Convert col ref to a cell ref and then to a col number.
|
1214
|
-
|
1218
|
+
col = substitute_cellref("#{col}1")[1] if col.to_s =~ /^\D/
|
1215
1219
|
|
1216
1220
|
# Reject column if it is outside filter range.
|
1217
1221
|
unless @filter_area.inside?(col)
|
@@ -1615,8 +1619,10 @@ class Worksheet < BIFFWriter
|
|
1615
1619
|
#
|
1616
1620
|
def repeat_columns(*args)
|
1617
1621
|
# Check for a cell reference in A1 notation and substitute row and column
|
1618
|
-
if args[0] =~ /^\D/
|
1619
|
-
|
1622
|
+
if args[0].to_s =~ /^\D/
|
1623
|
+
array = substitute_cellref(*args)
|
1624
|
+
firstcol = array[1]
|
1625
|
+
lastcol = array[3]
|
1620
1626
|
else
|
1621
1627
|
firstcol, lastcol = args
|
1622
1628
|
end
|
@@ -2209,10 +2215,8 @@ class Worksheet < BIFFWriter
|
|
2209
2215
|
# Check for a cell reference in A1 notation and substitute row and column
|
2210
2216
|
args = row_col_notation(args)
|
2211
2217
|
|
2212
|
-
token = args[2]
|
2213
|
-
|
2214
2218
|
# Handle undefs as blanks
|
2215
|
-
token
|
2219
|
+
token = args[2] || ''
|
2216
2220
|
|
2217
2221
|
# First try user defined matches.
|
2218
2222
|
@write_match.each do |aref|
|
@@ -2223,7 +2227,7 @@ class Worksheet < BIFFWriter
|
|
2223
2227
|
match = eval("#{sub} self, args")
|
2224
2228
|
return match if match
|
2225
2229
|
end
|
2226
|
-
end
|
2230
|
+
end if token.respond_to?(:=~)
|
2227
2231
|
|
2228
2232
|
# Match an array ref.
|
2229
2233
|
if token.respond_to?(:to_ary)
|
@@ -2231,16 +2235,16 @@ class Worksheet < BIFFWriter
|
|
2231
2235
|
elsif token.respond_to?(:coerce) # Numeric
|
2232
2236
|
write_number(*args)
|
2233
2237
|
# Match http, https or ftp URL
|
2234
|
-
elsif token =~ %r|^[fh]tt?ps?://|
|
2238
|
+
elsif token.respond_to?(:=~) && token =~ %r|^[fh]tt?ps?://|
|
2235
2239
|
write_url(*args)
|
2236
2240
|
# Match mailto:
|
2237
|
-
elsif token =~ %r|^mailto:|
|
2241
|
+
elsif token.respond_to?(:=~) && token =~ %r|^mailto:|
|
2238
2242
|
write_url(*args)
|
2239
2243
|
# Match internal or external sheet link
|
2240
|
-
elsif token =~ %r!^(?:in|ex)ternal:!
|
2244
|
+
elsif token.respond_to?(:=~) && token =~ %r!^(?:in|ex)ternal:!
|
2241
2245
|
write_url(*args)
|
2242
2246
|
# Match formula
|
2243
|
-
elsif token =~ /^=/
|
2247
|
+
elsif token.respond_to?(:=~) && token =~ /^=/
|
2244
2248
|
write_formula(*args)
|
2245
2249
|
# Match blank
|
2246
2250
|
elsif token == ''
|
@@ -3495,7 +3499,8 @@ class Worksheet < BIFFWriter
|
|
3495
3499
|
|
3496
3500
|
return -1 if args.size < 3 # Check the number of args
|
3497
3501
|
|
3498
|
-
row, col
|
3502
|
+
row, col = args
|
3503
|
+
params = args[3]
|
3499
3504
|
|
3500
3505
|
# Check for pairs of optional arguments, i.e. an odd number of args.
|
3501
3506
|
# raise "Uneven number of additional arguments" if args.size % 2 == 0
|
@@ -4457,10 +4462,10 @@ class Worksheet < BIFFWriter
|
|
4457
4462
|
y2 = 256.0 * height / size_row(row_end)
|
4458
4463
|
|
4459
4464
|
# Simulate ceil() without calling POSIX::ceil().
|
4460
|
-
x1 = (x1 +0.5).to_i
|
4461
|
-
y1 = (y1 +0.5).to_i
|
4462
|
-
x2 = (x2 +0.5).to_i
|
4463
|
-
y2 = (y2 +0.5).to_i
|
4465
|
+
x1 = (x1 + 0.5).to_i
|
4466
|
+
y1 = (y1 + 0.5).to_i
|
4467
|
+
x2 = (x2 + 0.5).to_i
|
4468
|
+
y2 = (y2 + 0.5).to_i
|
4464
4469
|
|
4465
4470
|
[
|
4466
4471
|
col_start, x1,
|
@@ -4615,7 +4620,7 @@ class Worksheet < BIFFWriter
|
|
4615
4620
|
drawings_saved += 1
|
4616
4621
|
|
4617
4622
|
# For each sheet start the spids at the next 1024 interval.
|
4618
|
-
max_spid = 1024 * (1 + Integer((max_spid -1)/1024.0))
|
4623
|
+
max_spid = 1024 * (1 + Integer((max_spid - 1) / 1024.0))
|
4619
4624
|
start_spid = max_spid
|
4620
4625
|
|
4621
4626
|
# Max spid for each sheet and eventually for the workbook.
|
@@ -4626,7 +4631,7 @@ class Worksheet < BIFFWriter
|
|
4626
4631
|
push_cluster(num_shapes, drawings_saved, clusters)
|
4627
4632
|
|
4628
4633
|
# Pass calculated values back to the worksheet
|
4629
|
-
@object_ids = ObjectIds.new(start_spid, drawings_saved, num_shapes, max_spid -1)
|
4634
|
+
@object_ids = ObjectIds.new(start_spid, drawings_saved, num_shapes, max_spid - 1)
|
4630
4635
|
|
4631
4636
|
[mso_size, drawings_saved, max_spid, start_spid]
|
4632
4637
|
end
|
@@ -4666,7 +4671,7 @@ class Worksheet < BIFFWriter
|
|
4666
4671
|
def set_header_footer_common(type, string, margin, encoding) # :nodoc:
|
4667
4672
|
ruby_19 { string = convert_to_ascii_if_ascii(string) }
|
4668
4673
|
|
4669
|
-
limit = encoding != 0 ? 255 *2 : 255
|
4674
|
+
limit = encoding != 0 ? 255 * 2 : 255
|
4670
4675
|
|
4671
4676
|
# Handle utf8 strings
|
4672
4677
|
if is_utf8?(string)
|
@@ -4821,7 +4826,7 @@ class Worksheet < BIFFWriter
|
|
4821
4826
|
# Special handling of "Top" filter expressions.
|
4822
4827
|
if tokens[0] =~ /^top|bottom$/i
|
4823
4828
|
value = tokens[1]
|
4824
|
-
if (value =~ /\D/ or value.to_i < 1 or value.to_i > 500)
|
4829
|
+
if (value.to_s =~ /\D/ or value.to_i < 1 or value.to_i > 500)
|
4825
4830
|
raise "The value '#{value}' in expression '#{expression}' " +
|
4826
4831
|
"must be in the range 1 to 500"
|
4827
4832
|
end
|
@@ -4850,7 +4855,7 @@ class Worksheet < BIFFWriter
|
|
4850
4855
|
end
|
4851
4856
|
|
4852
4857
|
# Special handling for Blanks/NonBlanks.
|
4853
|
-
if (token =~ /^blanks|nonblanks$/i)
|
4858
|
+
if (token.to_s =~ /^blanks|nonblanks$/i)
|
4854
4859
|
# Only allow Equals or NotEqual in this context.
|
4855
4860
|
if (operator != 2 and operator != 5)
|
4856
4861
|
raise "The operator '#{tokens[1]}' in expression '#{expression}' " +
|
@@ -4876,7 +4881,7 @@ class Worksheet < BIFFWriter
|
|
4876
4881
|
|
4877
4882
|
# if the string token contains an Excel match character then change the
|
4878
4883
|
# operator type to indicate a non "simple" equality.
|
4879
|
-
if (operator == 2 and token =~ /[*?]/)
|
4884
|
+
if (operator == 2 and token.to_s =~ /[*?]/)
|
4880
4885
|
operator = 22
|
4881
4886
|
end
|
4882
4887
|
|
@@ -4941,8 +4946,8 @@ class Worksheet < BIFFWriter
|
|
4941
4946
|
# Convert a column range: 'A:A' or 'B:G'.
|
4942
4947
|
# A range such as A:A is equivalent to A1:65536, so add rows as required
|
4943
4948
|
if cell =~ /\$?([A-I]?[A-Z]):\$?([A-I]?[A-Z])/
|
4944
|
-
row1, col1 = cell_to_rowcol($1 +'1')
|
4945
|
-
row2, col2 = cell_to_rowcol($2 +'65536')
|
4949
|
+
row1, col1 = cell_to_rowcol($1 + '1')
|
4950
|
+
row2, col2 = cell_to_rowcol($2 + '65536')
|
4946
4951
|
return [row1, col1, row2, col2, *args]
|
4947
4952
|
end
|
4948
4953
|
|
@@ -5177,8 +5182,8 @@ class Worksheet < BIFFWriter
|
|
5177
5182
|
# Convert an Ascii URL type and to a null terminated wchar string.
|
5178
5183
|
if encoding == 0
|
5179
5184
|
url =
|
5180
|
-
ruby_18 { url + "\0" } ||
|
5181
|
-
ruby_19 { url.force_encoding('BINARY') + "\0"
|
5185
|
+
ruby_18 { url.dup + "\0" } ||
|
5186
|
+
ruby_19 { url.dup.force_encoding('BINARY') + "\0" }
|
5182
5187
|
url = url.unpack('c*').pack('v*')
|
5183
5188
|
end
|
5184
5189
|
|
@@ -5266,12 +5271,12 @@ class Worksheet < BIFFWriter
|
|
5266
5271
|
end
|
5267
5272
|
|
5268
5273
|
def sheetname_from_url(url)
|
5269
|
-
sheetname
|
5274
|
+
sheetname = url.split('!')[0]
|
5270
5275
|
sheetname
|
5271
5276
|
end
|
5272
5277
|
|
5273
5278
|
def cell_from_url(url)
|
5274
|
-
|
5279
|
+
cell = url.split('!')[1]
|
5275
5280
|
cell
|
5276
5281
|
end
|
5277
5282
|
|
@@ -6368,9 +6373,9 @@ class Worksheet < BIFFWriter
|
|
6368
6373
|
|
6369
6374
|
# The relationship is different for user units less than 1.
|
6370
6375
|
if width < 1
|
6371
|
-
(width *12).to_i
|
6376
|
+
(width * 12).to_i
|
6372
6377
|
else
|
6373
|
-
(width *7 +5 ).to_i
|
6378
|
+
(width * 7 + 5 ).to_i
|
6374
6379
|
end
|
6375
6380
|
else
|
6376
6381
|
64
|
@@ -6427,7 +6432,7 @@ class Worksheet < BIFFWriter
|
|
6427
6432
|
|
6428
6433
|
col1.upto(col2) do |i|
|
6429
6434
|
# Reverse order since records are being pre-pended.
|
6430
|
-
col = col2 -i
|
6435
|
+
col = col2 - i
|
6431
6436
|
|
6432
6437
|
# Skip if column doesn't have an active filter.
|
6433
6438
|
next unless @filter_cols[col]
|
@@ -6546,7 +6551,7 @@ class Worksheet < BIFFWriter
|
|
6546
6551
|
# Handle utf8 strings
|
6547
6552
|
if is_utf8?(string)
|
6548
6553
|
string = utf8_to_16be(string)
|
6549
|
-
|
6554
|
+
encoding = 1
|
6550
6555
|
end
|
6551
6556
|
|
6552
6557
|
string =
|
@@ -6950,6 +6955,9 @@ class Worksheet < BIFFWriter
|
|
6950
6955
|
|
6951
6956
|
# Check for a cell reference in A1 notation and substitute row and column
|
6952
6957
|
def row_col_notation(args) # :nodoc:
|
6958
|
+
# ruby 3.2 no longer handles =~ for various types
|
6959
|
+
return args unless args[0].respond_to?(:=~)
|
6960
|
+
|
6953
6961
|
if args[0] =~ /^\D/
|
6954
6962
|
substitute_cellref(*args)
|
6955
6963
|
else
|
data/test/helper.rb
CHANGED
@@ -1,14 +1,22 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
|
-
|
3
|
-
require 'test/unit'
|
2
|
+
# frozen_string_literal: true
|
4
3
|
|
5
|
-
|
4
|
+
require 'bundler'
|
5
|
+
|
6
|
+
begin
|
7
|
+
Bundler.setup(:default, :development)
|
8
|
+
rescue Bundler::BundlerError => e
|
9
|
+
warn e.message
|
10
|
+
warn "Run `bundle install` to install missing gems"
|
11
|
+
exit e.status_code
|
12
|
+
end
|
13
|
+
require 'minitest/autorun'
|
6
14
|
|
7
15
|
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
8
16
|
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
9
17
|
require 'writeexcel'
|
10
18
|
|
11
|
-
class Test
|
19
|
+
class Minitest::Test
|
12
20
|
###############################################################################
|
13
21
|
#
|
14
22
|
# Unpack the binary data into a format suitable for printing in tests.
|
data/test/test_00_IEEE_double.rb
CHANGED
data/test/test_04_dimensions.rb
CHANGED
@@ -14,7 +14,7 @@
|
|
14
14
|
require 'helper'
|
15
15
|
require 'stringio'
|
16
16
|
|
17
|
-
class TC_dimensions < Test
|
17
|
+
class TC_dimensions < Minitest::Test
|
18
18
|
|
19
19
|
def setup
|
20
20
|
@workbook = WriteExcel.new(StringIO.new)
|
@@ -386,7 +386,7 @@ class TC_dimensions < Test::Unit::TestCase
|
|
386
386
|
end
|
387
387
|
|
388
388
|
def test_merge_range
|
389
|
-
|
389
|
+
@worksheet.__send__("store_formula", '=A1 * 3 + 50')
|
390
390
|
@worksheet.merge_range('C6:E8', 'Test', @format)
|
391
391
|
|
392
392
|
data = @worksheet.__send__("store_dimensions")
|
data/test/test_05_rows.rb
CHANGED
data/test/test_06_extsst.rb
CHANGED
data/test/test_11_date_time.rb
CHANGED
data/test/test_12_date_only.rb
CHANGED
data/test/test_21_escher.rb
CHANGED
data/test/test_23_note.rb
CHANGED
data/test/test_24_txo.rb
CHANGED
data/test/test_26_autofilter.rb
CHANGED
data/test/test_27_autofilter.rb
CHANGED
data/test/test_28_autofilter.rb
CHANGED
data/test/test_29_process_jpg.rb
CHANGED
@@ -13,7 +13,7 @@
|
|
13
13
|
require 'helper'
|
14
14
|
require 'stringio'
|
15
15
|
|
16
|
-
class TC_29_process_jpg < Test
|
16
|
+
class TC_29_process_jpg < Minitest::Test
|
17
17
|
|
18
18
|
def setup
|
19
19
|
@image = Writeexcel::Image.new(nil, nil, nil, nil)
|
@@ -21,7 +21,6 @@ class TC_29_process_jpg < Test::Unit::TestCase
|
|
21
21
|
end
|
22
22
|
|
23
23
|
def test_valid_jpg_image_1
|
24
|
-
testname = '3w x 5h jpeg image.'
|
25
24
|
|
26
25
|
data = %w(
|
27
26
|
FF D8 FF E0 00 10 4A 46 49 46 00 01 01 01 00 60
|
@@ -50,8 +49,6 @@ class TC_29_process_jpg < Test::Unit::TestCase
|
|
50
49
|
end
|
51
50
|
|
52
51
|
def test_valid_jpg_image_2
|
53
|
-
testname = '5w x 3h jpeg image.'
|
54
|
-
|
55
52
|
data = %w(
|
56
53
|
FF D8 FF E0 00 10 4A 46 49 46 00 01 01 01 00 60
|
57
54
|
00 60 00 00 FF DB 00 43 00 06 04 05 06 05 04 06
|
@@ -79,50 +76,11 @@ class TC_29_process_jpg < Test::Unit::TestCase
|
|
79
76
|
assert_equal(3, @image.height)
|
80
77
|
end
|
81
78
|
|
82
|
-
def test_valid_jpg_image_3_ffco_marker_missing
|
83
|
-
testname = 'FFCO marker missing in image.'
|
84
|
-
|
85
|
-
data = %w(
|
86
|
-
FF D8 FF E0 00 10 4A 46 49 46 00 01 01 01 00 60
|
87
|
-
00 60 00 00 FF DB 00 43 00 06 04 05 06 05 04 06
|
88
|
-
06 05 06 07 07 06 08 0A 10 0A 0A 09 09 0A 14 0E
|
89
|
-
0F 0C 10 17 14 18 18 17 14 16 16 1A 1D 25 1F 1A
|
90
|
-
1B 23 1C 16 16 20 2C 20 23 26 27 29 2A 29 19 1F
|
91
|
-
2D 30 2D 28 30 25 28 29 28 FF DB 00 43 01 07 07
|
92
|
-
07 0A 08 0A 13 0A 0A 13 28 1A 16 1A 28 28 28 28
|
93
|
-
28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28
|
94
|
-
28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28
|
95
|
-
28 28 28 28 28 28 28 28 28 28 28 28 28 28 FF C1
|
96
|
-
00 11 08 00 03 00 05 03 01 22 00 02 11 01 03 11
|
97
|
-
01 FF C4 00 15 00 01 01 00 00 00 00 00 00 00 00
|
98
|
-
00 00 00 00 00 00 00 07 FF C4 00 14 10 01 00 00
|
99
|
-
00 00 00 00 00 00 00 00 00 00 00 00 00 00 FF C4
|
100
|
-
00 15 01 01 01 00 00 00 00 00 00 00 00 00 00 00
|
101
|
-
00 00 00 06 08 FF C4 00 14 11 01 00 00 00 00 00
|
102
|
-
00 00 00 00 00 00 00 00 00 00 00 FF DA 00 0C 03
|
103
|
-
01 00 02 11 03 11 00 3F 00 9D 00 1C A4 5F FF D9
|
104
|
-
)
|
105
|
-
|
106
|
-
assert_raise(RuntimeError, " \t" + testname) {
|
107
|
-
@image.__send__("process_jpg", [data.join('')].pack('H*'))
|
108
|
-
}
|
109
|
-
end
|
110
|
-
|
111
|
-
def test_invalid_jpeg_image
|
112
|
-
testname = 'empty image'
|
113
|
-
image = ''
|
114
|
-
|
115
|
-
assert_raise(RuntimeError, " \t" + testname) {
|
116
|
-
@image.__send__("process_jpg", image)
|
117
|
-
}
|
118
|
-
end
|
119
|
-
|
120
79
|
###############################################################################
|
121
80
|
#
|
122
81
|
# Test 5. Progressive DCT-based JPEG image.
|
123
82
|
#
|
124
83
|
def test_progressive_dct_based_jpeg_image
|
125
|
-
testname = '35w x 35h progressive jpeg image.'
|
126
84
|
data = %w(
|
127
85
|
FF D8 FF E0 00 10 4A 46 49 46 00 01 02 01 00 96
|
128
86
|
00 96 00 00 FF E1 04 E7 45 78 69 66 00 00 4D 4D
|
data/test/test_41_properties.rb
CHANGED