writeexcel 1.0.4 → 1.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.travis.yml +8 -0
- data/README.rdoc +9 -1
- data/examples/a_simple.rb +0 -1
- data/examples/chart_area.rb +0 -1
- data/examples/chart_legend.rb +0 -1
- data/examples/copyformat.rb +0 -1
- data/examples/data_validate.rb +1 -2
- data/examples/date_time.rb +0 -1
- data/examples/demo.rb +0 -1
- data/examples/diag_border.rb +0 -1
- data/examples/formats.rb +0 -1
- data/examples/header.rb +0 -1
- data/examples/hide_sheet.rb +0 -1
- data/examples/hyperlink.rb +0 -1
- data/examples/hyperlink2.rb +0 -1
- data/examples/images.rb +0 -1
- data/examples/merge1.rb +0 -1
- data/examples/merge2.rb +0 -1
- data/examples/merge3.rb +0 -1
- data/examples/merge4.rb +0 -1
- data/examples/merge5.rb +0 -1
- data/examples/password_protection.rb +0 -1
- data/examples/properties.rb +0 -1
- data/examples/properties_jp.rb +0 -1
- data/examples/protection.rb +0 -1
- data/examples/regions.rb +0 -1
- data/examples/repeat.rb +0 -1
- data/examples/set_first_sheet.rb +0 -1
- data/examples/stocks.rb +0 -1
- data/examples/store_formula.rb +0 -1
- data/examples/tab_colors.rb +0 -1
- data/examples/write_arrays.rb +0 -1
- 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 +2 -6
- 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 -5
- 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 +4 -1
- metadata +38 -19
- 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
@@ -1,4 +1,5 @@
|
|
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
|
@@ -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
|
@@ -680,13 +680,11 @@ class Formula < ExcelFormulaParser #:nodoc:
|
|
680
680
|
'ptgRefNV' => 0x4C,
|
681
681
|
'ptgAreaNV' => 0x4D,
|
682
682
|
'ptgMemAreaNV' => 0x4E,
|
683
|
-
'ptgMemNoMemN' => 0x4F,
|
684
683
|
'ptgFuncCEV' => 0x58,
|
685
684
|
'ptgNameXV' => 0x59,
|
686
685
|
'ptgRef3dV' => 0x5A,
|
687
686
|
'ptgArea3dV' => 0x5B,
|
688
687
|
'ptgRefErr3dV' => 0x5C,
|
689
|
-
'ptgAreaErr3d' => 0x5D,
|
690
688
|
'ptgArrayA' => 0x60,
|
691
689
|
'ptgFuncA' => 0x61,
|
692
690
|
'ptgFuncVarA' => 0x62,
|
@@ -702,13 +700,11 @@ class Formula < ExcelFormulaParser #:nodoc:
|
|
702
700
|
'ptgRefNA' => 0x6C,
|
703
701
|
'ptgAreaNA' => 0x6D,
|
704
702
|
'ptgMemAreaNA' => 0x6E,
|
705
|
-
'ptgMemNoMemN' => 0x6F,
|
706
703
|
'ptgFuncCEA' => 0x78,
|
707
704
|
'ptgNameXA' => 0x79,
|
708
705
|
'ptgRef3dA' => 0x7A,
|
709
706
|
'ptgArea3dA' => 0x7B,
|
710
|
-
'ptgRefErr3dA' => 0x7C
|
711
|
-
'ptgAreaErr3d' => 0x7D
|
707
|
+
'ptgRefErr3dA' => 0x7C
|
712
708
|
}
|
713
709
|
|
714
710
|
# Thanks to Michael Meeks and Gnumeric for the initial arg values.
|
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
|
@@ -55,8 +55,6 @@ class OLEStorageLite #:nodoc:
|
|
55
55
|
end
|
56
56
|
done << no
|
57
57
|
|
58
|
-
rootblock = info[:root_start]
|
59
|
-
|
60
58
|
#1. Get Information about itself
|
61
59
|
pps = _getNthPps(no, info, data)
|
62
60
|
|
@@ -76,7 +74,6 @@ class OLEStorageLite #:nodoc:
|
|
76
74
|
private :_getPpsTree
|
77
75
|
|
78
76
|
def _getPpsSearch(no, info, name, data, icase, done = nil)
|
79
|
-
rootblock = info[:root_start]
|
80
77
|
#1. Check it self
|
81
78
|
if done
|
82
79
|
return [] if done.include?(no)
|
@@ -589,7 +586,6 @@ class OLEStorageLitePPSRoot < OLEStorageLitePPS #:nodoc:
|
|
589
586
|
rh_info[:fileh] = sFile.binmode
|
590
587
|
end
|
591
588
|
|
592
|
-
iBlk = 0
|
593
589
|
#1. Make an array of PPS (for Save)
|
594
590
|
aList=[]
|
595
591
|
if bNoAs
|
@@ -728,7 +724,6 @@ class OLEStorageLitePPSRoot < OLEStorageLitePPS #:nodoc:
|
|
728
724
|
private :_saveHeader
|
729
725
|
|
730
726
|
def _saveBigData(iStBlk, aList, rh_info)
|
731
|
-
iRes = 0
|
732
727
|
file = rh_info[:fileh]
|
733
728
|
|
734
729
|
#1.Write Big (ge 0x1000) Data into Block
|
@@ -810,7 +805,7 @@ class OLEStorageLitePPSRoot < OLEStorageLitePPS #:nodoc:
|
|
810
805
|
aPrev = aWk[0, iPos]
|
811
806
|
aWk[0..iPos-1] = []
|
812
807
|
aNext = aWk[1, iCnt - iPos - 1]
|
813
|
-
aWk[1..(1 + iCnt - iPos -1 -1)] = []
|
808
|
+
aWk[1..(1 + iCnt - iPos - 1 - 1)] = []
|
814
809
|
pps_array[iPos].prev_pps = _savePpsSetPnt(aPrev, aList, rh_info)
|
815
810
|
pps_array[iPos].next_pps = _savePpsSetPnt(aNext, aList, rh_info)
|
816
811
|
pps_array[iPos].dir_pps = _savePpsSetPnt(pps_array[iPos].child, aList, rh_info)
|
@@ -834,12 +829,10 @@ class OLEStorageLitePPSRoot < OLEStorageLitePPS #:nodoc:
|
|
834
829
|
return pps_array[0].no
|
835
830
|
#1.3 Array
|
836
831
|
else
|
837
|
-
iCnt = pps_array.size
|
838
832
|
#1.3.1 Define Center
|
839
833
|
iPos = 0 #int($iCnt/ 2); #$iCnt
|
840
834
|
|
841
835
|
aWk = pps_array.dup
|
842
|
-
aPrev = aWk[1, 1]
|
843
836
|
aWk[1..1] = []
|
844
837
|
aNext = aWk[1..aWk.size] #, $iCnt - $iPos -1);
|
845
838
|
pps_array[iPos].prev_pps = _savePpsSetPnt2(pps_array, aList, rh_info)
|
@@ -975,7 +968,7 @@ class OLEStorageLitePPSFile < OLEStorageLitePPS #:nodoc:
|
|
975
968
|
@pps_file.binmode
|
976
969
|
end
|
977
970
|
|
978
|
-
def append
|
971
|
+
def append(data)
|
979
972
|
return if data.nil?
|
980
973
|
if @pps_file
|
981
974
|
@pps_file << data
|
data/lib/writeexcel/version.rb
CHANGED
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
|