writeexcel 1.0.5 → 1.0.7
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/.github/workflows/test-suite.yml +26 -0
- data/README.rdoc +11 -2
- data/lib/writeexcel/biffwriter.rb +2 -1
- data/lib/writeexcel/cell_range.rb +1 -0
- 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 +2 -1
- data/lib/writeexcel/convert_date_time.rb +7 -7
- data/lib/writeexcel/excelformulaparser.rb +50 -50
- 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 +2 -4
- data/lib/writeexcel/workbook.rb +14 -25
- data/lib/writeexcel/worksheet.rb +73 -56
- data/lib/writeexcel/worksheets.rb +1 -2
- data/lib/writeexcel.rb +3 -5
- data/test/helper.rb +12 -4
- data/test/test_00_IEEE_double.rb +1 -1
- data/test/test_04_dimensions.rb +6 -6
- data/test/test_05_rows.rb +14 -17
- data/test/test_06_extsst.rb +8 -11
- 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 +5 -5
- data/test/test_22_mso_drawing_group.rb +37 -40
- data/test/test_23_note.rb +5 -5
- data/test/test_24_txo.rb +5 -5
- data/test/test_25_position_object.rb +5 -5
- 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 +5 -5
- data/test/test_31_validation_dv_strings.rb +8 -8
- data/test/test_32_validation_dv_formula.rb +5 -5
- data/test/test_40_property_types.rb +1 -1
- data/test/test_41_properties.rb +1 -1
- data/test/test_42_set_properties.rb +30 -37
- data/test/test_50_name_stored.rb +1 -19
- 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 +6 -3
- metadata +24 -21
- 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
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 210718d145e6c74ec1b4ff8242a80937d3fe3de27815decd8a79856fa2f6ae73
|
4
|
+
data.tar.gz: 3ba1e17f91c2093e715cdb14964814cf67adad44890dd8286aac3e1568a09a6b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 28357fc96e5c28bf45924743c758111deb2e8ca5386dcd8efcbd1fdabcae277a8d3756c21d2e9b6b454f10558f9615d28c1b77ef25c8cda3d9335bd24d027c9a
|
7
|
+
data.tar.gz: 36c16f58a152fbfd64d1cd4af38bbdf5a9bccf77962da6cc5436fb70a080bc164e1178ebf0a70296c96232c3143ce775cb74ed31698e4ca2f49d8fc4e884335d
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# This workflow uses actions that are not certified by GitHub.
|
2
|
+
# They are provided by a third-party and are governed by
|
3
|
+
# separate terms of service, privacy policy, and support
|
4
|
+
# documentation.
|
5
|
+
# This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
|
6
|
+
# For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
|
7
|
+
|
8
|
+
name: test-suite
|
9
|
+
|
10
|
+
on: [push, pull_request]
|
11
|
+
|
12
|
+
jobs:
|
13
|
+
test:
|
14
|
+
runs-on: ubuntu-20.04
|
15
|
+
strategy:
|
16
|
+
fail-fast: false
|
17
|
+
matrix:
|
18
|
+
ruby: [3.3, 3.2, 3.1, '3.0', 2.7, 2.6, 2.5, 2.4]
|
19
|
+
|
20
|
+
steps:
|
21
|
+
- uses: actions/checkout@v2
|
22
|
+
- uses: ruby/setup-ruby@v1
|
23
|
+
with:
|
24
|
+
ruby-version: ${{ matrix.ruby }}
|
25
|
+
bundler-cache: true
|
26
|
+
- run: bundle exec rake
|
data/README.rdoc
CHANGED
@@ -3,6 +3,7 @@
|
|
3
3
|
Write to a cross-platform Excel binary file.
|
4
4
|
|
5
5
|
{<img src="https://badge.fury.io/rb/writeexcel.png" alt="Gem Version" />}[http://badge.fury.io/rb/writeexcel]
|
6
|
+
{<img src="https://travis-ci.org/cxn03651/writeexcel.svg?branch=master" alt="Build Status" />}[https://travis-ci.org/cxn03651/writeexcel]
|
6
7
|
|
7
8
|
== Description
|
8
9
|
|
@@ -84,6 +85,14 @@ Example Code:
|
|
84
85
|
* and ......
|
85
86
|
|
86
87
|
== Recent Change
|
88
|
+
v1.0.7
|
89
|
+
* support Ruby 3.3
|
90
|
+
* support Ruby 2.4 or later
|
91
|
+
|
92
|
+
v1.0.6
|
93
|
+
* support Ruby 3.2
|
94
|
+
* use minitest gem instead of test-unit.
|
95
|
+
|
87
96
|
v1.0.5
|
88
97
|
* use test-unit gem instead of test/unit.
|
89
98
|
|
@@ -107,8 +116,8 @@ v1.0.0
|
|
107
116
|
|
108
117
|
Original was written in Perl by John McNamara (jmcnamara@cpan.org).
|
109
118
|
|
110
|
-
Convert to ruby by Hideo Nakamura (
|
111
|
-
Copyright (c) 2009-
|
119
|
+
Convert to ruby by Hideo Nakamura (nakamura.hideo@gmail.com)
|
120
|
+
Copyright (c) 2009-2024 Hideo NAKAMURA. See LICENSE.txt for details.
|
112
121
|
|
113
122
|
== License
|
114
123
|
|
@@ -1,4 +1,5 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
|
+
# frozen_string_literal: true
|
2
3
|
#
|
3
4
|
# BIFFwriter - An abstract base class for Excel workbooks and worksheets.
|
4
5
|
#
|
@@ -187,7 +188,7 @@ class BIFFWriter < WriteFile #:nodoc:
|
|
187
188
|
# The header contains version and instance info packed into 2 bytes.
|
188
189
|
header = version | (instance << 4)
|
189
190
|
|
190
|
-
|
191
|
+
[header, type, length].pack('vvV') + data
|
191
192
|
end
|
192
193
|
|
193
194
|
def not_using_tmpfile
|
data/lib/writeexcel/chart.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
|
+
# frozen_string_literal: true
|
2
3
|
###############################################################################
|
3
4
|
#
|
4
5
|
# Chart - A writer class for Excel Charts.
|
@@ -649,8 +650,6 @@ class Chart < Worksheet
|
|
649
650
|
# information required for _store_series() and the SERIES record.
|
650
651
|
#
|
651
652
|
def parse_series_formula(formula) # :nodoc:
|
652
|
-
encoding = 0
|
653
|
-
length = 0
|
654
653
|
count = 0
|
655
654
|
tokens = []
|
656
655
|
|
@@ -677,7 +676,7 @@ class Chart < Worksheet
|
|
677
676
|
|
678
677
|
# Extract the range from the parse formula.
|
679
678
|
if formula.ord == 0x3B
|
680
|
-
|
679
|
+
row_1, row_2 = formula.unpack('Cv5')[2, 2]
|
681
680
|
|
682
681
|
# TODO. Remove high bit on relative references.
|
683
682
|
count = row_2 - row_1 + 1
|
data/lib/writeexcel/col_info.rb
CHANGED
data/lib/writeexcel/comments.rb
CHANGED
@@ -6,6 +6,7 @@ class Worksheet < BIFFWriter
|
|
6
6
|
class Collection
|
7
7
|
def initialize
|
8
8
|
@items = {}
|
9
|
+
@array = nil
|
9
10
|
end
|
10
11
|
|
11
12
|
def <<(item)
|
@@ -252,7 +253,7 @@ class Worksheet < BIFFWriter
|
|
252
253
|
when 65533 then 65529
|
253
254
|
when 65534 then 65530
|
254
255
|
when 65535 then 65531
|
255
|
-
else @row -1
|
256
|
+
else @row - 1
|
256
257
|
end
|
257
258
|
end
|
258
259
|
|
@@ -81,7 +81,7 @@ module ConvertDateTime
|
|
81
81
|
epoch = date_1904 ? 1904 : 1900
|
82
82
|
offset = date_1904 ? 4 : 0
|
83
83
|
norm = 300
|
84
|
-
range = year -epoch
|
84
|
+
range = year - epoch
|
85
85
|
|
86
86
|
# Set month days and check for leap year.
|
87
87
|
mdays = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
|
@@ -92,15 +92,15 @@ module ConvertDateTime
|
|
92
92
|
# Some boundary checks
|
93
93
|
return nil if year < epoch or year > 9999
|
94
94
|
return nil if month < 1 or month > 12
|
95
|
-
return nil if day < 1 or day > mdays[month -1]
|
95
|
+
return nil if day < 1 or day > mdays[month - 1]
|
96
96
|
|
97
97
|
# Accumulate the number of days since the epoch.
|
98
98
|
days = mdays[0, month - 1].inject(day) {|result, mday| result + mday} # days from 1, Jan
|
99
|
-
days += range *365
|
100
|
-
days += ((range)
|
101
|
-
days -= ((range + offset)
|
102
|
-
days += ((range + offset + norm)/400) # Add 400 year leapdays
|
103
|
-
days -= leap
|
99
|
+
days += range * 365 # Add days for past years
|
100
|
+
days += ((range) / 4) # Add leapdays
|
101
|
+
days -= ((range + offset) / 100) # Subtract 100 year leapdays
|
102
|
+
days += ((range + offset + norm) / 400) # Add 400 year leapdays
|
103
|
+
days -= leap # Already counted above
|
104
104
|
|
105
105
|
# Adjust for Excel erroneously treating 1900 as a leap year.
|
106
106
|
days += 1 if !date_1904 and days > 59
|
@@ -1,11 +1,12 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
|
+
# frozen_string_literal: true
|
2
3
|
#
|
3
4
|
# DO NOT MODIFY!!!!
|
4
5
|
# This file is automatically generated by Racc 1.4.11
|
5
6
|
# from Racc grammer file "".
|
6
7
|
#
|
7
8
|
|
8
|
-
require 'racc/parser
|
9
|
+
require 'racc/parser'
|
9
10
|
class ExcelFormulaParser < Racc::Parser # :nodoc:
|
10
11
|
##### State transition tables begin ###
|
11
12
|
|
@@ -293,14 +294,14 @@ Racc_debug_parser = false
|
|
293
294
|
|
294
295
|
module_eval(<<'.,.,', 'excelformula.y', 20)
|
295
296
|
def _reduce_2(val, _values, result)
|
296
|
-
result = []
|
297
|
+
result = []
|
297
298
|
result
|
298
299
|
end
|
299
300
|
.,.,
|
300
301
|
|
301
302
|
module_eval(<<'.,.,', 'excelformula.y', 21)
|
302
303
|
def _reduce_3(val, _values, result)
|
303
|
-
result.push val[1], '_arg', '1'
|
304
|
+
result.push val[1], '_arg', '1'
|
304
305
|
result
|
305
306
|
end
|
306
307
|
.,.,
|
@@ -309,84 +310,84 @@ module_eval(<<'.,.,', 'excelformula.y', 21)
|
|
309
310
|
|
310
311
|
module_eval(<<'.,.,', 'excelformula.y', 24)
|
311
312
|
def _reduce_5(val, _values, result)
|
312
|
-
result = [ val[0], val[2], 'ptgAdd' ]
|
313
|
+
result = [ val[0], val[2], 'ptgAdd' ]
|
313
314
|
result
|
314
315
|
end
|
315
316
|
.,.,
|
316
317
|
|
317
318
|
module_eval(<<'.,.,', 'excelformula.y', 25)
|
318
319
|
def _reduce_6(val, _values, result)
|
319
|
-
result = [ val[0], val[2], 'ptgSub' ]
|
320
|
+
result = [ val[0], val[2], 'ptgSub' ]
|
320
321
|
result
|
321
322
|
end
|
322
323
|
.,.,
|
323
324
|
|
324
325
|
module_eval(<<'.,.,', 'excelformula.y', 26)
|
325
326
|
def _reduce_7(val, _values, result)
|
326
|
-
result = [ val[0], val[2], 'ptgMul' ]
|
327
|
+
result = [ val[0], val[2], 'ptgMul' ]
|
327
328
|
result
|
328
329
|
end
|
329
330
|
.,.,
|
330
331
|
|
331
332
|
module_eval(<<'.,.,', 'excelformula.y', 27)
|
332
333
|
def _reduce_8(val, _values, result)
|
333
|
-
result = [ val[0], val[2], 'ptgDiv' ]
|
334
|
+
result = [ val[0], val[2], 'ptgDiv' ]
|
334
335
|
result
|
335
336
|
end
|
336
337
|
.,.,
|
337
338
|
|
338
339
|
module_eval(<<'.,.,', 'excelformula.y', 28)
|
339
340
|
def _reduce_9(val, _values, result)
|
340
|
-
result = [ val[0], val[2], 'ptgPower' ]
|
341
|
+
result = [ val[0], val[2], 'ptgPower' ]
|
341
342
|
result
|
342
343
|
end
|
343
344
|
.,.,
|
344
345
|
|
345
346
|
module_eval(<<'.,.,', 'excelformula.y', 29)
|
346
347
|
def _reduce_10(val, _values, result)
|
347
|
-
result = [ val[0], val[2], 'ptgConcat' ]
|
348
|
+
result = [ val[0], val[2], 'ptgConcat' ]
|
348
349
|
result
|
349
350
|
end
|
350
351
|
.,.,
|
351
352
|
|
352
353
|
module_eval(<<'.,.,', 'excelformula.y', 30)
|
353
354
|
def _reduce_11(val, _values, result)
|
354
|
-
result = [ val[0], val[2], 'ptgLT' ]
|
355
|
+
result = [ val[0], val[2], 'ptgLT' ]
|
355
356
|
result
|
356
357
|
end
|
357
358
|
.,.,
|
358
359
|
|
359
360
|
module_eval(<<'.,.,', 'excelformula.y', 31)
|
360
361
|
def _reduce_12(val, _values, result)
|
361
|
-
result = [ val[0], val[2], 'ptgGT' ]
|
362
|
+
result = [ val[0], val[2], 'ptgGT' ]
|
362
363
|
result
|
363
364
|
end
|
364
365
|
.,.,
|
365
366
|
|
366
367
|
module_eval(<<'.,.,', 'excelformula.y', 32)
|
367
368
|
def _reduce_13(val, _values, result)
|
368
|
-
result = [ val[0], val[2], 'ptgLE' ]
|
369
|
+
result = [ val[0], val[2], 'ptgLE' ]
|
369
370
|
result
|
370
371
|
end
|
371
372
|
.,.,
|
372
373
|
|
373
374
|
module_eval(<<'.,.,', 'excelformula.y', 33)
|
374
375
|
def _reduce_14(val, _values, result)
|
375
|
-
result = [ val[0], val[2], 'ptgGE' ]
|
376
|
+
result = [ val[0], val[2], 'ptgGE' ]
|
376
377
|
result
|
377
378
|
end
|
378
379
|
.,.,
|
379
380
|
|
380
381
|
module_eval(<<'.,.,', 'excelformula.y', 34)
|
381
382
|
def _reduce_15(val, _values, result)
|
382
|
-
result = [ val[0], val[2], 'ptgNE' ]
|
383
|
+
result = [ val[0], val[2], 'ptgNE' ]
|
383
384
|
result
|
384
385
|
end
|
385
386
|
.,.,
|
386
387
|
|
387
388
|
module_eval(<<'.,.,', 'excelformula.y', 35)
|
388
389
|
def _reduce_16(val, _values, result)
|
389
|
-
result = [ val[0], val[2], 'ptgEQ' ]
|
390
|
+
result = [ val[0], val[2], 'ptgEQ' ]
|
390
391
|
result
|
391
392
|
end
|
392
393
|
.,.,
|
@@ -395,14 +396,14 @@ module_eval(<<'.,.,', 'excelformula.y', 35)
|
|
395
396
|
|
396
397
|
module_eval(<<'.,.,', 'excelformula.y', 38)
|
397
398
|
def _reduce_18(val, _values, result)
|
398
|
-
result = [ val[1], '_arg', '1', 'ptgParen']
|
399
|
+
result = [ val[1], '_arg', '1', 'ptgParen']
|
399
400
|
result
|
400
401
|
end
|
401
402
|
.,.,
|
402
403
|
|
403
404
|
module_eval(<<'.,.,', 'excelformula.y', 39)
|
404
405
|
def _reduce_19(val, _values, result)
|
405
|
-
result = [ '_num', '-1', val[1], 'ptgMul' ]
|
406
|
+
result = [ '_num', '-1', val[1], 'ptgMul' ]
|
406
407
|
result
|
407
408
|
end
|
408
409
|
.,.,
|
@@ -411,63 +412,63 @@ module_eval(<<'.,.,', 'excelformula.y', 39)
|
|
411
412
|
|
412
413
|
module_eval(<<'.,.,', 'excelformula.y', 41)
|
413
414
|
def _reduce_21(val, _values, result)
|
414
|
-
result = [ '_num', val[0] ]
|
415
|
+
result = [ '_num', val[0] ]
|
415
416
|
result
|
416
417
|
end
|
417
418
|
.,.,
|
418
419
|
|
419
420
|
module_eval(<<'.,.,', 'excelformula.y', 42)
|
420
421
|
def _reduce_22(val, _values, result)
|
421
|
-
result = [ '_str', val[0] ]
|
422
|
+
result = [ '_str', val[0] ]
|
422
423
|
result
|
423
424
|
end
|
424
425
|
.,.,
|
425
426
|
|
426
427
|
module_eval(<<'.,.,', 'excelformula.y', 43)
|
427
428
|
def _reduce_23(val, _values, result)
|
428
|
-
result = [ '_ref2d', val[0] ]
|
429
|
+
result = [ '_ref2d', val[0] ]
|
429
430
|
result
|
430
431
|
end
|
431
432
|
.,.,
|
432
433
|
|
433
434
|
module_eval(<<'.,.,', 'excelformula.y', 44)
|
434
435
|
def _reduce_24(val, _values, result)
|
435
|
-
result = [ '_ref3d', val[0] ]
|
436
|
+
result = [ '_ref3d', val[0] ]
|
436
437
|
result
|
437
438
|
end
|
438
439
|
.,.,
|
439
440
|
|
440
441
|
module_eval(<<'.,.,', 'excelformula.y', 45)
|
441
442
|
def _reduce_25(val, _values, result)
|
442
|
-
result = [ '_range2d', val[0] ]
|
443
|
+
result = [ '_range2d', val[0] ]
|
443
444
|
result
|
444
445
|
end
|
445
446
|
.,.,
|
446
447
|
|
447
448
|
module_eval(<<'.,.,', 'excelformula.y', 46)
|
448
449
|
def _reduce_26(val, _values, result)
|
449
|
-
result = [ '_range3d', val[0] ]
|
450
|
+
result = [ '_range3d', val[0] ]
|
450
451
|
result
|
451
452
|
end
|
452
453
|
.,.,
|
453
454
|
|
454
455
|
module_eval(<<'.,.,', 'excelformula.y', 47)
|
455
456
|
def _reduce_27(val, _values, result)
|
456
|
-
result = [ '_name', val[0] ]
|
457
|
+
result = [ '_name', val[0] ]
|
457
458
|
result
|
458
459
|
end
|
459
460
|
.,.,
|
460
461
|
|
461
462
|
module_eval(<<'.,.,', 'excelformula.y', 48)
|
462
463
|
def _reduce_28(val, _values, result)
|
463
|
-
result = [ 'ptgBool', '1' ]
|
464
|
+
result = [ 'ptgBool', '1' ]
|
464
465
|
result
|
465
466
|
end
|
466
467
|
.,.,
|
467
468
|
|
468
469
|
module_eval(<<'.,.,', 'excelformula.y', 49)
|
469
470
|
def _reduce_29(val, _values, result)
|
470
|
-
result = [ 'ptgBool', '0' ]
|
471
|
+
result = [ 'ptgBool', '0' ]
|
471
472
|
result
|
472
473
|
end
|
473
474
|
.,.,
|
@@ -476,28 +477,28 @@ module_eval(<<'.,.,', 'excelformula.y', 49)
|
|
476
477
|
|
477
478
|
module_eval(<<'.,.,', 'excelformula.y', 52)
|
478
479
|
def _reduce_31(val, _values, result)
|
479
|
-
result = [ '_class', val[0], val[2], '_arg', val[2].size.to_s, '_func', val[0] ]
|
480
|
+
result = [ '_class', val[0], val[2], '_arg', val[2].size.to_s, '_func', val[0] ]
|
480
481
|
result
|
481
482
|
end
|
482
483
|
.,.,
|
483
484
|
|
484
485
|
module_eval(<<'.,.,', 'excelformula.y', 53)
|
485
486
|
def _reduce_32(val, _values, result)
|
486
|
-
result = [ '_func', val[0] ]
|
487
|
+
result = [ '_func', val[0] ]
|
487
488
|
result
|
488
489
|
end
|
489
490
|
.,.,
|
490
491
|
|
491
492
|
module_eval(<<'.,.,', 'excelformula.y', 55)
|
492
493
|
def _reduce_33(val, _values, result)
|
493
|
-
result = val
|
494
|
+
result = val
|
494
495
|
result
|
495
496
|
end
|
496
497
|
.,.,
|
497
498
|
|
498
499
|
module_eval(<<'.,.,', 'excelformula.y', 56)
|
499
500
|
def _reduce_34(val, _values, result)
|
500
|
-
result.push val[2]
|
501
|
+
result.push val[2]
|
501
502
|
result
|
502
503
|
end
|
503
504
|
.,.,
|
@@ -515,70 +516,69 @@ end
|
|
515
516
|
module Writeexcel
|
516
517
|
|
517
518
|
class Node # :nodoc:
|
518
|
-
|
519
|
+
|
519
520
|
def exec_list(nodes)
|
520
521
|
v = nil
|
521
522
|
nodes.each { |i| v = i.evaluate }
|
522
523
|
v
|
523
524
|
end
|
524
|
-
|
525
|
+
|
525
526
|
def excelformulaparser_error(msg)
|
526
527
|
raise ExcelFormulaParserError,
|
527
528
|
"in #{fname}:#{lineno}: #{msg}"
|
528
529
|
end
|
529
|
-
|
530
|
+
|
530
531
|
end
|
531
|
-
|
532
|
+
|
532
533
|
class RootNode < Node # :nodoc:
|
533
|
-
|
534
|
+
|
534
535
|
def initialize(tree)
|
535
536
|
@tree = tree
|
536
537
|
end
|
537
|
-
|
538
|
+
|
538
539
|
def evaluate
|
539
540
|
exec_list @tree
|
540
541
|
end
|
541
|
-
|
542
|
+
|
542
543
|
end
|
543
|
-
|
544
|
-
|
544
|
+
|
545
|
+
|
545
546
|
class FuncallNode < Node # :nodoc:
|
546
|
-
|
547
|
+
|
547
548
|
def initialize(func, args)
|
548
549
|
@func = func
|
549
550
|
@args = args
|
550
551
|
end
|
551
|
-
|
552
|
+
|
552
553
|
def evaluate
|
553
554
|
arg = @args.collect {|i| i.evaluate }
|
554
|
-
out = []
|
555
555
|
arg.each { |i| o.push i }
|
556
556
|
o.push @func
|
557
557
|
p o
|
558
558
|
end
|
559
|
-
|
559
|
+
|
560
560
|
end
|
561
|
-
|
561
|
+
|
562
562
|
class NumberNode < Node # :nodoc:
|
563
|
-
|
563
|
+
|
564
564
|
def initialize(val)
|
565
565
|
@val = val
|
566
566
|
end
|
567
|
-
|
567
|
+
|
568
568
|
def evaluate
|
569
569
|
p @val
|
570
570
|
end
|
571
|
-
|
571
|
+
|
572
572
|
end
|
573
|
-
|
573
|
+
|
574
574
|
class OperateNode < Node # :nodoc:
|
575
|
-
|
575
|
+
|
576
576
|
def initialize(op, left, right)
|
577
577
|
@op = op
|
578
578
|
@left = left
|
579
579
|
@right = right
|
580
580
|
end
|
581
|
-
|
581
|
+
|
582
582
|
def evaluate
|
583
583
|
o = []
|
584
584
|
o.push @left
|
data/lib/writeexcel/format.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
|
+
# frozen_string_literal: true
|
2
3
|
##############################################################################
|
3
4
|
#
|
4
5
|
# Format - A class for defining Excel formatting.
|
@@ -1572,4 +1573,3 @@ class Format < Colors
|
|
1572
1573
|
end # class Format
|
1573
1574
|
|
1574
1575
|
end # module Writeexcel
|
1575
|
-
|
data/lib/writeexcel/formula.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
|
+
# frozen_string_literal: true
|
2
3
|
###############################################################################
|
3
4
|
#
|
4
5
|
# Formula - A class for generating Excel formulas.
|
@@ -62,7 +63,6 @@ class Formula < ExcelFormulaParser #:nodoc:
|
|
62
63
|
#
|
63
64
|
def parse_tokens(tokens)
|
64
65
|
parse_str = ''
|
65
|
-
last_type = ''
|
66
66
|
modifier = ''
|
67
67
|
num_args = 0
|
68
68
|
_class = 0
|
data/lib/writeexcel/helper.rb
CHANGED
@@ -42,9 +42,9 @@
|
|
42
42
|
private :utf8_to_16le
|
43
43
|
|
44
44
|
def ascii_to_16be(ascii)
|
45
|
-
ascii.unpack("C*").pack("n*")
|
46
|
-
ruby_19 {
|
47
|
-
|
45
|
+
str_16be = ascii.unpack("C*").pack("n*")
|
46
|
+
ruby_19 { str_16be.force_encoding('UTF-16BE') }
|
47
|
+
str_16be
|
48
48
|
end
|
49
49
|
private :ascii_to_16be
|
50
50
|
|
@@ -109,10 +109,10 @@ class Workbook < BIFFWriter
|
|
109
109
|
written += space_remaining
|
110
110
|
|
111
111
|
# Reduce the current block length by the amount written
|
112
|
-
block_length -= continue_limit -continue -align
|
112
|
+
block_length -= continue_limit - continue - align
|
113
113
|
|
114
114
|
# Store the max size for this block
|
115
|
-
block_sizes.push(continue_limit -align)
|
115
|
+
block_sizes.push(continue_limit - align)
|
116
116
|
|
117
117
|
# If the current string was split then the next CONTINUE block
|
118
118
|
# should have the string continue flag (grbit) set unless the
|
@@ -125,10 +125,10 @@ class Workbook < BIFFWriter
|
|
125
125
|
end
|
126
126
|
else
|
127
127
|
# Store the max size for this block
|
128
|
-
block_sizes.push(written +continue)
|
128
|
+
block_sizes.push(written + continue)
|
129
129
|
|
130
130
|
# Not enough space to start the string in the current block
|
131
|
-
block_length -= continue_limit -space_remaining -continue
|
131
|
+
block_length -= continue_limit - space_remaining - continue
|
132
132
|
continue = 0
|
133
133
|
end
|
134
134
|
|
@@ -145,7 +145,7 @@ class Workbook < BIFFWriter
|
|
145
145
|
end
|
146
146
|
|
147
147
|
# Store the max size for the last block unless it is empty
|
148
|
-
block_sizes.push(written +continue) if written +continue != 0
|
148
|
+
block_sizes.push(written + continue) if written + continue != 0
|
149
149
|
|
150
150
|
block_sizes
|
151
151
|
end
|