write_xlsx 0.72.2 → 0.72.3.beta1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/{README.rdoc → Changes} +3 -94
- data/README.md +96 -0
- data/lib/write_xlsx/chart.rb +115 -259
- data/lib/write_xlsx/chart/axis.rb +4 -4
- data/lib/write_xlsx/chart/bar.rb +1 -1
- data/lib/write_xlsx/chart/column.rb +1 -1
- data/lib/write_xlsx/chart/pie.rb +3 -3
- data/lib/write_xlsx/chart/radar.rb +1 -1
- data/lib/write_xlsx/chart/scatter.rb +1 -1
- data/lib/write_xlsx/chart/series.rb +0 -37
- data/lib/write_xlsx/chartsheet.rb +25 -37
- data/lib/write_xlsx/col_name.rb +40 -0
- data/lib/write_xlsx/drawing.rb +95 -85
- data/lib/write_xlsx/format.rb +32 -32
- data/lib/write_xlsx/package/app.rb +18 -23
- data/lib/write_xlsx/package/button.rb +15 -12
- data/lib/write_xlsx/package/comments.rb +33 -30
- data/lib/write_xlsx/package/conditional_format.rb +18 -14
- data/lib/write_xlsx/package/content_types.rb +22 -17
- data/lib/write_xlsx/package/core.rb +19 -24
- data/lib/write_xlsx/package/relationships.rb +10 -13
- data/lib/write_xlsx/package/shared_strings.rb +8 -16
- data/lib/write_xlsx/package/styles.rb +59 -64
- data/lib/write_xlsx/package/table.rb +27 -37
- data/lib/write_xlsx/package/vml.rb +23 -21
- data/lib/write_xlsx/package/xml_writer_simple.rb +3 -6
- data/lib/write_xlsx/sheets.rb +4 -4
- data/lib/write_xlsx/sparkline.rb +22 -22
- data/lib/write_xlsx/utility.rb +61 -33
- data/lib/write_xlsx/version.rb +1 -1
- data/lib/write_xlsx/workbook.rb +46 -50
- data/lib/write_xlsx/worksheet.rb +149 -133
- data/lib/write_xlsx/worksheet/cell_data.rb +8 -6
- data/lib/write_xlsx/worksheet/data_validation.rb +14 -14
- data/lib/write_xlsx/worksheet/hyperlink.rb +97 -65
- data/lib/write_xlsx/worksheet/page_setup.rb +23 -22
- data/test/chart/test_write_a_latin.rb +3 -3
- data/test/regression/test_chart_font01.rb +1 -1
- data/test/regression/test_chart_font02.rb +1 -1
- data/test/regression/test_chart_font03.rb +1 -1
- data/test/regression/test_chart_font04.rb +1 -1
- data/test/regression/test_chart_font05.rb +1 -1
- data/test/regression/test_chart_font06.rb +1 -1
- data/test/test_xml_writer_simple.rb +3 -3
- data/test/worksheet/test_write_hyperlink.rb +4 -4
- data/test/worksheet/test_write_worksheet_attributes.rb +3 -3
- data/write_xlsx.gemspec +2 -1
- metadata +9 -8
- data/test/package/table/test_write_xml_declaration.rb +0 -20
data/lib/write_xlsx/version.rb
CHANGED
data/lib/write_xlsx/workbook.rb
CHANGED
@@ -242,36 +242,33 @@ def assemble_xml_file #:nodoc:
|
|
242
242
|
# Prepare format object for passing to Style.rb.
|
243
243
|
prepare_format_properties
|
244
244
|
|
245
|
-
write_xml_declaration
|
245
|
+
write_xml_declaration do
|
246
246
|
|
247
|
-
|
248
|
-
|
247
|
+
# Write the root workbook element.
|
248
|
+
write_workbook do
|
249
249
|
|
250
|
-
|
251
|
-
|
250
|
+
# Write the XLSX file version.
|
251
|
+
write_file_version
|
252
252
|
|
253
|
-
|
254
|
-
|
253
|
+
# Write the workbook properties.
|
254
|
+
write_workbook_pr
|
255
255
|
|
256
|
-
|
257
|
-
|
256
|
+
# Write the workbook view properties.
|
257
|
+
write_book_views
|
258
258
|
|
259
|
-
|
260
|
-
|
259
|
+
# Write the worksheet names and ids.
|
260
|
+
@worksheets.write_sheets(@writer)
|
261
261
|
|
262
|
-
|
263
|
-
|
262
|
+
# Write the workbook defined names.
|
263
|
+
write_defined_names
|
264
264
|
|
265
|
-
|
266
|
-
|
265
|
+
# Write the workbook calculation properties.
|
266
|
+
write_calc_pr
|
267
267
|
|
268
|
-
|
269
|
-
|
268
|
+
# Write the workbook extension storage.
|
269
|
+
#write_ext_lst
|
270
|
+
end
|
270
271
|
end
|
271
|
-
|
272
|
-
# Close the XML writer object and filehandle.
|
273
|
-
@writer.crlf
|
274
|
-
@writer.close
|
275
272
|
end
|
276
273
|
|
277
274
|
#
|
@@ -1073,17 +1070,13 @@ def get_chart_range(range) #:nodoc:
|
|
1073
1070
|
return [sheetname, row_start, col_start, row_end, col_end]
|
1074
1071
|
end
|
1075
1072
|
|
1076
|
-
def write_xml_declaration #:nodoc:
|
1077
|
-
@writer.xml_decl
|
1078
|
-
end
|
1079
|
-
|
1080
1073
|
def write_workbook #:nodoc:
|
1081
1074
|
schema = 'http://schemas.openxmlformats.org'
|
1082
1075
|
attributes = [
|
1083
|
-
'xmlns',
|
1084
|
-
|
1085
|
-
'xmlns:r',
|
1086
|
-
|
1076
|
+
['xmlns',
|
1077
|
+
schema + '/spreadsheetml/2006/main'],
|
1078
|
+
['xmlns:r',
|
1079
|
+
schema + '/officeDocument/2006/relationships']
|
1087
1080
|
]
|
1088
1081
|
@writer.tag_elements('workbook', attributes) do
|
1089
1082
|
yield
|
@@ -1092,14 +1085,14 @@ def write_workbook #:nodoc:
|
|
1092
1085
|
|
1093
1086
|
def write_file_version #:nodoc:
|
1094
1087
|
attributes = [
|
1095
|
-
|
1096
|
-
|
1097
|
-
|
1098
|
-
|
1088
|
+
['appName', 'xl'],
|
1089
|
+
['lastEdited', 4],
|
1090
|
+
['lowestEdited', 4],
|
1091
|
+
['rupBuild', 4505]
|
1099
1092
|
]
|
1100
1093
|
|
1101
1094
|
if @vba_project
|
1102
|
-
attributes << :codeName
|
1095
|
+
attributes << [:codeName, '{37E998C4-C9E5-D4B9-71C8-EB1FF731991C}']
|
1103
1096
|
end
|
1104
1097
|
|
1105
1098
|
@writer.empty_tag('fileVersion', attributes)
|
@@ -1107,9 +1100,9 @@ def write_file_version #:nodoc:
|
|
1107
1100
|
|
1108
1101
|
def write_workbook_pr #:nodoc:
|
1109
1102
|
attributes = []
|
1110
|
-
attributes << 'codeName'
|
1111
|
-
attributes << 'date1904'
|
1112
|
-
attributes << 'defaultThemeVersion'
|
1103
|
+
attributes << ['codeName', @vba_codename] if ptrue?(@vba_codename)
|
1104
|
+
attributes << ['date1904', 1] if date_1904?
|
1105
|
+
attributes << ['defaultThemeVersion', 124226]
|
1113
1106
|
@writer.empty_tag('workbookPr', attributes)
|
1114
1107
|
end
|
1115
1108
|
|
@@ -1119,25 +1112,28 @@ def write_book_views #:nodoc:
|
|
1119
1112
|
|
1120
1113
|
def write_workbook_view #:nodoc:
|
1121
1114
|
attributes = [
|
1122
|
-
|
1123
|
-
|
1124
|
-
|
1125
|
-
|
1115
|
+
['xWindow', @x_window],
|
1116
|
+
['yWindow', @y_window],
|
1117
|
+
['windowWidth', @window_width],
|
1118
|
+
['windowHeight', @window_height]
|
1126
1119
|
]
|
1127
1120
|
if @tab_ratio != 500
|
1128
|
-
attributes << 'tabRatio'
|
1121
|
+
attributes << ['tabRatio', @tab_ratio]
|
1129
1122
|
end
|
1130
1123
|
if @firstsheet > 0
|
1131
|
-
attributes << 'firstSheet'
|
1124
|
+
attributes << ['firstSheet', @firstsheet + 1]
|
1132
1125
|
end
|
1133
1126
|
if @activesheet > 0
|
1134
|
-
attributes << 'activeTab'
|
1127
|
+
attributes << ['activeTab', @activesheet]
|
1135
1128
|
end
|
1136
1129
|
@writer.empty_tag('workbookView', attributes)
|
1137
1130
|
end
|
1138
1131
|
|
1139
1132
|
def write_calc_pr #:nodoc:
|
1140
|
-
attributes = [
|
1133
|
+
attributes = [
|
1134
|
+
['calcId', 124519],
|
1135
|
+
['fullCalcOnLoad', 1]
|
1136
|
+
]
|
1141
1137
|
@writer.empty_tag('calcPr', attributes)
|
1142
1138
|
end
|
1143
1139
|
|
@@ -1147,8 +1143,8 @@ def write_ext_lst #:nodoc:
|
|
1147
1143
|
|
1148
1144
|
def write_ext #:nodoc:
|
1149
1145
|
attributes = [
|
1150
|
-
'xmlns:mx', "#{OFFICE_URL}mac/excel/2008/main",
|
1151
|
-
'uri', uri
|
1146
|
+
['xmlns:mx', "#{OFFICE_URL}mac/excel/2008/main"],
|
1147
|
+
['uri', uri]
|
1152
1148
|
]
|
1153
1149
|
@writer.tag_elements('ext', attributes) { write_mx_arch_id }
|
1154
1150
|
end
|
@@ -1167,9 +1163,9 @@ def write_defined_names #:nodoc:
|
|
1167
1163
|
def write_defined_name(defined_name) #:nodoc:
|
1168
1164
|
name, id, range, hidden = defined_name
|
1169
1165
|
|
1170
|
-
attributes = ['name', name]
|
1171
|
-
attributes << 'localSheetId'
|
1172
|
-
attributes << 'hidden'
|
1166
|
+
attributes = [ ['name', name] ]
|
1167
|
+
attributes << ['localSheetId', "#{id}"] unless id == -1
|
1168
|
+
attributes << ['hidden', '1'] if hidden
|
1173
1169
|
|
1174
1170
|
@writer.data_element('definedName', range, attributes)
|
1175
1171
|
end
|
data/lib/write_xlsx/worksheet.rb
CHANGED
@@ -372,33 +372,32 @@ def set_xml_writer(filename) #:nodoc:
|
|
372
372
|
end
|
373
373
|
|
374
374
|
def assemble_xml_file #:nodoc:
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
375
|
+
write_xml_declaration do
|
376
|
+
@writer.tag_elements('worksheet', write_worksheet_attributes) do
|
377
|
+
write_sheet_pr
|
378
|
+
write_dimension
|
379
|
+
write_sheet_views
|
380
|
+
write_sheet_format_pr
|
381
|
+
write_cols
|
382
|
+
write_sheet_data
|
383
|
+
write_sheet_protection
|
384
|
+
write_auto_filter
|
385
|
+
write_merge_cells
|
386
|
+
write_conditional_formats
|
387
|
+
write_data_validations
|
388
|
+
write_hyperlinks
|
389
|
+
write_print_options
|
390
|
+
write_page_margins
|
391
|
+
write_page_setup
|
392
|
+
write_header_footer
|
393
|
+
write_row_breaks
|
394
|
+
write_col_breaks
|
395
|
+
write_drawings
|
396
|
+
write_legacy_drawing
|
397
|
+
write_table_parts
|
398
|
+
write_ext_sparklines
|
399
|
+
end
|
399
400
|
end
|
400
|
-
@writer.crlf
|
401
|
-
@writer.close
|
402
401
|
end
|
403
402
|
|
404
403
|
#
|
@@ -2559,7 +2558,7 @@ def write_url(*args)
|
|
2559
2558
|
check_dimensions(row, col)
|
2560
2559
|
store_row_col_max_min_values(row, col)
|
2561
2560
|
|
2562
|
-
hyperlink = Hyperlink.
|
2561
|
+
hyperlink = Hyperlink.factory(url, str)
|
2563
2562
|
hyperlink.tip = tip
|
2564
2563
|
|
2565
2564
|
@hlink_count += 1
|
@@ -5681,7 +5680,12 @@ def write_cell_formula(formula = '') #:nodoc:
|
|
5681
5680
|
# Write the cell array formula <f> element.
|
5682
5681
|
#
|
5683
5682
|
def write_cell_array_formula(formula, range) #:nodoc:
|
5684
|
-
@writer.data_element('f', formula,
|
5683
|
+
@writer.data_element('f', formula,
|
5684
|
+
[
|
5685
|
+
['t', 'array'],
|
5686
|
+
['ref', range]
|
5687
|
+
]
|
5688
|
+
)
|
5685
5689
|
end
|
5686
5690
|
|
5687
5691
|
def date_1904? #:nodoc:
|
@@ -5817,7 +5821,7 @@ def xml_str_of_rich_string(fragments)
|
|
5817
5821
|
# Write the string fragment part, with whitespace handling.
|
5818
5822
|
attributes = []
|
5819
5823
|
|
5820
|
-
attributes << 'xml:space'
|
5824
|
+
attributes << ['xml:space', 'preserve'] if token =~ /^\s/ || token =~ /\s$/
|
5821
5825
|
writer.data_element('t', token, attributes)
|
5822
5826
|
writer.end_tag('r')
|
5823
5827
|
end
|
@@ -6337,13 +6341,13 @@ def encode_password(password) #:nodoc:
|
|
6337
6341
|
def write_worksheet_attributes #:nodoc:
|
6338
6342
|
schema = 'http://schemas.openxmlformats.org/'
|
6339
6343
|
attributes = [
|
6340
|
-
'xmlns', "#{schema}spreadsheetml/2006/main",
|
6341
|
-
'xmlns:r', "#{schema}officeDocument/2006/relationships"
|
6344
|
+
['xmlns', "#{schema}spreadsheetml/2006/main"],
|
6345
|
+
['xmlns:r', "#{schema}officeDocument/2006/relationships"]
|
6342
6346
|
]
|
6343
6347
|
if @excel_version == 2010
|
6344
|
-
attributes << 'xmlns:mc'
|
6345
|
-
attributes << 'xmlns:x14ac'
|
6346
|
-
attributes << 'mc:Ignorable'
|
6348
|
+
attributes << ['xmlns:mc', "#{schema}markup-compatibility/2006"]
|
6349
|
+
attributes << ['xmlns:x14ac', "#{OFFICE_URL}spreadsheetml/2009/9/ac"]
|
6350
|
+
attributes << ['mc:Ignorable', 'x14ac']
|
6347
6351
|
end
|
6348
6352
|
attributes
|
6349
6353
|
end
|
@@ -6355,8 +6359,8 @@ def write_sheet_pr #:nodoc:
|
|
6355
6359
|
return unless tab_outline_fit? || vba_codename? || filter_on?
|
6356
6360
|
|
6357
6361
|
attributes = []
|
6358
|
-
attributes << 'codeName'
|
6359
|
-
attributes << 'filterMode'
|
6362
|
+
attributes << ['codeName', @vba_codename] if vba_codename?
|
6363
|
+
attributes << ['filterMode', 1] if filter_on?
|
6360
6364
|
|
6361
6365
|
if tab_outline_fit?
|
6362
6366
|
@writer.tag_elements('sheetPr', attributes) do
|
@@ -6377,7 +6381,7 @@ def tab_outline_fit?
|
|
6377
6381
|
# Write the <pageSetUpPr> element.
|
6378
6382
|
#
|
6379
6383
|
def write_page_set_up_pr #:nodoc:
|
6380
|
-
@writer.empty_tag('pageSetUpPr', ['fitToPage', 1]) if fit_page?
|
6384
|
+
@writer.empty_tag('pageSetUpPr', [ ['fitToPage', 1] ]) if fit_page?
|
6381
6385
|
end
|
6382
6386
|
|
6383
6387
|
# Write the <dimension> element. This specifies the range of cells in the
|
@@ -6409,7 +6413,7 @@ def write_dimension #:nodoc:
|
|
6409
6413
|
cell_2 = xl_rowcol_to_cell(@dim_rowmax, @dim_colmax)
|
6410
6414
|
ref = cell_1 + ':' + cell_2
|
6411
6415
|
end
|
6412
|
-
@writer.empty_tag('dimension', ['ref', ref])
|
6416
|
+
@writer.empty_tag('dimension', [ ['ref', ref] ])
|
6413
6417
|
end
|
6414
6418
|
#
|
6415
6419
|
# Write the <sheetViews> element.
|
@@ -6421,31 +6425,31 @@ def write_sheet_views #:nodoc:
|
|
6421
6425
|
def write_sheet_view #:nodoc:
|
6422
6426
|
attributes = []
|
6423
6427
|
# Hide screen gridlines if required
|
6424
|
-
attributes << 'showGridLines'
|
6428
|
+
attributes << ['showGridLines', 0] unless @screen_gridlines
|
6425
6429
|
|
6426
6430
|
# Hide zeroes in cells.
|
6427
|
-
attributes << 'showZeros'
|
6431
|
+
attributes << ['showZeros', 0] unless show_zeros?
|
6428
6432
|
|
6429
6433
|
# Display worksheet right to left for Hebrew, Arabic and others.
|
6430
|
-
attributes << 'rightToLeft'
|
6434
|
+
attributes << ['rightToLeft', 1] if @right_to_left
|
6431
6435
|
|
6432
6436
|
# Show that the sheet tab is selected.
|
6433
|
-
attributes << 'tabSelected'
|
6437
|
+
attributes << ['tabSelected', 1] if @selected
|
6434
6438
|
|
6435
6439
|
# Turn outlines off. Also required in the outlinePr element.
|
6436
|
-
attributes << "showOutlineSymbols"
|
6440
|
+
attributes << ["showOutlineSymbols", 0] if @outline_on
|
6437
6441
|
|
6438
6442
|
# Set the page view/layout mode if required.
|
6439
6443
|
# TODO. Add pageBreakPreview mode when requested.
|
6440
|
-
|
6444
|
+
attributes << ['view', 'pageLayout'] if page_view?
|
6441
6445
|
|
6442
6446
|
# Set the zoom level.
|
6443
6447
|
if @zoom != 100
|
6444
|
-
|
6445
|
-
|
6448
|
+
attributes << ['zoomScale', @zoom] unless page_view?
|
6449
|
+
attributes << ['zoomScaleNormal', @zoom] if zoom_scale_normal?
|
6446
6450
|
end
|
6447
6451
|
|
6448
|
-
attributes << 'workbookViewId'
|
6452
|
+
attributes << ['workbookViewId', 0]
|
6449
6453
|
|
6450
6454
|
if @panes.empty? && @selections.empty?
|
6451
6455
|
@writer.empty_tag('sheetView', attributes)
|
@@ -6469,9 +6473,9 @@ def write_selections #:nodoc:
|
|
6469
6473
|
#
|
6470
6474
|
def write_selection(pane, active_cell, sqref) #:nodoc:
|
6471
6475
|
attributes = []
|
6472
|
-
|
6473
|
-
|
6474
|
-
|
6476
|
+
attributes << ['pane', pane] if pane
|
6477
|
+
attributes << ['activeCell', active_cell] if active_cell
|
6478
|
+
attributes << ['sqref', sqref] if sqref
|
6475
6479
|
|
6476
6480
|
@writer.empty_tag('selection', attributes)
|
6477
6481
|
end
|
@@ -6482,19 +6486,21 @@ def write_selection(pane, active_cell, sqref) #:nodoc:
|
|
6482
6486
|
def write_sheet_format_pr #:nodoc:
|
6483
6487
|
base_col_width = 10
|
6484
6488
|
|
6485
|
-
attributes = [
|
6489
|
+
attributes = [
|
6490
|
+
['defaultRowHeight', @default_row_height]
|
6491
|
+
]
|
6486
6492
|
if @default_row_height != 15
|
6487
|
-
attributes << 'customHeight'
|
6493
|
+
attributes << ['customHeight', 1]
|
6488
6494
|
end
|
6489
6495
|
|
6490
6496
|
if ptrue?(@default_row_zeroed)
|
6491
|
-
attributes << 'zeroHeight'
|
6497
|
+
attributes << ['zeroHeight', 1]
|
6492
6498
|
end
|
6493
6499
|
|
6494
|
-
attributes << 'outlineLevelRow'
|
6495
|
-
attributes << 'outlineLevelCol'
|
6500
|
+
attributes << ['outlineLevelRow', @outline_row_level] if @outline_row_level > 0
|
6501
|
+
attributes << ['outlineLevelCol', @outline_col_level] if @outline_col_level > 0
|
6496
6502
|
if @excel_version == 2010
|
6497
|
-
attributes << 'x14ac:dyDescent'
|
6503
|
+
attributes << ['x14ac:dyDescent', '0.25']
|
6498
6504
|
end
|
6499
6505
|
@writer.empty_tag('sheetFormatPr', attributes)
|
6500
6506
|
end
|
@@ -6547,16 +6553,16 @@ def col_info_attributes(args)
|
|
6547
6553
|
width = width.to_i if width - width.to_i == 0
|
6548
6554
|
|
6549
6555
|
attributes = [
|
6550
|
-
'min', min + 1,
|
6551
|
-
'max', max + 1,
|
6552
|
-
'width', width
|
6556
|
+
['min', min + 1],
|
6557
|
+
['max', max + 1],
|
6558
|
+
['width', width]
|
6553
6559
|
]
|
6554
6560
|
|
6555
|
-
attributes << 'style'
|
6556
|
-
attributes << 'hidden'
|
6557
|
-
attributes << 'customWidth'
|
6558
|
-
attributes << 'outlineLevel'
|
6559
|
-
attributes << 'collapsed'
|
6561
|
+
attributes << ['style', xf_index] if xf_index != 0
|
6562
|
+
attributes << ['hidden', 1] if hidden != 0
|
6563
|
+
attributes << ['customWidth', 1] if custom_width
|
6564
|
+
attributes << ['outlineLevel', level] if level != 0
|
6565
|
+
attributes << ['collapsed', 1] if collapsed != 0
|
6560
6566
|
attributes
|
6561
6567
|
end
|
6562
6568
|
|
@@ -6633,19 +6639,19 @@ def row_attributes(args)
|
|
6633
6639
|
level ||= 0
|
6634
6640
|
xf_index = format ? format.get_xf_index : 0
|
6635
6641
|
|
6636
|
-
attributes = ['r', r + 1]
|
6642
|
+
attributes = [['r', r + 1]]
|
6637
6643
|
|
6638
|
-
|
6639
|
-
|
6640
|
-
|
6641
|
-
|
6642
|
-
|
6643
|
-
|
6644
|
-
|
6645
|
-
|
6644
|
+
attributes << ['spans', spans] if spans
|
6645
|
+
attributes << ['s', xf_index] if ptrue?(xf_index)
|
6646
|
+
attributes << ['customFormat', 1] if ptrue?(format)
|
6647
|
+
attributes << ['ht', height] if height != 15
|
6648
|
+
attributes << ['hidden', 1] if ptrue?(hidden)
|
6649
|
+
attributes << ['customHeight', 1] if height != 15
|
6650
|
+
attributes << ['outlineLevel', level] if ptrue?(level)
|
6651
|
+
attributes << ['collapsed', 1] if ptrue?(collapsed)
|
6646
6652
|
|
6647
6653
|
if @excel_version == 2010
|
6648
|
-
attributes << 'x14ac:dyDescent'
|
6654
|
+
attributes << ['x14ac:dyDescent', '0.25']
|
6649
6655
|
end
|
6650
6656
|
attributes
|
6651
6657
|
end
|
@@ -6691,11 +6697,11 @@ def write_freeze_panes(row, col, top_row, left_col, type) #:nodoc:
|
|
6691
6697
|
end
|
6692
6698
|
|
6693
6699
|
attributes = []
|
6694
|
-
|
6695
|
-
|
6696
|
-
attributes << 'topLeftCell'
|
6697
|
-
attributes << 'activePane'
|
6698
|
-
attributes << 'state'
|
6700
|
+
attributes << ['xSplit', x_split] if x_split > 0
|
6701
|
+
attributes << ['ySplit', y_split] if y_split > 0
|
6702
|
+
attributes << ['topLeftCell', top_left_cell]
|
6703
|
+
attributes << ['activePane', active_pane]
|
6704
|
+
attributes << ['state', state]
|
6699
6705
|
|
6700
6706
|
@writer.empty_tag('pane', attributes)
|
6701
6707
|
end
|
@@ -6739,10 +6745,10 @@ def write_split_panes(row, col, top_row, left_col, type) #:nodoc:
|
|
6739
6745
|
active_pane = set_active_pane_and_cell_selections(row, col, top_row, left_col, active_cell, sqref)
|
6740
6746
|
|
6741
6747
|
attributes = []
|
6742
|
-
|
6743
|
-
|
6744
|
-
attributes << 'topLeftCell'
|
6745
|
-
|
6748
|
+
attributes << ['xSplit', x_split] if x_split > 0
|
6749
|
+
attributes << ['ySplit', y_split] if y_split > 0
|
6750
|
+
attributes << ['topLeftCell', top_left_cell]
|
6751
|
+
attributes << ['activePane', active_pane] if has_selection
|
6746
6752
|
|
6747
6753
|
@writer.empty_tag('pane', attributes)
|
6748
6754
|
end
|
@@ -6772,7 +6778,7 @@ def calculate_x_split_width(width) #:nodoc:
|
|
6772
6778
|
# Write the <sheetCalcPr> element for the worksheet calculation properties.
|
6773
6779
|
#
|
6774
6780
|
def write_sheet_calc_pr #:nodoc:
|
6775
|
-
@writer.empty_tag('sheetCalcPr', ['fullCalcOnLoad', 1])
|
6781
|
+
@writer.empty_tag('sheetCalcPr', [ ['fullCalcOnLoad', 1] ])
|
6776
6782
|
end
|
6777
6783
|
|
6778
6784
|
#
|
@@ -6780,8 +6786,8 @@ def write_sheet_calc_pr #:nodoc:
|
|
6780
6786
|
#
|
6781
6787
|
def write_phonetic_pr #:nodoc:
|
6782
6788
|
attributes = [
|
6783
|
-
'fontId', 1,
|
6784
|
-
'type', 'noConversion'
|
6789
|
+
['fontId', 1],
|
6790
|
+
['type', 'noConversion']
|
6785
6791
|
]
|
6786
6792
|
|
6787
6793
|
@writer.empty_tag('phoneticPr', attributes)
|
@@ -6813,7 +6819,7 @@ def write_merge_cells #:nodoc:
|
|
6813
6819
|
def write_some_elements(tag, container)
|
6814
6820
|
return if container.empty?
|
6815
6821
|
|
6816
|
-
@writer.tag_elements(tag, ['count', container.size]) do
|
6822
|
+
@writer.tag_elements(tag, [ ['count', container.size] ]) do
|
6817
6823
|
yield
|
6818
6824
|
end
|
6819
6825
|
end
|
@@ -6828,7 +6834,7 @@ def write_merge_cell(merged_range) #:nodoc:
|
|
6828
6834
|
cell_1 = xl_rowcol_to_cell(row_min, col_min)
|
6829
6835
|
cell_2 = xl_rowcol_to_cell(row_max, col_max)
|
6830
6836
|
|
6831
|
-
@writer.empty_tag('mergeCell', ['ref', "#{cell_1}:#{cell_2}"])
|
6837
|
+
@writer.empty_tag('mergeCell', [ ['ref', "#{cell_1}:#{cell_2}"] ])
|
6832
6838
|
end
|
6833
6839
|
|
6834
6840
|
#
|
@@ -6874,7 +6880,10 @@ def write_breaks(tag) # :nodoc:
|
|
6874
6880
|
|
6875
6881
|
return if page_breaks.empty?
|
6876
6882
|
|
6877
|
-
attributes = [
|
6883
|
+
attributes = [
|
6884
|
+
['count', count],
|
6885
|
+
['manualBreakCount', count]
|
6886
|
+
]
|
6878
6887
|
|
6879
6888
|
@writer.tag_elements(tag, attributes) do
|
6880
6889
|
page_breaks.each { |num| write_brk(num, max) }
|
@@ -6885,9 +6894,9 @@ def write_breaks(tag) # :nodoc:
|
|
6885
6894
|
#
|
6886
6895
|
def write_brk(id, max) #:nodoc:
|
6887
6896
|
attributes = [
|
6888
|
-
'id', id,
|
6889
|
-
'max', max,
|
6890
|
-
'man', 1
|
6897
|
+
['id', id],
|
6898
|
+
['max', max],
|
6899
|
+
['man', 1]
|
6891
6900
|
]
|
6892
6901
|
|
6893
6902
|
@writer.empty_tag('brk', attributes)
|
@@ -6899,7 +6908,9 @@ def write_brk(id, max) #:nodoc:
|
|
6899
6908
|
def write_auto_filter #:nodoc:
|
6900
6909
|
return unless autofilter_ref?
|
6901
6910
|
|
6902
|
-
attributes = [
|
6911
|
+
attributes = [
|
6912
|
+
['ref', @autofilter_ref]
|
6913
|
+
]
|
6903
6914
|
|
6904
6915
|
if filter_on?
|
6905
6916
|
# Autofilter defined active filters.
|
@@ -6936,7 +6947,7 @@ def write_autofilters #:nodoc:
|
|
6936
6947
|
# Write the <filterColumn> element.
|
6937
6948
|
#
|
6938
6949
|
def write_filter_column(col_id, type, *filters) #:nodoc:
|
6939
|
-
@writer.tag_elements('filterColumn', ['colId', col_id]) do
|
6950
|
+
@writer.tag_elements('filterColumn', [ ['colId', col_id] ]) do
|
6940
6951
|
if type == 1
|
6941
6952
|
# Type == 1 is the new XLSX style filter.
|
6942
6953
|
write_filters(*filters)
|
@@ -6953,7 +6964,7 @@ def write_filter_column(col_id, type, *filters) #:nodoc:
|
|
6953
6964
|
def write_filters(*filters) #:nodoc:
|
6954
6965
|
if filters.size == 1 && filters[0] == 'blanks'
|
6955
6966
|
# Special case for blank cells only.
|
6956
|
-
@writer.empty_tag('filters', ['blank', 1])
|
6967
|
+
@writer.empty_tag('filters', [ ['blank', 1] ])
|
6957
6968
|
else
|
6958
6969
|
# General case.
|
6959
6970
|
@writer.tag_elements('filters') do
|
@@ -6966,7 +6977,7 @@ def write_filters(*filters) #:nodoc:
|
|
6966
6977
|
# Write the <filter> element.
|
6967
6978
|
#
|
6968
6979
|
def write_filter(val) #:nodoc:
|
6969
|
-
@writer.empty_tag('filter', ['val', val])
|
6980
|
+
@writer.empty_tag('filter', [ ['val', val] ])
|
6970
6981
|
end
|
6971
6982
|
|
6972
6983
|
#
|
@@ -6981,9 +6992,9 @@ def write_custom_filters(*tokens) #:nodoc:
|
|
6981
6992
|
|
6982
6993
|
# Check if the "join" operand is "and" or "or".
|
6983
6994
|
if tokens[2] == 0
|
6984
|
-
attributes = ['and', 1]
|
6995
|
+
attributes = [ ['and', 1] ]
|
6985
6996
|
else
|
6986
|
-
attributes = ['and', 0]
|
6997
|
+
attributes = [ ['and', 0] ]
|
6987
6998
|
end
|
6988
6999
|
|
6989
7000
|
# Write the two custom filters.
|
@@ -7017,8 +7028,8 @@ def write_custom_filter(operator, val) #:nodoc:
|
|
7017
7028
|
|
7018
7029
|
# The 'equal' operator is the default attribute and isn't stored.
|
7019
7030
|
attributes = []
|
7020
|
-
attributes << 'operator'
|
7021
|
-
attributes << 'val'
|
7031
|
+
attributes << ['operator', operator] unless operator == 'equal'
|
7032
|
+
attributes << ['val', val]
|
7022
7033
|
|
7023
7034
|
@writer.empty_tag('customFilter', attributes)
|
7024
7035
|
end
|
@@ -7096,7 +7107,10 @@ def write_hyperlink_internal(link, row, col) #:nodoc:
|
|
7096
7107
|
def write_tab_color #:nodoc:
|
7097
7108
|
return unless tab_color?
|
7098
7109
|
|
7099
|
-
@writer.empty_tag('tabColor',
|
7110
|
+
@writer.empty_tag('tabColor',
|
7111
|
+
[
|
7112
|
+
['rgb', get_palette_color(@tab_color)]
|
7113
|
+
])
|
7100
7114
|
end
|
7101
7115
|
|
7102
7116
|
#
|
@@ -7106,10 +7120,10 @@ def write_outline_pr
|
|
7106
7120
|
return unless outline_changed?
|
7107
7121
|
|
7108
7122
|
attributes = []
|
7109
|
-
attributes << "applyStyles"
|
7110
|
-
attributes << "summaryBelow"
|
7111
|
-
attributes << "summaryRight"
|
7112
|
-
attributes << "showOutlineSymbols"
|
7123
|
+
attributes << ["applyStyles", 1] if @outline_style != 0
|
7124
|
+
attributes << ["summaryBelow", 0] if @outline_below == 0
|
7125
|
+
attributes << ["summaryRight", 0] if @outline_right == 0
|
7126
|
+
attributes << ["showOutlineSymbols", 0] if @outline_on == 0
|
7113
7127
|
|
7114
7128
|
@writer.empty_tag('outlinePr', attributes)
|
7115
7129
|
end
|
@@ -7121,27 +7135,27 @@ def write_sheet_protection #:nodoc:
|
|
7121
7135
|
return unless protect?
|
7122
7136
|
|
7123
7137
|
attributes = []
|
7124
|
-
attributes << "password"
|
7125
|
-
attributes << "sheet"
|
7126
|
-
attributes << "content"
|
7127
|
-
attributes << "objects"
|
7128
|
-
attributes << "scenarios"
|
7129
|
-
attributes << "formatCells"
|
7130
|
-
attributes << "formatColumns"
|
7131
|
-
attributes << "formatRows"
|
7132
|
-
attributes << "insertColumns"
|
7133
|
-
attributes << "insertRows"
|
7134
|
-
attributes << "insertHyperlinks"
|
7135
|
-
attributes << "deleteColumns"
|
7136
|
-
attributes << "deleteRows"
|
7137
|
-
|
7138
|
-
attributes << "selectLockedCells"
|
7139
|
-
|
7140
|
-
attributes << "sort"
|
7141
|
-
attributes << "autoFilter"
|
7142
|
-
attributes << "pivotTables"
|
7143
|
-
|
7144
|
-
attributes << "selectUnlockedCells"
|
7138
|
+
attributes << ["password", @protect[:password]] if ptrue?(@protect[:password])
|
7139
|
+
attributes << ["sheet", 1] if ptrue?(@protect[:sheet])
|
7140
|
+
attributes << ["content", 1] if ptrue?(@protect[:content])
|
7141
|
+
attributes << ["objects", 1] unless ptrue?(@protect[:objects])
|
7142
|
+
attributes << ["scenarios", 1] unless ptrue?(@protect[:scenarios])
|
7143
|
+
attributes << ["formatCells", 0] if ptrue?(@protect[:format_cells])
|
7144
|
+
attributes << ["formatColumns", 0] if ptrue?(@protect[:format_columns])
|
7145
|
+
attributes << ["formatRows", 0] if ptrue?(@protect[:format_rows])
|
7146
|
+
attributes << ["insertColumns", 0] if ptrue?(@protect[:insert_columns])
|
7147
|
+
attributes << ["insertRows", 0] if ptrue?(@protect[:insert_rows])
|
7148
|
+
attributes << ["insertHyperlinks", 0] if ptrue?(@protect[:insert_hyperlinks])
|
7149
|
+
attributes << ["deleteColumns", 0] if ptrue?(@protect[:delete_columns])
|
7150
|
+
attributes << ["deleteRows", 0] if ptrue?(@protect[:delete_rows])
|
7151
|
+
|
7152
|
+
attributes << ["selectLockedCells", 1] unless ptrue?(@protect[:select_locked_cells])
|
7153
|
+
|
7154
|
+
attributes << ["sort", 0] if ptrue?(@protect[:sort])
|
7155
|
+
attributes << ["autoFilter", 0] if ptrue?(@protect[:autofilter])
|
7156
|
+
attributes << ["pivotTables", 0] if ptrue?(@protect[:pivot_tables])
|
7157
|
+
|
7158
|
+
attributes << ["selectUnlockedCells", 1] unless ptrue?(@protect[:select_unlocked_cells])
|
7145
7159
|
|
7146
7160
|
@writer.empty_tag('sheetProtection', attributes)
|
7147
7161
|
end
|
@@ -7173,7 +7187,7 @@ def write_underline(writer, underline) #:nodoc:
|
|
7173
7187
|
def write_table_parts
|
7174
7188
|
return if @tables.empty?
|
7175
7189
|
|
7176
|
-
@writer.tag_elements('tableParts', ['count', tables_count]) do
|
7190
|
+
@writer.tag_elements('tableParts', [ ['count', tables_count] ]) do
|
7177
7191
|
tables_count.times { increment_rel_id_and_write_r_id('tablePart') }
|
7178
7192
|
end
|
7179
7193
|
end
|
@@ -7182,7 +7196,7 @@ def write_table_parts
|
|
7182
7196
|
# Write the <tablePart> element.
|
7183
7197
|
#
|
7184
7198
|
def write_table_part(id)
|
7185
|
-
@writer.empty_tag('tablePart', r_id_attributes(id))
|
7199
|
+
@writer.empty_tag('tablePart', [r_id_attributes(id)])
|
7186
7200
|
end
|
7187
7201
|
|
7188
7202
|
def increment_rel_id_and_write_r_id(tag)
|
@@ -7191,7 +7205,7 @@ def increment_rel_id_and_write_r_id(tag)
|
|
7191
7205
|
end
|
7192
7206
|
|
7193
7207
|
def write_r_id(tag, id)
|
7194
|
-
@writer.empty_tag(tag, r_id_attributes(id))
|
7208
|
+
@writer.empty_tag(tag, [r_id_attributes(id)])
|
7195
7209
|
end
|
7196
7210
|
|
7197
7211
|
#
|
@@ -7209,8 +7223,8 @@ def write_ext
|
|
7209
7223
|
|
7210
7224
|
def write_ext_attributes
|
7211
7225
|
[
|
7212
|
-
'xmlns:x14', "#{OFFICE_URL}spreadsheetml/2009/9/main",
|
7213
|
-
'uri', '{05C60535-1F16-4fd2-B633-F4F36F0B64E0}'
|
7226
|
+
['xmlns:x14', "#{OFFICE_URL}spreadsheetml/2009/9/main"],
|
7227
|
+
['uri', '{05C60535-1F16-4fd2-B633-F4F36F0B64E0}']
|
7214
7228
|
]
|
7215
7229
|
end
|
7216
7230
|
|
@@ -7225,7 +7239,9 @@ def write_sparkline_groups
|
|
7225
7239
|
end
|
7226
7240
|
|
7227
7241
|
def sparkline_groups_attributes # :nodoc:
|
7228
|
-
[
|
7242
|
+
[
|
7243
|
+
['xmlns:xm', "#{OFFICE_URL}excel/2006/main"]
|
7244
|
+
]
|
7229
7245
|
end
|
7230
7246
|
|
7231
7247
|
#
|
@@ -7250,7 +7266,7 @@ def write_conditional_formats #:nodoc:
|
|
7250
7266
|
# Write the <conditionalFormatting> element.
|
7251
7267
|
#
|
7252
7268
|
def write_conditional_formatting(range, cond_formats) #:nodoc:
|
7253
|
-
@writer.tag_elements('conditionalFormatting', ['sqref', range]) do
|
7269
|
+
@writer.tag_elements('conditionalFormatting', [ ['sqref', range] ]) do
|
7254
7270
|
cond_formats.each { |cond_format| cond_format.write_cf_rule }
|
7255
7271
|
end
|
7256
7272
|
end
|