xlsxrb 0.2.1 → 0.2.2
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 +4 -4
- data/CHANGELOG.md +51 -0
- data/README.md +24 -2
- data/lib/xlsxrb/dsl_helpers.rb +16 -0
- data/lib/xlsxrb/elements/styles.rb +15 -6
- data/lib/xlsxrb/number_formatter.rb +26 -8
- data/lib/xlsxrb/ooxml/cfb.rb +11 -3
- data/lib/xlsxrb/ooxml/crypto/agile.rb +48 -10
- data/lib/xlsxrb/ooxml/crypto/standard.rb +5 -1
- data/lib/xlsxrb/ooxml/crypto.rb +3 -0
- data/lib/xlsxrb/ooxml/shared_strings_parser.rb +26 -8
- data/lib/xlsxrb/ooxml/workbook_writer.rb +30 -19
- data/lib/xlsxrb/ooxml/worksheet_parser.rb +116 -12
- data/lib/xlsxrb/ooxml/worksheet_writer.rb +43 -38
- data/lib/xlsxrb/ooxml/writer/drawing_xml.rb +206 -201
- data/lib/xlsxrb/ooxml/writer/features_xml.rb +99 -99
- data/lib/xlsxrb/ooxml/writer/styles_xml.rb +46 -46
- data/lib/xlsxrb/ooxml/writer.rb +166 -159
- data/lib/xlsxrb/ooxml/xml_builder.rb +17 -7
- data/lib/xlsxrb/ooxml/xml_parser.rb +34 -1
- data/lib/xlsxrb/ooxml/zip_reader.rb +95 -68
- data/lib/xlsxrb/ooxml/zip_writer.rb +16 -0
- data/lib/xlsxrb/stream_sheet.rb +26 -11
- data/lib/xlsxrb/stream_writer.rb +9 -6
- data/lib/xlsxrb/version.rb +1 -1
- data/lib/xlsxrb/worksheet_builder.rb +6 -5
- data/lib/xlsxrb.rb +68 -21
- data/sig/generated/xlsxrb/dsl_helpers.rbs +9 -0
- data/sig/generated/xlsxrb/elements/styles.rbs +5 -0
- data/sig/generated/xlsxrb/number_formatter.rbs +7 -0
- data/sig/generated/xlsxrb/ooxml/cfb.rbs +2 -0
- data/sig/generated/xlsxrb/ooxml/crypto/agile.rbs +10 -0
- data/sig/generated/xlsxrb/ooxml/shared_strings_parser.rbs +7 -0
- data/sig/generated/xlsxrb/ooxml/workbook_writer.rbs +8 -0
- data/sig/generated/xlsxrb/ooxml/worksheet_parser.rbs +40 -0
- data/sig/generated/xlsxrb/ooxml/writer.rbs +4 -0
- data/sig/generated/xlsxrb/ooxml/xml_builder.rbs +7 -2
- data/sig/generated/xlsxrb/ooxml/xml_parser.rbs +10 -0
- data/sig/generated/xlsxrb/ooxml/zip_reader.rbs +12 -1
- data/sig/generated/xlsxrb/ooxml/zip_writer.rbs +8 -0
- data/sig/generated/xlsxrb/stream_sheet.rbs +9 -0
- data/sig/generated/xlsxrb/stream_writer.rbs +6 -2
- data/sig/generated/xlsxrb/worksheet_builder.rbs +3 -1
- data/sig/generated/xlsxrb.rbs +38 -8
- metadata +9 -3
data/lib/xlsxrb/ooxml/writer.rb
CHANGED
|
@@ -2129,6 +2129,13 @@ module Xlsxrb
|
|
|
2129
2129
|
combo: "comboChart", column: "barChart"
|
|
2130
2130
|
}.freeze
|
|
2131
2131
|
|
|
2132
|
+
# The elements of EG_ColorTransform in DrawingML. A transform's type is written as an
|
|
2133
|
+
# element name, so only these are accepted.
|
|
2134
|
+
COLOR_TRANSFORMS = %w[
|
|
2135
|
+
tint shade comp inv gray alpha alphaOff alphaMod hue hueOff hueMod sat satOff satMod
|
|
2136
|
+
lum lumOff lumMod red redOff redMod green greenOff greenMod blue blueOff blueMod gamma invGamma
|
|
2137
|
+
].freeze
|
|
2138
|
+
|
|
2132
2139
|
NO_AXIS_CHARTS = %w[pieChart doughnutChart pie3DChart ofPieChart].freeze
|
|
2133
2140
|
THREE_AXIS_CHARTS = %w[surface3DChart].freeze
|
|
2134
2141
|
GROUPING_CHARTS = %w[barChart lineChart areaChart bar3DChart line3DChart area3DChart].freeze
|
|
@@ -2239,8 +2246,8 @@ module Xlsxrb
|
|
|
2239
2246
|
overrides.merge!(@extra_ct_overrides) { |_k, generated, _extra| generated }
|
|
2240
2247
|
|
|
2241
2248
|
parts = [XML_HEADER, %(<Types xmlns="#{CT_NS}">)]
|
|
2242
|
-
defaults.each { |ext, ct| parts << %(<Default Extension="#{ext}" ContentType="#{ct}"/>) }
|
|
2243
|
-
overrides.each { |pn, ct| parts << %(<Override PartName="#{pn}" ContentType="#{ct}"/>) }
|
|
2249
|
+
defaults.each { |ext, ct| parts << %(<Default Extension="#{xml_escape(ext)}" ContentType="#{xml_escape(ct)}"/>) }
|
|
2250
|
+
overrides.each { |pn, ct| parts << %(<Override PartName="#{xml_escape(pn)}" ContentType="#{xml_escape(ct)}"/>) }
|
|
2244
2251
|
parts << "</Types>"
|
|
2245
2252
|
parts.join
|
|
2246
2253
|
end
|
|
@@ -2251,19 +2258,19 @@ module Xlsxrb
|
|
|
2251
2258
|
parts = [
|
|
2252
2259
|
XML_HEADER,
|
|
2253
2260
|
%(<Relationships xmlns="#{REL_NS}">),
|
|
2254
|
-
%(<Relationship Id="rId#{rid_counter}" Type="#{DOC_REL_NS}/officeDocument" Target="xl/workbook.xml"/>)
|
|
2261
|
+
%(<Relationship Id="rId#{xml_escape(rid_counter)}" Type="#{DOC_REL_NS}/officeDocument" Target="xl/workbook.xml"/>)
|
|
2255
2262
|
]
|
|
2256
2263
|
unless @core_properties.empty?
|
|
2257
2264
|
rid_counter += 1
|
|
2258
|
-
parts << %(<Relationship Id="rId#{rid_counter}" Type="http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties" Target="docProps/core.xml"/>)
|
|
2265
|
+
parts << %(<Relationship Id="rId#{xml_escape(rid_counter)}" Type="http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties" Target="docProps/core.xml"/>)
|
|
2259
2266
|
end
|
|
2260
2267
|
if @app_properties.any?
|
|
2261
2268
|
rid_counter += 1
|
|
2262
|
-
parts << %(<Relationship Id="rId#{rid_counter}" Type="#{DOC_REL_NS}/extended-properties" Target="docProps/app.xml"/>)
|
|
2269
|
+
parts << %(<Relationship Id="rId#{xml_escape(rid_counter)}" Type="#{DOC_REL_NS}/extended-properties" Target="docProps/app.xml"/>)
|
|
2263
2270
|
end
|
|
2264
2271
|
unless @custom_properties.empty?
|
|
2265
2272
|
rid_counter += 1
|
|
2266
|
-
parts << %(<Relationship Id="rId#{rid_counter}" Type="#{DOC_REL_NS}/custom-properties" Target="docProps/custom.xml"/>)
|
|
2273
|
+
parts << %(<Relationship Id="rId#{xml_escape(rid_counter)}" Type="#{DOC_REL_NS}/custom-properties" Target="docProps/custom.xml"/>)
|
|
2267
2274
|
end
|
|
2268
2275
|
parts << "</Relationships>"
|
|
2269
2276
|
parts.join
|
|
@@ -2272,7 +2279,7 @@ module Xlsxrb
|
|
|
2272
2279
|
# : (?::Integer pivot_cache_count) -> untyped
|
|
2273
2280
|
def generate_workbook_xml(pivot_cache_count = 0)
|
|
2274
2281
|
wb_attrs = %(xmlns="#{SSML_NS}" xmlns:r="#{DOC_REL_NS}")
|
|
2275
|
-
wb_attrs << %( conformance="#{@workbook_properties[:conformance]}") if @workbook_properties[:conformance]
|
|
2282
|
+
wb_attrs << %( conformance="#{xml_escape(@workbook_properties[:conformance])}") if @workbook_properties[:conformance]
|
|
2276
2283
|
parts = [
|
|
2277
2284
|
XML_HEADER,
|
|
2278
2285
|
"<workbook #{wb_attrs}>"
|
|
@@ -2282,9 +2289,9 @@ module Xlsxrb
|
|
|
2282
2289
|
unless @file_version.empty?
|
|
2283
2290
|
fv_attrs = []
|
|
2284
2291
|
fv_attrs << %(appName="#{xml_escape(@file_version[:app_name])}") if @file_version[:app_name]
|
|
2285
|
-
fv_attrs << %(lastEdited="#{@file_version[:last_edited]}") if @file_version[:last_edited]
|
|
2286
|
-
fv_attrs << %(lowestEdited="#{@file_version[:lowest_edited]}") if @file_version[:lowest_edited]
|
|
2287
|
-
fv_attrs << %(rupBuild="#{@file_version[:rup_build]}") if @file_version[:rup_build]
|
|
2292
|
+
fv_attrs << %(lastEdited="#{xml_escape(@file_version[:last_edited])}") if @file_version[:last_edited]
|
|
2293
|
+
fv_attrs << %(lowestEdited="#{xml_escape(@file_version[:lowest_edited])}") if @file_version[:lowest_edited]
|
|
2294
|
+
fv_attrs << %(rupBuild="#{xml_escape(@file_version[:rup_build])}") if @file_version[:rup_build]
|
|
2288
2295
|
fv_attrs << %(codeName="#{xml_escape(@file_version[:code_name])}") if @file_version[:code_name]
|
|
2289
2296
|
parts << "<fileVersion #{fv_attrs.join(" ")}/>" unless fv_attrs.empty?
|
|
2290
2297
|
end
|
|
@@ -2295,9 +2302,9 @@ module Xlsxrb
|
|
|
2295
2302
|
fs_attrs << 'readOnlyRecommended="1"' if @file_sharing[:read_only_recommended]
|
|
2296
2303
|
fs_attrs << %(userName="#{xml_escape(@file_sharing[:user_name])}") if @file_sharing[:user_name]
|
|
2297
2304
|
fs_attrs << %(algorithmName="#{xml_escape(@file_sharing[:algorithm_name])}") if @file_sharing[:algorithm_name]
|
|
2298
|
-
fs_attrs << %(hashValue="#{@file_sharing[:hash_value]}") if @file_sharing[:hash_value]
|
|
2299
|
-
fs_attrs << %(saltValue="#{@file_sharing[:salt_value]}") if @file_sharing[:salt_value]
|
|
2300
|
-
fs_attrs << %(spinCount="#{@file_sharing[:spin_count]}") if @file_sharing[:spin_count]
|
|
2305
|
+
fs_attrs << %(hashValue="#{xml_escape(@file_sharing[:hash_value])}") if @file_sharing[:hash_value]
|
|
2306
|
+
fs_attrs << %(saltValue="#{xml_escape(@file_sharing[:salt_value])}") if @file_sharing[:salt_value]
|
|
2307
|
+
fs_attrs << %(spinCount="#{xml_escape(@file_sharing[:spin_count])}") if @file_sharing[:spin_count]
|
|
2301
2308
|
parts << "<fileSharing #{fs_attrs.join(" ")}/>" unless fs_attrs.empty?
|
|
2302
2309
|
end
|
|
2303
2310
|
|
|
@@ -2306,7 +2313,7 @@ module Xlsxrb
|
|
|
2306
2313
|
attrs = []
|
|
2307
2314
|
attrs << %(date1904="#{@workbook_properties[:date1904] ? 1 : 0}") unless @workbook_properties[:date1904].nil?
|
|
2308
2315
|
attrs << %(dateCompatibility="0") if @workbook_properties[:date_compatibility] == false
|
|
2309
|
-
attrs << %(defaultThemeVersion="#{@workbook_properties[:default_theme_version]}") if @workbook_properties[:default_theme_version]
|
|
2316
|
+
attrs << %(defaultThemeVersion="#{xml_escape(@workbook_properties[:default_theme_version])}") if @workbook_properties[:default_theme_version]
|
|
2310
2317
|
attrs << %(codeName="#{xml_escape(@workbook_properties[:code_name])}") if @workbook_properties[:code_name]
|
|
2311
2318
|
attrs << %(filterPrivacy="1") if @workbook_properties[:filter_privacy]
|
|
2312
2319
|
attrs << %(autoCompressPictures="0") if @workbook_properties[:auto_compress_pictures] == false
|
|
@@ -2329,7 +2336,7 @@ module Xlsxrb
|
|
|
2329
2336
|
# bookViews/workbookView
|
|
2330
2337
|
unless @workbook_views.empty?
|
|
2331
2338
|
attrs = []
|
|
2332
|
-
attrs << %(visibility="#{@workbook_views[:visibility]}") if @workbook_views[:visibility]
|
|
2339
|
+
attrs << %(visibility="#{xml_escape(@workbook_views[:visibility])}") if @workbook_views[:visibility]
|
|
2333
2340
|
attrs << 'minimized="1"' if @workbook_views[:minimized]
|
|
2334
2341
|
shs = @workbook_views[:show_horizontal_scroll]
|
|
2335
2342
|
attrs << %(showHorizontalScroll="#{shs ? 1 : 0}") unless shs.nil?
|
|
@@ -2337,14 +2344,14 @@ module Xlsxrb
|
|
|
2337
2344
|
attrs << %(showVerticalScroll="#{svs ? 1 : 0}") unless svs.nil?
|
|
2338
2345
|
sst = @workbook_views[:show_sheet_tabs]
|
|
2339
2346
|
attrs << %(showSheetTabs="#{sst ? 1 : 0}") unless sst.nil?
|
|
2340
|
-
attrs << %(xWindow="#{@workbook_views[:x_window]}") if @workbook_views[:x_window]
|
|
2341
|
-
attrs << %(yWindow="#{@workbook_views[:y_window]}") if @workbook_views[:y_window]
|
|
2342
|
-
attrs << %(windowWidth="#{@workbook_views[:window_width]}") if @workbook_views[:window_width]
|
|
2343
|
-
attrs << %(windowHeight="#{@workbook_views[:window_height]}") if @workbook_views[:window_height]
|
|
2344
|
-
attrs << %(tabRatio="#{@workbook_views[:tab_ratio]}") if @workbook_views[:tab_ratio]
|
|
2345
|
-
attrs << %(firstSheet="#{@workbook_views[:first_sheet]}") if @workbook_views[:first_sheet]
|
|
2347
|
+
attrs << %(xWindow="#{xml_escape(@workbook_views[:x_window])}") if @workbook_views[:x_window]
|
|
2348
|
+
attrs << %(yWindow="#{xml_escape(@workbook_views[:y_window])}") if @workbook_views[:y_window]
|
|
2349
|
+
attrs << %(windowWidth="#{xml_escape(@workbook_views[:window_width])}") if @workbook_views[:window_width]
|
|
2350
|
+
attrs << %(windowHeight="#{xml_escape(@workbook_views[:window_height])}") if @workbook_views[:window_height]
|
|
2351
|
+
attrs << %(tabRatio="#{xml_escape(@workbook_views[:tab_ratio])}") if @workbook_views[:tab_ratio]
|
|
2352
|
+
attrs << %(firstSheet="#{xml_escape(@workbook_views[:first_sheet])}") if @workbook_views[:first_sheet]
|
|
2346
2353
|
at = @workbook_views[:active_sheet_index] || @workbook_views[:active_tab]
|
|
2347
|
-
attrs << %(activeTab="#{at}") if at
|
|
2354
|
+
attrs << %(activeTab="#{xml_escape(at)}") if at
|
|
2348
2355
|
afdg = @workbook_views[:auto_filter_date_grouping]
|
|
2349
2356
|
attrs << %(autoFilterDateGrouping="#{afdg ? 1 : 0}") unless afdg.nil?
|
|
2350
2357
|
parts << "<bookViews>"
|
|
@@ -2374,7 +2381,7 @@ module Xlsxrb
|
|
|
2374
2381
|
wp_attrs << %(workbookAlgorithmName="#{xml_escape(@workbook_protection[:algorithm_name])}")
|
|
2375
2382
|
wp_attrs << %(workbookHashValue="#{xml_escape(@workbook_protection[:hash_value])}") if @workbook_protection[:hash_value]
|
|
2376
2383
|
wp_attrs << %(workbookSaltValue="#{xml_escape(@workbook_protection[:salt_value])}") if @workbook_protection[:salt_value]
|
|
2377
|
-
wp_attrs << %(workbookSpinCount="#{@workbook_protection[:spin_count]}") if @workbook_protection[:spin_count]
|
|
2384
|
+
wp_attrs << %(workbookSpinCount="#{xml_escape(@workbook_protection[:spin_count])}") if @workbook_protection[:spin_count]
|
|
2378
2385
|
elsif @workbook_protection[:password]
|
|
2379
2386
|
wp_attrs << %(workbookPassword="#{xml_escape(@workbook_protection[:password])}")
|
|
2380
2387
|
end
|
|
@@ -2382,7 +2389,7 @@ module Xlsxrb
|
|
|
2382
2389
|
wp_attrs << %(revisionsAlgorithmName="#{xml_escape(@workbook_protection[:revisions_algorithm_name])}")
|
|
2383
2390
|
wp_attrs << %(revisionsHashValue="#{xml_escape(@workbook_protection[:revisions_hash_value])}") if @workbook_protection[:revisions_hash_value]
|
|
2384
2391
|
wp_attrs << %(revisionsSaltValue="#{xml_escape(@workbook_protection[:revisions_salt_value])}") if @workbook_protection[:revisions_salt_value]
|
|
2385
|
-
wp_attrs << %(revisionsSpinCount="#{@workbook_protection[:revisions_spin_count]}") if @workbook_protection[:revisions_spin_count]
|
|
2392
|
+
wp_attrs << %(revisionsSpinCount="#{xml_escape(@workbook_protection[:revisions_spin_count])}") if @workbook_protection[:revisions_spin_count]
|
|
2386
2393
|
elsif @workbook_protection[:revisions_password]
|
|
2387
2394
|
wp_attrs << %(revisionsPassword="#{xml_escape(@workbook_protection[:revisions_password])}")
|
|
2388
2395
|
end
|
|
@@ -2395,7 +2402,7 @@ module Xlsxrb
|
|
|
2395
2402
|
el_rid_base = @sheet_order.size + 1 + (@use_shared_strings ? 1 : 0) + 1 + pivot_cache_count
|
|
2396
2403
|
parts << "<externalReferences>"
|
|
2397
2404
|
@external_links.each_with_index do |_, idx|
|
|
2398
|
-
parts << %(<externalReference r:id="rId#{el_rid_base + idx}"/>)
|
|
2405
|
+
parts << %(<externalReference r:id="rId#{xml_escape(el_rid_base + idx)}"/>)
|
|
2399
2406
|
end
|
|
2400
2407
|
parts << "</externalReferences>"
|
|
2401
2408
|
end
|
|
@@ -2405,7 +2412,7 @@ module Xlsxrb
|
|
|
2405
2412
|
parts << "<definedNames>"
|
|
2406
2413
|
@defined_names.each do |dn|
|
|
2407
2414
|
attrs = %(name="#{xml_escape(dn[:name])}")
|
|
2408
|
-
attrs << %( localSheetId="#{dn[:local_sheet_id]}") if dn[:local_sheet_id]
|
|
2415
|
+
attrs << %( localSheetId="#{xml_escape(dn[:local_sheet_id])}") if dn[:local_sheet_id]
|
|
2409
2416
|
attrs << ' hidden="1"' if dn[:hidden]
|
|
2410
2417
|
attrs << %( comment="#{xml_escape(dn[:comment])}") if dn[:comment]
|
|
2411
2418
|
attrs << %( description="#{xml_escape(dn[:description])}") if dn[:description]
|
|
@@ -2415,7 +2422,7 @@ module Xlsxrb
|
|
|
2415
2422
|
attrs << %( shortcutKey="#{xml_escape(dn[:shortcut_key])}") if dn[:shortcut_key]
|
|
2416
2423
|
attrs << ' publishToServer="1"' if dn[:publish_to_server]
|
|
2417
2424
|
attrs << ' workbookParameter="1"' if dn[:workbook_parameter]
|
|
2418
|
-
attrs << %( functionGroupId="#{dn[:function_group_id]}") if dn[:function_group_id]
|
|
2425
|
+
attrs << %( functionGroupId="#{xml_escape(dn[:function_group_id])}") if dn[:function_group_id]
|
|
2419
2426
|
attrs << %( customMenu="#{xml_escape(dn[:custom_menu])}") if dn[:custom_menu]
|
|
2420
2427
|
attrs << %( help="#{xml_escape(dn[:help])}") if dn[:help]
|
|
2421
2428
|
attrs << %( statusBar="#{xml_escape(dn[:status_bar])}") if dn[:status_bar]
|
|
@@ -2427,20 +2434,20 @@ module Xlsxrb
|
|
|
2427
2434
|
# calcPr
|
|
2428
2435
|
unless @calc_properties.empty?
|
|
2429
2436
|
attrs = []
|
|
2430
|
-
attrs << %(calcId="#{@calc_properties[:calc_id]}") if @calc_properties[:calc_id]
|
|
2431
|
-
attrs << %(calcMode="#{@calc_properties[:calc_mode]}") if @calc_properties[:calc_mode]
|
|
2437
|
+
attrs << %(calcId="#{xml_escape(@calc_properties[:calc_id])}") if @calc_properties[:calc_id]
|
|
2438
|
+
attrs << %(calcMode="#{xml_escape(@calc_properties[:calc_mode])}") if @calc_properties[:calc_mode]
|
|
2432
2439
|
attrs << %(fullCalcOnLoad="#{@calc_properties[:full_calc_on_load] ? 1 : 0}") unless @calc_properties[:full_calc_on_load].nil?
|
|
2433
2440
|
attrs << %(iterate="#{@calc_properties[:iterate] ? 1 : 0}") unless @calc_properties[:iterate].nil?
|
|
2434
|
-
attrs << %(iterateCount="#{@calc_properties[:iterate_count]}") if @calc_properties[:iterate_count]
|
|
2435
|
-
attrs << %(iterateDelta="#{@calc_properties[:iterate_delta]}") if @calc_properties[:iterate_delta]
|
|
2436
|
-
attrs << %(refMode="#{@calc_properties[:ref_mode]}") if @calc_properties[:ref_mode]
|
|
2441
|
+
attrs << %(iterateCount="#{xml_escape(@calc_properties[:iterate_count])}") if @calc_properties[:iterate_count]
|
|
2442
|
+
attrs << %(iterateDelta="#{xml_escape(@calc_properties[:iterate_delta])}") if @calc_properties[:iterate_delta]
|
|
2443
|
+
attrs << %(refMode="#{xml_escape(@calc_properties[:ref_mode])}") if @calc_properties[:ref_mode]
|
|
2437
2444
|
attrs << %(calcCompleted="#{@calc_properties[:calc_completed] ? 1 : 0}") unless @calc_properties[:calc_completed].nil?
|
|
2438
2445
|
attrs << %(calcOnSave="#{@calc_properties[:calc_on_save] ? 1 : 0}") unless @calc_properties[:calc_on_save].nil?
|
|
2439
2446
|
fp = @calc_properties[:full_precision]
|
|
2440
2447
|
attrs << %(fullPrecision="#{fp ? 1 : 0}") unless fp.nil?
|
|
2441
2448
|
conc = @calc_properties[:concurrent_calc]
|
|
2442
2449
|
attrs << %(concurrentCalc="#{conc ? 1 : 0}") unless conc.nil?
|
|
2443
|
-
attrs << %(concurrentManualCount="#{@calc_properties[:concurrent_manual_count]}") if @calc_properties[:concurrent_manual_count]
|
|
2450
|
+
attrs << %(concurrentManualCount="#{xml_escape(@calc_properties[:concurrent_manual_count])}") if @calc_properties[:concurrent_manual_count]
|
|
2444
2451
|
ffc = @calc_properties[:force_full_calc]
|
|
2445
2452
|
attrs << %(forceFullCalc="#{ffc ? 1 : 0}") unless ffc.nil?
|
|
2446
2453
|
parts << "<calcPr #{attrs.join(" ")}/>" unless attrs.empty?
|
|
@@ -2452,7 +2459,7 @@ module Xlsxrb
|
|
|
2452
2459
|
pivot_rid_base = @sheet_order.size + 1 + (@use_shared_strings ? 1 : 0) + 1
|
|
2453
2460
|
parts << "<pivotCaches>"
|
|
2454
2461
|
pivot_cache_count.times do |ci|
|
|
2455
|
-
parts << %(<pivotCache cacheId="#{ci + 1}" r:id="rId#{pivot_rid_base + ci}"/>)
|
|
2462
|
+
parts << %(<pivotCache cacheId="#{xml_escape(ci + 1)}" r:id="rId#{xml_escape(pivot_rid_base + ci)}"/>)
|
|
2456
2463
|
end
|
|
2457
2464
|
parts << "</pivotCaches>"
|
|
2458
2465
|
end
|
|
@@ -2485,26 +2492,26 @@ module Xlsxrb
|
|
|
2485
2492
|
parts << %(<Relationship Id="rId#{i + 1}" Type="#{DOC_REL_NS}/worksheet" Target="worksheets/sheet#{i + 1}.xml"/>)
|
|
2486
2493
|
end
|
|
2487
2494
|
next_rid = @sheet_order.size + 1
|
|
2488
|
-
parts << %(<Relationship Id="rId#{next_rid}" Type="#{DOC_REL_NS}/styles" Target="styles.xml"/>)
|
|
2495
|
+
parts << %(<Relationship Id="rId#{xml_escape(next_rid)}" Type="#{DOC_REL_NS}/styles" Target="styles.xml"/>)
|
|
2489
2496
|
next_rid += 1
|
|
2490
2497
|
if @use_shared_strings
|
|
2491
|
-
parts << %(<Relationship Id="rId#{next_rid}" Type="#{DOC_REL_NS}/sharedStrings" Target="sharedStrings.xml"/>)
|
|
2498
|
+
parts << %(<Relationship Id="rId#{xml_escape(next_rid)}" Type="#{DOC_REL_NS}/sharedStrings" Target="sharedStrings.xml"/>)
|
|
2492
2499
|
next_rid += 1
|
|
2493
2500
|
end
|
|
2494
2501
|
(1..@pivot_cache_count.to_i).each do |c|
|
|
2495
|
-
parts << %(<Relationship Id="rId#{next_rid}" Type="#{DOC_REL_NS}/pivotCacheDefinition" Target="pivotCache/pivotCacheDefinition#{c}.xml"/>)
|
|
2502
|
+
parts << %(<Relationship Id="rId#{xml_escape(next_rid)}" Type="#{DOC_REL_NS}/pivotCacheDefinition" Target="pivotCache/pivotCacheDefinition#{xml_escape(c)}.xml"/>)
|
|
2496
2503
|
next_rid += 1
|
|
2497
2504
|
end
|
|
2498
2505
|
@external_links.each_with_index do |_, idx|
|
|
2499
|
-
parts << %(<Relationship Id="rId#{next_rid}" Type="#{DOC_REL_NS}/externalLink" Target="externalLinks/externalLink#{idx + 1}.xml"/>)
|
|
2506
|
+
parts << %(<Relationship Id="rId#{xml_escape(next_rid)}" Type="#{DOC_REL_NS}/externalLink" Target="externalLinks/externalLink#{xml_escape(idx + 1)}.xml"/>)
|
|
2500
2507
|
next_rid += 1
|
|
2501
2508
|
end
|
|
2502
2509
|
if has_calc_chain
|
|
2503
|
-
parts << %(<Relationship Id="rId#{next_rid}" Type="#{DOC_REL_NS}/calcChain" Target="calcChain.xml"/>)
|
|
2510
|
+
parts << %(<Relationship Id="rId#{xml_escape(next_rid)}" Type="#{DOC_REL_NS}/calcChain" Target="calcChain.xml"/>)
|
|
2504
2511
|
next_rid += 1
|
|
2505
2512
|
end
|
|
2506
2513
|
if @persons_data.any?
|
|
2507
|
-
parts << %(<Relationship Id="rId#{next_rid}" Type="http://schemas.microsoft.com/office/2017/10/relationships/person" Target="persons/person.xml"/>)
|
|
2514
|
+
parts << %(<Relationship Id="rId#{xml_escape(next_rid)}" Type="http://schemas.microsoft.com/office/2017/10/relationships/person" Target="persons/person.xml"/>)
|
|
2508
2515
|
next_rid += 1
|
|
2509
2516
|
end
|
|
2510
2517
|
parts << "</Relationships>"
|
|
@@ -2523,7 +2530,7 @@ module Xlsxrb
|
|
|
2523
2530
|
|
|
2524
2531
|
parts = [XML_HEADER, %(<calcChain xmlns="#{SSML_NS}">)]
|
|
2525
2532
|
chain_entries.each do |entry|
|
|
2526
|
-
parts << %(<c r="#{entry[:ref]}" i="#{entry[:sheet_id]}"/>)
|
|
2533
|
+
parts << %(<c r="#{xml_escape(entry[:ref])}" i="#{xml_escape(entry[:sheet_id])}"/>)
|
|
2527
2534
|
end
|
|
2528
2535
|
parts << "</calcChain>"
|
|
2529
2536
|
parts.join
|
|
@@ -2544,7 +2551,7 @@ module Xlsxrb
|
|
|
2544
2551
|
sp_attrs = []
|
|
2545
2552
|
sp_attrs << 'syncHorizontal="1"' if sheet_props[:sync_horizontal]
|
|
2546
2553
|
sp_attrs << 'syncVertical="1"' if sheet_props[:sync_vertical]
|
|
2547
|
-
sp_attrs << %(syncRef="#{sheet_props[:sync_ref]}") if sheet_props[:sync_ref]
|
|
2554
|
+
sp_attrs << %(syncRef="#{xml_escape(sheet_props[:sync_ref])}") if sheet_props[:sync_ref]
|
|
2548
2555
|
sp_attrs << 'transitionEvaluation="1"' if sheet_props[:transition_evaluation]
|
|
2549
2556
|
sp_attrs << 'transitionEntry="1"' if sheet_props[:transition_entry]
|
|
2550
2557
|
sp_attrs << %(codeName="#{xml_escape(sheet_props[:code_name])}") if sheet_props[:code_name]
|
|
@@ -2556,19 +2563,19 @@ module Xlsxrb
|
|
|
2556
2563
|
if tc.is_a?(Hash)
|
|
2557
2564
|
tc_attrs = []
|
|
2558
2565
|
tc_attrs << 'auto="1"' if tc[:auto]
|
|
2559
|
-
tc_attrs << %(indexed="#{tc[:indexed]}") if tc[:indexed]
|
|
2560
|
-
tc_attrs << %(rgb="#{tc[:rgb].to_s.delete_prefix("#")}") if tc[:rgb]
|
|
2561
|
-
tc_attrs << %(theme="#{tc[:theme]}") if tc[:theme]
|
|
2562
|
-
tc_attrs << %(tint="#{tc[:tint]}") if tc[:tint]
|
|
2566
|
+
tc_attrs << %(indexed="#{xml_escape(tc[:indexed])}") if tc[:indexed]
|
|
2567
|
+
tc_attrs << %(rgb="#{xml_escape(tc[:rgb].to_s.delete_prefix("#"))}") if tc[:rgb]
|
|
2568
|
+
tc_attrs << %(theme="#{xml_escape(tc[:theme])}") if tc[:theme]
|
|
2569
|
+
tc_attrs << %(tint="#{xml_escape(tc[:tint])}") if tc[:tint]
|
|
2563
2570
|
sp_children << "<tabColor #{tc_attrs.join(" ")}/>" unless tc_attrs.empty?
|
|
2564
2571
|
elsif tc
|
|
2565
|
-
sp_children << %(<tabColor rgb="#{tc.to_s.delete_prefix("#")}"/>)
|
|
2572
|
+
sp_children << %(<tabColor rgb="#{xml_escape(tc.to_s.delete_prefix("#"))}"/>)
|
|
2566
2573
|
elsif sheet_props[:tab_color_theme]
|
|
2567
|
-
tc_attrs = [%(theme="#{sheet_props[:tab_color_theme]}")]
|
|
2568
|
-
tc_attrs << %(tint="#{sheet_props[:tab_color_tint]}") if sheet_props[:tab_color_tint]
|
|
2574
|
+
tc_attrs = [%(theme="#{xml_escape(sheet_props[:tab_color_theme])}")]
|
|
2575
|
+
tc_attrs << %(tint="#{xml_escape(sheet_props[:tab_color_tint])}") if sheet_props[:tab_color_tint]
|
|
2569
2576
|
sp_children << "<tabColor #{tc_attrs.join(" ")}/>"
|
|
2570
2577
|
elsif sheet_props[:tab_color_indexed]
|
|
2571
|
-
sp_children << %(<tabColor indexed="#{sheet_props[:tab_color_indexed]}"/>)
|
|
2578
|
+
sp_children << %(<tabColor indexed="#{xml_escape(sheet_props[:tab_color_indexed])}"/>)
|
|
2572
2579
|
elsif sheet_props[:tab_color_auto]
|
|
2573
2580
|
sp_children << '<tabColor auto="1"/>'
|
|
2574
2581
|
end
|
|
@@ -2604,7 +2611,7 @@ module Xlsxrb
|
|
|
2604
2611
|
end
|
|
2605
2612
|
|
|
2606
2613
|
# Emit <dimension> computed from cell addresses.
|
|
2607
|
-
parts << %(<dimension ref="#{compute_dimension(sheet_cells)}"/>) unless sheet_cells.empty?
|
|
2614
|
+
parts << %(<dimension ref="#{xml_escape(compute_dimension(sheet_cells))}"/>) unless sheet_cells.empty?
|
|
2608
2615
|
|
|
2609
2616
|
# Emit <sheetViews> if sheet view properties, freeze pane, or selection are defined.
|
|
2610
2617
|
if !sheet_sv.empty? || sheet_fp || sheet_sel
|
|
@@ -2631,22 +2638,22 @@ module Xlsxrb
|
|
|
2631
2638
|
sv_attrs << %(defaultGridColor="#{dgc ? 1 : 0}") unless dgc.nil?
|
|
2632
2639
|
sws = sheet_sv[:show_white_space]
|
|
2633
2640
|
sv_attrs << %(showWhiteSpace="#{sws ? 1 : 0}") unless sws.nil?
|
|
2634
|
-
sv_attrs << %(view="#{sheet_sv[:view]}") if sheet_sv[:view]
|
|
2635
|
-
sv_attrs << %(topLeftCell="#{sheet_sv[:top_left_cell]}") if sheet_sv[:top_left_cell]
|
|
2636
|
-
sv_attrs << %(colorId="#{sheet_sv[:color_id]}") if sheet_sv[:color_id]
|
|
2641
|
+
sv_attrs << %(view="#{xml_escape(sheet_sv[:view])}") if sheet_sv[:view]
|
|
2642
|
+
sv_attrs << %(topLeftCell="#{xml_escape(sheet_sv[:top_left_cell])}") if sheet_sv[:top_left_cell]
|
|
2643
|
+
sv_attrs << %(colorId="#{xml_escape(sheet_sv[:color_id])}") if sheet_sv[:color_id]
|
|
2637
2644
|
zs = sheet_sv[:zoom_scale]
|
|
2638
|
-
sv_attrs << %(zoomScale="#{zs}") if zs
|
|
2639
|
-
sv_attrs << %(zoomScaleNormal="#{sheet_sv[:zoom_scale_normal]}") if sheet_sv[:zoom_scale_normal]
|
|
2640
|
-
sv_attrs << %(zoomScaleSheetLayoutView="#{sheet_sv[:zoom_scale_sheet_layout_view]}") if sheet_sv[:zoom_scale_sheet_layout_view]
|
|
2641
|
-
sv_attrs << %(zoomScalePageLayoutView="#{sheet_sv[:zoom_scale_page_layout_view]}") if sheet_sv[:zoom_scale_page_layout_view]
|
|
2645
|
+
sv_attrs << %(zoomScale="#{xml_escape(zs)}") if zs
|
|
2646
|
+
sv_attrs << %(zoomScaleNormal="#{xml_escape(sheet_sv[:zoom_scale_normal])}") if sheet_sv[:zoom_scale_normal]
|
|
2647
|
+
sv_attrs << %(zoomScaleSheetLayoutView="#{xml_escape(sheet_sv[:zoom_scale_sheet_layout_view])}") if sheet_sv[:zoom_scale_sheet_layout_view]
|
|
2648
|
+
sv_attrs << %(zoomScalePageLayoutView="#{xml_escape(sheet_sv[:zoom_scale_page_layout_view])}") if sheet_sv[:zoom_scale_page_layout_view]
|
|
2642
2649
|
sv_attrs << 'workbookViewId="0"'
|
|
2643
2650
|
parts << "<sheetView #{sv_attrs.join(" ")}>"
|
|
2644
2651
|
|
|
2645
2652
|
if sheet_fp && sheet_fp[:state] == :split
|
|
2646
2653
|
pane_attrs = []
|
|
2647
|
-
pane_attrs << %(xSplit="#{sheet_fp[:x_split]}") if sheet_fp[:x_split].to_i.positive?
|
|
2648
|
-
pane_attrs << %(ySplit="#{sheet_fp[:y_split]}") if sheet_fp[:y_split].to_i.positive?
|
|
2649
|
-
pane_attrs << %(topLeftCell="#{sheet_fp[:top_left_cell]}") if sheet_fp[:top_left_cell]
|
|
2654
|
+
pane_attrs << %(xSplit="#{xml_escape(sheet_fp[:x_split])}") if sheet_fp[:x_split].to_i.positive?
|
|
2655
|
+
pane_attrs << %(ySplit="#{xml_escape(sheet_fp[:y_split])}") if sheet_fp[:y_split].to_i.positive?
|
|
2656
|
+
pane_attrs << %(topLeftCell="#{xml_escape(sheet_fp[:top_left_cell])}") if sheet_fp[:top_left_cell]
|
|
2650
2657
|
has_x = sheet_fp[:x_split].to_i.positive?
|
|
2651
2658
|
has_y = sheet_fp[:y_split].to_i.positive?
|
|
2652
2659
|
active_pane = if has_y && has_x
|
|
@@ -2656,16 +2663,16 @@ module Xlsxrb
|
|
|
2656
2663
|
else
|
|
2657
2664
|
"topRight"
|
|
2658
2665
|
end
|
|
2659
|
-
pane_attrs << %(activePane="#{active_pane}")
|
|
2666
|
+
pane_attrs << %(activePane="#{xml_escape(active_pane)}")
|
|
2660
2667
|
parts << "<pane #{pane_attrs.join(" ")}/>"
|
|
2661
2668
|
elsif sheet_fp
|
|
2662
2669
|
fp_col = sheet_fp[:column] || sheet_fp[:col] || 0
|
|
2663
2670
|
if sheet_fp[:row].to_i.positive? || fp_col.to_i.positive?
|
|
2664
2671
|
top_left = "#{index_to_column_letter(fp_col.to_i + 1)}#{sheet_fp[:row].to_i + 1}"
|
|
2665
2672
|
pane_attrs = []
|
|
2666
|
-
pane_attrs << %(ySplit="#{sheet_fp[:row]}") if sheet_fp[:row].to_i.positive?
|
|
2667
|
-
pane_attrs << %(xSplit="#{fp_col}") if fp_col.to_i.positive?
|
|
2668
|
-
pane_attrs << %(topLeftCell="#{top_left}")
|
|
2673
|
+
pane_attrs << %(ySplit="#{xml_escape(sheet_fp[:row])}") if sheet_fp[:row].to_i.positive?
|
|
2674
|
+
pane_attrs << %(xSplit="#{xml_escape(fp_col)}") if fp_col.to_i.positive?
|
|
2675
|
+
pane_attrs << %(topLeftCell="#{xml_escape(top_left)}")
|
|
2669
2676
|
active_pane = if sheet_fp[:row].to_i.positive? && fp_col.to_i.positive?
|
|
2670
2677
|
"bottomRight"
|
|
2671
2678
|
elsif sheet_fp[:row].to_i.positive?
|
|
@@ -2673,7 +2680,7 @@ module Xlsxrb
|
|
|
2673
2680
|
else
|
|
2674
2681
|
"topRight"
|
|
2675
2682
|
end
|
|
2676
|
-
pane_attrs << %(activePane="#{active_pane}")
|
|
2683
|
+
pane_attrs << %(activePane="#{xml_escape(active_pane)}")
|
|
2677
2684
|
pane_attrs << 'state="frozen"'
|
|
2678
2685
|
parts << "<pane #{pane_attrs.join(" ")}/>"
|
|
2679
2686
|
end
|
|
@@ -2681,10 +2688,10 @@ module Xlsxrb
|
|
|
2681
2688
|
|
|
2682
2689
|
if sheet_sel
|
|
2683
2690
|
sel_attrs = []
|
|
2684
|
-
sel_attrs << %(pane="#{sheet_sel[:pane]}") if sheet_sel[:pane]
|
|
2685
|
-
sel_attrs << %(activeCell="#{sheet_sel[:active_cell]}") if sheet_sel[:active_cell]
|
|
2686
|
-
sel_attrs << %(activeCellId="#{sheet_sel[:active_cell_id]}") if sheet_sel[:active_cell_id]
|
|
2687
|
-
sel_attrs << %(sqref="#{sheet_sel[:sqref]}") if sheet_sel[:sqref]
|
|
2691
|
+
sel_attrs << %(pane="#{xml_escape(sheet_sel[:pane])}") if sheet_sel[:pane]
|
|
2692
|
+
sel_attrs << %(activeCell="#{xml_escape(sheet_sel[:active_cell])}") if sheet_sel[:active_cell]
|
|
2693
|
+
sel_attrs << %(activeCellId="#{xml_escape(sheet_sel[:active_cell_id])}") if sheet_sel[:active_cell_id]
|
|
2694
|
+
sel_attrs << %(sqref="#{xml_escape(sheet_sel[:sqref])}") if sheet_sel[:sqref]
|
|
2688
2695
|
parts << "<selection #{sel_attrs.join(" ")}/>"
|
|
2689
2696
|
end
|
|
2690
2697
|
|
|
@@ -2695,11 +2702,11 @@ module Xlsxrb
|
|
|
2695
2702
|
# Emit <sheetFormatPr> if sheet format properties are defined.
|
|
2696
2703
|
unless sheet_fmt.empty?
|
|
2697
2704
|
fmt_attrs = []
|
|
2698
|
-
fmt_attrs << %(defaultRowHeight="#{sheet_fmt[:default_row_height]}") if sheet_fmt[:default_row_height]
|
|
2699
|
-
fmt_attrs << %(defaultColWidth="#{sheet_fmt[:default_col_width]}") if sheet_fmt[:default_col_width]
|
|
2700
|
-
fmt_attrs << %(baseColWidth="#{sheet_fmt[:base_col_width]}") if sheet_fmt[:base_col_width]
|
|
2701
|
-
fmt_attrs << %(outlineLevelRow="#{sheet_fmt[:outline_level_row]}") if sheet_fmt[:outline_level_row]
|
|
2702
|
-
fmt_attrs << %(outlineLevelCol="#{sheet_fmt[:outline_level_col]}") if sheet_fmt[:outline_level_col]
|
|
2705
|
+
fmt_attrs << %(defaultRowHeight="#{xml_escape(sheet_fmt[:default_row_height])}") if sheet_fmt[:default_row_height]
|
|
2706
|
+
fmt_attrs << %(defaultColWidth="#{xml_escape(sheet_fmt[:default_col_width])}") if sheet_fmt[:default_col_width]
|
|
2707
|
+
fmt_attrs << %(baseColWidth="#{xml_escape(sheet_fmt[:base_col_width])}") if sheet_fmt[:base_col_width]
|
|
2708
|
+
fmt_attrs << %(outlineLevelRow="#{xml_escape(sheet_fmt[:outline_level_row])}") if sheet_fmt[:outline_level_row]
|
|
2709
|
+
fmt_attrs << %(outlineLevelCol="#{xml_escape(sheet_fmt[:outline_level_col])}") if sheet_fmt[:outline_level_col]
|
|
2703
2710
|
fmt_attrs << 'customHeight="1"' if sheet_fmt[:custom_height]
|
|
2704
2711
|
fmt_attrs << 'zeroHeight="1"' if sheet_fmt[:zero_height]
|
|
2705
2712
|
fmt_attrs << 'thickTop="1"' if sheet_fmt[:thick_top]
|
|
@@ -2715,13 +2722,13 @@ module Xlsxrb
|
|
|
2715
2722
|
idx = column_letter_to_index(col_letter)
|
|
2716
2723
|
width = sheet_col_widths[col_letter]
|
|
2717
2724
|
ca = sheet_col_attrs[col_letter] || {}
|
|
2718
|
-
col_attrs = %(min="#{idx}" max="#{idx}")
|
|
2719
|
-
col_attrs << %( width="#{width}" customWidth="1") if width
|
|
2725
|
+
col_attrs = %(min="#{xml_escape(idx)}" max="#{xml_escape(idx)}")
|
|
2726
|
+
col_attrs << %( width="#{xml_escape(width)}" customWidth="1") if width
|
|
2720
2727
|
col_attrs << ' hidden="1"' if ca[:hidden]
|
|
2721
2728
|
col_attrs << ' bestFit="1"' if ca[:best_fit]
|
|
2722
|
-
col_attrs << %( outlineLevel="#{ca[:outline_level]}") if ca[:outline_level]
|
|
2729
|
+
col_attrs << %( outlineLevel="#{xml_escape(ca[:outline_level])}") if ca[:outline_level]
|
|
2723
2730
|
col_attrs << ' collapsed="1"' if ca[:collapsed]
|
|
2724
|
-
col_attrs << %( style="#{ca[:style]}") if ca[:style]
|
|
2731
|
+
col_attrs << %( style="#{xml_escape(ca[:style])}") if ca[:style]
|
|
2725
2732
|
col_attrs << ' phonetic="1"' if ca[:phonetic]
|
|
2726
2733
|
parts << "<col #{col_attrs}/>"
|
|
2727
2734
|
end
|
|
@@ -2744,14 +2751,14 @@ module Xlsxrb
|
|
|
2744
2751
|
|
|
2745
2752
|
# Emit rows in ascending order.
|
|
2746
2753
|
cells_by_row.sort.each do |row_num, row_cells|
|
|
2747
|
-
attrs = %(r="#{row_num}")
|
|
2754
|
+
attrs = %(r="#{xml_escape(row_num)}")
|
|
2748
2755
|
ra = sheet_row_attrs[row_num]
|
|
2749
2756
|
if ra
|
|
2750
|
-
attrs << %( ht="#{ra[:height]}" customHeight="1") if ra[:height]
|
|
2757
|
+
attrs << %( ht="#{xml_escape(ra[:height])}" customHeight="1") if ra[:height]
|
|
2751
2758
|
attrs << ' hidden="1"' if ra[:hidden]
|
|
2752
|
-
attrs << %( outlineLevel="#{ra[:outline_level]}") if ra[:outline_level]
|
|
2759
|
+
attrs << %( outlineLevel="#{xml_escape(ra[:outline_level])}") if ra[:outline_level]
|
|
2753
2760
|
attrs << ' collapsed="1"' if ra[:collapsed]
|
|
2754
|
-
attrs << %( s="#{ra[:style]}" customFormat="1") if ra.key?(:style)
|
|
2761
|
+
attrs << %( s="#{xml_escape(ra[:style])}" customFormat="1") if ra.key?(:style)
|
|
2755
2762
|
attrs << ' thickTop="1"' if ra[:thick_top]
|
|
2756
2763
|
attrs << ' thickBot="1"' if ra[:thick_bot]
|
|
2757
2764
|
attrs << ' ph="1"' if ra[:ph]
|
|
@@ -2793,7 +2800,7 @@ module Xlsxrb
|
|
|
2793
2800
|
sp_attrs << %(algorithmName="#{xml_escape(sheet_prot[:algorithm_name])}")
|
|
2794
2801
|
sp_attrs << %(hashValue="#{xml_escape(sheet_prot[:hash_value])}") if sheet_prot[:hash_value]
|
|
2795
2802
|
sp_attrs << %(saltValue="#{xml_escape(sheet_prot[:salt_value])}") if sheet_prot[:salt_value]
|
|
2796
|
-
sp_attrs << %(spinCount="#{sheet_prot[:spin_count]}") if sheet_prot[:spin_count]
|
|
2803
|
+
sp_attrs << %(spinCount="#{xml_escape(sheet_prot[:spin_count])}") if sheet_prot[:spin_count]
|
|
2797
2804
|
elsif sheet_prot[:password]
|
|
2798
2805
|
sp_attrs << %(password="#{xml_escape(sheet_prot[:password])}")
|
|
2799
2806
|
end
|
|
@@ -2804,12 +2811,12 @@ module Xlsxrb
|
|
|
2804
2811
|
unless prot_ranges.empty?
|
|
2805
2812
|
parts << "<protectedRanges>"
|
|
2806
2813
|
prot_ranges.each do |pr|
|
|
2807
|
-
pr_attrs = [%(sqref="#{pr[:sqref]}"), %(name="#{xml_escape(pr[:name])}")]
|
|
2814
|
+
pr_attrs = [%(sqref="#{xml_escape(pr[:sqref])}"), %(name="#{xml_escape(pr[:name])}")]
|
|
2808
2815
|
if pr[:algorithm_name]
|
|
2809
2816
|
pr_attrs << %(algorithmName="#{xml_escape(pr[:algorithm_name])}")
|
|
2810
2817
|
pr_attrs << %(hashValue="#{xml_escape(pr[:hash_value])}") if pr[:hash_value]
|
|
2811
2818
|
pr_attrs << %(saltValue="#{xml_escape(pr[:salt_value])}") if pr[:salt_value]
|
|
2812
|
-
pr_attrs << %(spinCount="#{pr[:spin_count]}") if pr[:spin_count]
|
|
2819
|
+
pr_attrs << %(spinCount="#{xml_escape(pr[:spin_count])}") if pr[:spin_count]
|
|
2813
2820
|
end
|
|
2814
2821
|
sds = pr[:security_descriptors] || []
|
|
2815
2822
|
if sds.empty?
|
|
@@ -2826,9 +2833,9 @@ module Xlsxrb
|
|
|
2826
2833
|
# Emit <scenarios> if defined.
|
|
2827
2834
|
if sheet_scenarios
|
|
2828
2835
|
sc_attrs = []
|
|
2829
|
-
sc_attrs << %(current="#{sheet_scenarios[:current]}") if sheet_scenarios[:current]
|
|
2830
|
-
sc_attrs << %(show="#{sheet_scenarios[:show]}") if sheet_scenarios[:show]
|
|
2831
|
-
sc_attrs << %(sqref="#{sheet_scenarios[:sqref]}") if sheet_scenarios[:sqref]
|
|
2836
|
+
sc_attrs << %(current="#{xml_escape(sheet_scenarios[:current])}") if sheet_scenarios[:current]
|
|
2837
|
+
sc_attrs << %(show="#{xml_escape(sheet_scenarios[:show])}") if sheet_scenarios[:show]
|
|
2838
|
+
sc_attrs << %(sqref="#{xml_escape(sheet_scenarios[:sqref])}") if sheet_scenarios[:sqref]
|
|
2832
2839
|
items = sheet_scenarios[:scenarios] || []
|
|
2833
2840
|
sc_attr_str = sc_attrs.empty? ? "" : " #{sc_attrs.join(" ")}"
|
|
2834
2841
|
parts << "<scenarios#{sc_attr_str}>"
|
|
@@ -2841,10 +2848,10 @@ module Xlsxrb
|
|
|
2841
2848
|
s_attrs << %(comment="#{xml_escape(sc[:comment])}") if sc[:comment]
|
|
2842
2849
|
parts << "<scenario #{s_attrs.join(" ")}>"
|
|
2843
2850
|
(sc[:input_cells] || []).each do |ic|
|
|
2844
|
-
ic_attrs = [%(r="#{ic[:r]}"), %(val="#{xml_escape(ic[:val].to_s)}")]
|
|
2851
|
+
ic_attrs = [%(r="#{xml_escape(ic[:r])}"), %(val="#{xml_escape(ic[:val].to_s)}")]
|
|
2845
2852
|
ic_attrs << 'deleted="1"' if ic[:deleted]
|
|
2846
2853
|
ic_attrs << 'undone="1"' if ic[:undone]
|
|
2847
|
-
ic_attrs << %(numFmtId="#{ic[:num_fmt_id]}") if ic[:num_fmt_id]
|
|
2854
|
+
ic_attrs << %(numFmtId="#{xml_escape(ic[:num_fmt_id])}") if ic[:num_fmt_id]
|
|
2848
2855
|
parts << "<inputCells #{ic_attrs.join(" ")}/>"
|
|
2849
2856
|
end
|
|
2850
2857
|
parts << "</scenario>"
|
|
@@ -2855,11 +2862,11 @@ module Xlsxrb
|
|
|
2855
2862
|
# Emit <autoFilter> with optional filterColumns.
|
|
2856
2863
|
if sheet_auto_filter
|
|
2857
2864
|
if sheet_filter_cols.empty?
|
|
2858
|
-
parts << %(<autoFilter ref="#{sheet_auto_filter}"/>)
|
|
2865
|
+
parts << %(<autoFilter ref="#{xml_escape(sheet_auto_filter)}"/>)
|
|
2859
2866
|
else
|
|
2860
|
-
parts << %(<autoFilter ref="#{sheet_auto_filter}">)
|
|
2867
|
+
parts << %(<autoFilter ref="#{xml_escape(sheet_auto_filter)}">)
|
|
2861
2868
|
sheet_filter_cols.sort.each do |col_id, filter|
|
|
2862
|
-
fc_attrs = %( colId="#{col_id}")
|
|
2869
|
+
fc_attrs = %( colId="#{xml_escape(col_id)}")
|
|
2863
2870
|
fc_attrs << ' hiddenButton="1"' if filter[:hidden_button]
|
|
2864
2871
|
fc_attrs << ' showButton="0"' if filter[:show_button] == false
|
|
2865
2872
|
parts << "<filterColumn#{fc_attrs}>"
|
|
@@ -2872,19 +2879,19 @@ module Xlsxrb
|
|
|
2872
2879
|
|
|
2873
2880
|
# Emit <sortState> if defined.
|
|
2874
2881
|
if sheet_sort
|
|
2875
|
-
ss_attrs = %( ref="#{sheet_sort[:ref]}")
|
|
2882
|
+
ss_attrs = %( ref="#{xml_escape(sheet_sort[:ref])}")
|
|
2876
2883
|
ss_attrs << ' columnSort="1"' if sheet_sort[:column_sort]
|
|
2877
2884
|
ss_attrs << ' caseSensitive="1"' if sheet_sort[:case_sensitive]
|
|
2878
|
-
ss_attrs << %( sortMethod="#{sheet_sort[:sort_method]}") if sheet_sort[:sort_method]
|
|
2885
|
+
ss_attrs << %( sortMethod="#{xml_escape(sheet_sort[:sort_method])}") if sheet_sort[:sort_method]
|
|
2879
2886
|
parts << "<sortState#{ss_attrs}>"
|
|
2880
2887
|
sheet_sort[:sort_conditions].each do |sc|
|
|
2881
|
-
sc_attrs = %(ref="#{sc[:ref]}")
|
|
2888
|
+
sc_attrs = %(ref="#{xml_escape(sc[:ref])}")
|
|
2882
2889
|
sc_attrs << ' descending="1"' if sc[:descending]
|
|
2883
|
-
sc_attrs << %( sortBy="#{sc[:sort_by]}") if sc[:sort_by]
|
|
2890
|
+
sc_attrs << %( sortBy="#{xml_escape(sc[:sort_by])}") if sc[:sort_by]
|
|
2884
2891
|
sc_attrs << %( customList="#{xml_escape(sc[:custom_list])}") if sc[:custom_list]
|
|
2885
|
-
sc_attrs << %( dxfId="#{sc[:dxf_id]}") if sc[:dxf_id]
|
|
2886
|
-
sc_attrs << %( iconSet="#{sc[:icon_set]}") if sc[:icon_set]
|
|
2887
|
-
sc_attrs << %( iconId="#{sc[:icon_id]}") if sc[:icon_id]
|
|
2892
|
+
sc_attrs << %( dxfId="#{xml_escape(sc[:dxf_id])}") if sc[:dxf_id]
|
|
2893
|
+
sc_attrs << %( iconSet="#{xml_escape(sc[:icon_set])}") if sc[:icon_set]
|
|
2894
|
+
sc_attrs << %( iconId="#{xml_escape(sc[:icon_id])}") if sc[:icon_id]
|
|
2888
2895
|
parts << "<sortCondition #{sc_attrs}/>"
|
|
2889
2896
|
end
|
|
2890
2897
|
parts << "</sortState>"
|
|
@@ -2893,7 +2900,7 @@ module Xlsxrb
|
|
|
2893
2900
|
# Emit <dataConsolidate> if defined.
|
|
2894
2901
|
if data_consol
|
|
2895
2902
|
dc_attrs = []
|
|
2896
|
-
dc_attrs << %(function="#{data_consol[:function]}") if data_consol[:function] && data_consol[:function] != "sum"
|
|
2903
|
+
dc_attrs << %(function="#{xml_escape(data_consol[:function])}") if data_consol[:function] && data_consol[:function] != "sum"
|
|
2897
2904
|
dc_attrs << 'startLabels="1"' if data_consol[:start_labels]
|
|
2898
2905
|
dc_attrs << 'leftLabels="1"' if data_consol[:left_labels]
|
|
2899
2906
|
dc_attrs << 'topLabels="1"' if data_consol[:top_labels]
|
|
@@ -2907,7 +2914,7 @@ module Xlsxrb
|
|
|
2907
2914
|
parts << %(<dataRefs count="#{refs.size}">)
|
|
2908
2915
|
refs.each do |r|
|
|
2909
2916
|
ref_attrs = []
|
|
2910
|
-
ref_attrs << %(ref="#{r[:ref]}") if r[:ref]
|
|
2917
|
+
ref_attrs << %(ref="#{xml_escape(r[:ref])}") if r[:ref]
|
|
2911
2918
|
ref_attrs << %(name="#{xml_escape(r[:name])}") if r[:name]
|
|
2912
2919
|
ref_attrs << %(sheet="#{xml_escape(r[:sheet])}") if r[:sheet]
|
|
2913
2920
|
parts << "<dataRef #{ref_attrs.join(" ")}/>"
|
|
@@ -2920,16 +2927,16 @@ module Xlsxrb
|
|
|
2920
2927
|
# Emit <mergeCells> if merge ranges are defined.
|
|
2921
2928
|
unless sheet_merge_cells.empty?
|
|
2922
2929
|
parts << %(<mergeCells count="#{sheet_merge_cells.size}">)
|
|
2923
|
-
sheet_merge_cells.each { |ref| parts << %(<mergeCell ref="#{ref}"/>) }
|
|
2930
|
+
sheet_merge_cells.each { |ref| parts << %(<mergeCell ref="#{xml_escape(ref)}"/>) }
|
|
2924
2931
|
parts << "</mergeCells>"
|
|
2925
2932
|
end
|
|
2926
2933
|
|
|
2927
2934
|
# Emit <phoneticPr> if defined.
|
|
2928
2935
|
if phonetic_pr
|
|
2929
2936
|
pp_attrs = []
|
|
2930
|
-
pp_attrs << %(fontId="#{phonetic_pr[:font_id]}") if phonetic_pr[:font_id]
|
|
2931
|
-
pp_attrs << %(type="#{phonetic_pr[:type]}") if phonetic_pr[:type]
|
|
2932
|
-
pp_attrs << %(alignment="#{phonetic_pr[:alignment]}") if phonetic_pr[:alignment]
|
|
2937
|
+
pp_attrs << %(fontId="#{xml_escape(phonetic_pr[:font_id])}") if phonetic_pr[:font_id]
|
|
2938
|
+
pp_attrs << %(type="#{xml_escape(phonetic_pr[:type])}") if phonetic_pr[:type]
|
|
2939
|
+
pp_attrs << %(alignment="#{xml_escape(phonetic_pr[:alignment])}") if phonetic_pr[:alignment]
|
|
2933
2940
|
parts << "<phoneticPr #{pp_attrs.join(" ")}/>"
|
|
2934
2941
|
end
|
|
2935
2942
|
|
|
@@ -2938,10 +2945,10 @@ module Xlsxrb
|
|
|
2938
2945
|
parts << "<hyperlinks>"
|
|
2939
2946
|
ext_rid = 0
|
|
2940
2947
|
sheet_hyperlinks.each do |(cell_ref, link)|
|
|
2941
|
-
attrs = %(ref="#{cell_ref}")
|
|
2948
|
+
attrs = %(ref="#{xml_escape(cell_ref)}")
|
|
2942
2949
|
if link[:url]
|
|
2943
2950
|
ext_rid += 1
|
|
2944
|
-
attrs << %( r:id="rId#{ext_rid}")
|
|
2951
|
+
attrs << %( r:id="rId#{xml_escape(ext_rid)}")
|
|
2945
2952
|
end
|
|
2946
2953
|
attrs << %( display="#{xml_escape(link[:display])}") if link[:display]
|
|
2947
2954
|
attrs << %( tooltip="#{xml_escape(link[:tooltip])}") if link[:tooltip]
|
|
@@ -2954,7 +2961,7 @@ module Xlsxrb
|
|
|
2954
2961
|
# Emit <conditionalFormatting> if defined.
|
|
2955
2962
|
unless sheet_cf.empty?
|
|
2956
2963
|
sheet_cf.group_by { |cf| cf[:sqref] }.each do |sqref, rules|
|
|
2957
|
-
cf_attrs = %( sqref="#{sqref}")
|
|
2964
|
+
cf_attrs = %( sqref="#{xml_escape(sqref)}")
|
|
2958
2965
|
cf_attrs << ' pivot="1"' if rules.any? { |r| r[:pivot] }
|
|
2959
2966
|
parts << "<conditionalFormatting#{cf_attrs}>"
|
|
2960
2967
|
rules.each do |cf|
|
|
@@ -2970,14 +2977,14 @@ module Xlsxrb
|
|
|
2970
2977
|
unless valid_dv.empty?
|
|
2971
2978
|
dv_container_attrs = %( count="#{valid_dv.size}")
|
|
2972
2979
|
dv_container_attrs << ' disablePrompts="1"' if dv_options[:disable_prompts]
|
|
2973
|
-
dv_container_attrs << %( xWindow="#{dv_options[:x_window]}") if dv_options[:x_window]
|
|
2974
|
-
dv_container_attrs << %( yWindow="#{dv_options[:y_window]}") if dv_options[:y_window]
|
|
2980
|
+
dv_container_attrs << %( xWindow="#{xml_escape(dv_options[:x_window])}") if dv_options[:x_window]
|
|
2981
|
+
dv_container_attrs << %( yWindow="#{xml_escape(dv_options[:y_window])}") if dv_options[:y_window]
|
|
2975
2982
|
parts << "<dataValidations#{dv_container_attrs}>"
|
|
2976
2983
|
valid_dv.each do |dv|
|
|
2977
|
-
dv_attrs = %(sqref="#{dv[:sqref]}")
|
|
2978
|
-
dv_attrs << %( type="#{dv[:type]}") if dv[:type]
|
|
2979
|
-
dv_attrs << %( operator="#{dv[:operator]}") if dv[:operator]
|
|
2980
|
-
dv_attrs << %( errorStyle="#{dv[:error_style]}") if dv[:error_style]
|
|
2984
|
+
dv_attrs = %(sqref="#{xml_escape(dv[:sqref])}")
|
|
2985
|
+
dv_attrs << %( type="#{xml_escape(dv[:type])}") if dv[:type]
|
|
2986
|
+
dv_attrs << %( operator="#{xml_escape(dv[:operator])}") if dv[:operator]
|
|
2987
|
+
dv_attrs << %( errorStyle="#{xml_escape(dv[:error_style])}") if dv[:error_style]
|
|
2981
2988
|
dv_attrs << ' allowBlank="1"' if dv[:allow_blank]
|
|
2982
2989
|
dv_attrs << ' showInputMessage="1"' if dv[:show_input_message]
|
|
2983
2990
|
dv_attrs << ' showErrorMessage="1"' if dv[:show_error_message]
|
|
@@ -2986,7 +2993,7 @@ module Xlsxrb
|
|
|
2986
2993
|
dv_attrs << %( promptTitle="#{xml_escape(dv[:prompt_title])}") if dv[:prompt_title]
|
|
2987
2994
|
dv_attrs << %( prompt="#{xml_escape(dv[:prompt])}") if dv[:prompt]
|
|
2988
2995
|
dv_attrs << ' showDropDown="1"' if dv[:show_drop_down]
|
|
2989
|
-
dv_attrs << %( imeMode="#{dv[:ime_mode]}") if dv[:ime_mode]
|
|
2996
|
+
dv_attrs << %( imeMode="#{xml_escape(dv[:ime_mode])}") if dv[:ime_mode]
|
|
2990
2997
|
if dv[:formula1] || dv[:formula2]
|
|
2991
2998
|
parts << "<dataValidation #{dv_attrs}>"
|
|
2992
2999
|
parts << "<formula1>#{xml_escape(dv[:formula1])}</formula1>" if dv[:formula1]
|
|
@@ -3015,7 +3022,7 @@ module Xlsxrb
|
|
|
3015
3022
|
if sheet_pm
|
|
3016
3023
|
pm_attrs = %w[left right top bottom header footer].filter_map do |k|
|
|
3017
3024
|
v = sheet_pm[k.to_sym]
|
|
3018
|
-
%(#{k}="#{v}") if v
|
|
3025
|
+
%(#{k}="#{xml_escape(v)}") if v
|
|
3019
3026
|
end
|
|
3020
3027
|
parts << "<pageMargins #{pm_attrs.join(" ")}/>" unless pm_attrs.empty?
|
|
3021
3028
|
end
|
|
@@ -3023,23 +3030,23 @@ module Xlsxrb
|
|
|
3023
3030
|
# Emit <pageSetup> if defined.
|
|
3024
3031
|
unless sheet_ps.empty?
|
|
3025
3032
|
ps_attrs = []
|
|
3026
|
-
ps_attrs << %(orientation="#{sheet_ps[:orientation]}") if sheet_ps[:orientation]
|
|
3027
|
-
ps_attrs << %(paperSize="#{sheet_ps[:paper_size]}") if sheet_ps[:paper_size]
|
|
3028
|
-
ps_attrs << %(scale="#{sheet_ps[:scale]}") if sheet_ps[:scale]
|
|
3029
|
-
ps_attrs << %(fitToWidth="#{sheet_ps[:fit_to_width]}") if sheet_ps[:fit_to_width]
|
|
3030
|
-
ps_attrs << %(fitToHeight="#{sheet_ps[:fit_to_height]}") if sheet_ps[:fit_to_height]
|
|
3031
|
-
ps_attrs << %(pageOrder="#{sheet_ps[:page_order]}") if sheet_ps[:page_order]
|
|
3033
|
+
ps_attrs << %(orientation="#{xml_escape(sheet_ps[:orientation])}") if sheet_ps[:orientation]
|
|
3034
|
+
ps_attrs << %(paperSize="#{xml_escape(sheet_ps[:paper_size])}") if sheet_ps[:paper_size]
|
|
3035
|
+
ps_attrs << %(scale="#{xml_escape(sheet_ps[:scale])}") if sheet_ps[:scale]
|
|
3036
|
+
ps_attrs << %(fitToWidth="#{xml_escape(sheet_ps[:fit_to_width])}") if sheet_ps[:fit_to_width]
|
|
3037
|
+
ps_attrs << %(fitToHeight="#{xml_escape(sheet_ps[:fit_to_height])}") if sheet_ps[:fit_to_height]
|
|
3038
|
+
ps_attrs << %(pageOrder="#{xml_escape(sheet_ps[:page_order])}") if sheet_ps[:page_order]
|
|
3032
3039
|
ps_attrs << 'blackAndWhite="1"' if sheet_ps[:black_and_white]
|
|
3033
3040
|
ps_attrs << 'draft="1"' if sheet_ps[:draft]
|
|
3034
|
-
ps_attrs << %(cellComments="#{sheet_ps[:cell_comments]}") if sheet_ps[:cell_comments]
|
|
3035
|
-
ps_attrs << %(firstPageNumber="#{sheet_ps[:first_page_number]}") if sheet_ps[:first_page_number] && sheet_ps[:first_page_number].to_i >= 0
|
|
3041
|
+
ps_attrs << %(cellComments="#{xml_escape(sheet_ps[:cell_comments])}") if sheet_ps[:cell_comments]
|
|
3042
|
+
ps_attrs << %(firstPageNumber="#{xml_escape(sheet_ps[:first_page_number])}") if sheet_ps[:first_page_number] && sheet_ps[:first_page_number].to_i >= 0
|
|
3036
3043
|
ps_attrs << 'useFirstPageNumber="1"' if sheet_ps[:use_first_page_number]
|
|
3037
|
-
ps_attrs << %(horizontalDpi="#{sheet_ps[:horizontal_dpi]}") if sheet_ps[:horizontal_dpi].to_i.positive?
|
|
3038
|
-
ps_attrs << %(verticalDpi="#{sheet_ps[:vertical_dpi]}") if sheet_ps[:vertical_dpi].to_i.positive?
|
|
3039
|
-
ps_attrs << %(copies="#{sheet_ps[:copies]}") if sheet_ps[:copies]
|
|
3040
|
-
ps_attrs << %(paperHeight="#{sheet_ps[:paper_height]}") if sheet_ps[:paper_height]
|
|
3041
|
-
ps_attrs << %(paperWidth="#{sheet_ps[:paper_width]}") if sheet_ps[:paper_width]
|
|
3042
|
-
ps_attrs << %(errors="#{sheet_ps[:errors]}") if sheet_ps[:errors]
|
|
3044
|
+
ps_attrs << %(horizontalDpi="#{xml_escape(sheet_ps[:horizontal_dpi])}") if sheet_ps[:horizontal_dpi].to_i.positive?
|
|
3045
|
+
ps_attrs << %(verticalDpi="#{xml_escape(sheet_ps[:vertical_dpi])}") if sheet_ps[:vertical_dpi].to_i.positive?
|
|
3046
|
+
ps_attrs << %(copies="#{xml_escape(sheet_ps[:copies])}") if sheet_ps[:copies]
|
|
3047
|
+
ps_attrs << %(paperHeight="#{xml_escape(sheet_ps[:paper_height])}") if sheet_ps[:paper_height]
|
|
3048
|
+
ps_attrs << %(paperWidth="#{xml_escape(sheet_ps[:paper_width])}") if sheet_ps[:paper_width]
|
|
3049
|
+
ps_attrs << %(errors="#{xml_escape(sheet_ps[:errors])}") if sheet_ps[:errors]
|
|
3043
3050
|
ps_attrs << 'usePrinterDefaults="0"' if sheet_ps[:use_printer_defaults] == false
|
|
3044
3051
|
parts << "<pageSetup #{ps_attrs.join(" ")}/>" unless ps_attrs.empty?
|
|
3045
3052
|
end
|
|
@@ -3073,7 +3080,7 @@ module Xlsxrb
|
|
|
3073
3080
|
true
|
|
3074
3081
|
end
|
|
3075
3082
|
end
|
|
3076
|
-
parts << %(<rowBreaks count="#{sheet_rb.size}" manualBreakCount="#{manual_count}">)
|
|
3083
|
+
parts << %(<rowBreaks count="#{sheet_rb.size}" manualBreakCount="#{xml_escape(manual_count)}">)
|
|
3077
3084
|
sheet_rb.each { |r| parts << emit_brk_xml(r, default_max: 16_383) }
|
|
3078
3085
|
parts << "</rowBreaks>"
|
|
3079
3086
|
end
|
|
@@ -3089,7 +3096,7 @@ module Xlsxrb
|
|
|
3089
3096
|
true
|
|
3090
3097
|
end
|
|
3091
3098
|
end
|
|
3092
|
-
parts << %(<colBreaks count="#{sheet_cb.size}" manualBreakCount="#{manual_count}">)
|
|
3099
|
+
parts << %(<colBreaks count="#{sheet_cb.size}" manualBreakCount="#{xml_escape(manual_count)}">)
|
|
3093
3100
|
sheet_cb.each { |c| parts << emit_brk_xml(c, default_max: 1_048_575) }
|
|
3094
3101
|
parts << "</colBreaks>"
|
|
3095
3102
|
end
|
|
@@ -3097,7 +3104,7 @@ module Xlsxrb
|
|
|
3097
3104
|
# Emit <cellWatches> if defined.
|
|
3098
3105
|
unless cell_watches.empty?
|
|
3099
3106
|
parts << "<cellWatches>"
|
|
3100
|
-
cell_watches.each { |r| parts << %(<cellWatch r="#{r}"/>) }
|
|
3107
|
+
cell_watches.each { |r| parts << %(<cellWatch r="#{xml_escape(r)}"/>) }
|
|
3101
3108
|
parts << "</cellWatches>"
|
|
3102
3109
|
end
|
|
3103
3110
|
|
|
@@ -3105,7 +3112,7 @@ module Xlsxrb
|
|
|
3105
3112
|
unless ignored_errors.empty?
|
|
3106
3113
|
parts << "<ignoredErrors>"
|
|
3107
3114
|
ignored_errors.each do |ie|
|
|
3108
|
-
ie_attrs = %( sqref="#{ie[:sqref]}")
|
|
3115
|
+
ie_attrs = %( sqref="#{xml_escape(ie[:sqref])}")
|
|
3109
3116
|
ie_attrs << ' evalError="1"' if ie[:eval_error]
|
|
3110
3117
|
ie_attrs << ' twoDigitTextYear="1"' if ie[:two_digit_text_year]
|
|
3111
3118
|
ie_attrs << ' numberStoredAsText="1"' if ie[:number_stored_as_text]
|
|
@@ -3125,7 +3132,7 @@ module Xlsxrb
|
|
|
3125
3132
|
parts << %(<tableParts count="#{sheet_tables.size}">)
|
|
3126
3133
|
sheet_tables.each_with_index do |_tbl, i|
|
|
3127
3134
|
rid = hyperlink_count + i + 1
|
|
3128
|
-
parts << %(<tablePart r:id="rId#{rid}"/>)
|
|
3135
|
+
parts << %(<tablePart r:id="rId#{xml_escape(rid)}"/>)
|
|
3129
3136
|
end
|
|
3130
3137
|
parts << "</tableParts>"
|
|
3131
3138
|
end
|
|
@@ -3134,11 +3141,11 @@ module Xlsxrb
|
|
|
3134
3141
|
if has_drawing
|
|
3135
3142
|
# The drawing rId is after hyperlinks + tables + comments + vml
|
|
3136
3143
|
drawing_rid = hyperlink_count + sheet_tables.size + (has_comments ? 2 : 0) + 1
|
|
3137
|
-
parts << %(<drawing r:id="rId#{drawing_rid}"/>)
|
|
3144
|
+
parts << %(<drawing r:id="rId#{xml_escape(drawing_rid)}"/>)
|
|
3138
3145
|
end
|
|
3139
3146
|
|
|
3140
3147
|
# Emit <legacyDrawing> reference if comments exist (VML shapes).
|
|
3141
|
-
parts << %(<legacyDrawing r:id="rId#{vml_rid}"/>) if vml_rid
|
|
3148
|
+
parts << %(<legacyDrawing r:id="rId#{xml_escape(vml_rid)}"/>) if vml_rid
|
|
3142
3149
|
|
|
3143
3150
|
parts << "</worksheet>"
|
|
3144
3151
|
parts.join
|
|
@@ -3175,7 +3182,7 @@ module Xlsxrb
|
|
|
3175
3182
|
rt_sst.each { |rt, idx| entries[idx] = { type: :rt, value: rt } }
|
|
3176
3183
|
str_sst.each { |str, idx| entries[idx] = { type: :str, value: str } }
|
|
3177
3184
|
|
|
3178
|
-
parts = [XML_HEADER, %(<sst xmlns="#{SSML_NS}" count="#{total}" uniqueCount="#{total}">)]
|
|
3185
|
+
parts = [XML_HEADER, %(<sst xmlns="#{SSML_NS}" count="#{xml_escape(total)}" uniqueCount="#{xml_escape(total)}">)]
|
|
3179
3186
|
entries.each do |entry|
|
|
3180
3187
|
parts << if entry[:type] == :rt
|
|
3181
3188
|
"<si>#{rich_text_xml(entry[:value])}</si>"
|
|
@@ -3190,30 +3197,30 @@ module Xlsxrb
|
|
|
3190
3197
|
# : (untyped tbl) -> untyped
|
|
3191
3198
|
def generate_table_xml(tbl)
|
|
3192
3199
|
trc = tbl[:totals_row_count].to_i
|
|
3193
|
-
table_attrs = %(xmlns="#{SSML_NS}" id="#{tbl[:id]}" name="#{xml_escape(tbl[:name])}" displayName="#{xml_escape(tbl[:display_name])}" ref="#{tbl[:ref]}")
|
|
3200
|
+
table_attrs = %(xmlns="#{SSML_NS}" id="#{xml_escape(tbl[:id])}" name="#{xml_escape(tbl[:name])}" displayName="#{xml_escape(tbl[:display_name])}" ref="#{xml_escape(tbl[:ref])}")
|
|
3194
3201
|
table_attrs << %( comment="#{xml_escape(tbl[:comment])}") if tbl[:comment]
|
|
3195
3202
|
hrc = tbl[:header_row_count]
|
|
3196
|
-
table_attrs << %( headerRowCount="#{hrc}") if hrc && hrc != 1
|
|
3203
|
+
table_attrs << %( headerRowCount="#{xml_escape(hrc)}") if hrc && hrc != 1
|
|
3197
3204
|
table_attrs << ' insertRow="1"' if tbl[:insert_row]
|
|
3198
3205
|
table_attrs << ' insertRowShift="1"' if tbl[:insert_row_shift]
|
|
3199
|
-
table_attrs << %( totalsRowCount="#{trc}") if trc.positive?
|
|
3206
|
+
table_attrs << %( totalsRowCount="#{xml_escape(trc)}") if trc.positive?
|
|
3200
3207
|
table_attrs << ' totalsRowShown="0"' if trc.zero?
|
|
3201
3208
|
table_attrs << ' published="1"' if tbl[:published]
|
|
3202
|
-
table_attrs << %( headerRowDxfId="#{tbl[:header_row_dxf_id]}") if tbl[:header_row_dxf_id]
|
|
3203
|
-
table_attrs << %( dataDxfId="#{tbl[:data_dxf_id]}") if tbl[:data_dxf_id]
|
|
3204
|
-
table_attrs << %( totalsRowDxfId="#{tbl[:totals_row_dxf_id]}") if tbl[:totals_row_dxf_id]
|
|
3205
|
-
table_attrs << %( headerRowBorderDxfId="#{tbl[:header_row_border_dxf_id]}") if tbl[:header_row_border_dxf_id]
|
|
3206
|
-
table_attrs << %( tableBorderDxfId="#{tbl[:table_border_dxf_id]}") if tbl[:table_border_dxf_id]
|
|
3207
|
-
table_attrs << %( totalsRowBorderDxfId="#{tbl[:totals_row_border_dxf_id]}") if tbl[:totals_row_border_dxf_id]
|
|
3209
|
+
table_attrs << %( headerRowDxfId="#{xml_escape(tbl[:header_row_dxf_id])}") if tbl[:header_row_dxf_id]
|
|
3210
|
+
table_attrs << %( dataDxfId="#{xml_escape(tbl[:data_dxf_id])}") if tbl[:data_dxf_id]
|
|
3211
|
+
table_attrs << %( totalsRowDxfId="#{xml_escape(tbl[:totals_row_dxf_id])}") if tbl[:totals_row_dxf_id]
|
|
3212
|
+
table_attrs << %( headerRowBorderDxfId="#{xml_escape(tbl[:header_row_border_dxf_id])}") if tbl[:header_row_border_dxf_id]
|
|
3213
|
+
table_attrs << %( tableBorderDxfId="#{xml_escape(tbl[:table_border_dxf_id])}") if tbl[:table_border_dxf_id]
|
|
3214
|
+
table_attrs << %( totalsRowBorderDxfId="#{xml_escape(tbl[:totals_row_border_dxf_id])}") if tbl[:totals_row_border_dxf_id]
|
|
3208
3215
|
table_attrs << %( headerRowCellStyle="#{xml_escape(tbl[:header_row_cell_style])}") if tbl[:header_row_cell_style]
|
|
3209
3216
|
table_attrs << %( totalsRowCellStyle="#{xml_escape(tbl[:totals_row_cell_style])}") if tbl[:totals_row_cell_style]
|
|
3210
|
-
table_attrs << %( connectionId="#{tbl[:connection_id]}") if tbl[:connection_id]
|
|
3217
|
+
table_attrs << %( connectionId="#{xml_escape(tbl[:connection_id])}") if tbl[:connection_id]
|
|
3211
3218
|
table_attrs << %( tableType="#{xml_escape(tbl[:table_type])}") if tbl[:table_type]
|
|
3212
3219
|
parts = [
|
|
3213
3220
|
XML_HEADER,
|
|
3214
3221
|
"<table #{table_attrs}>"
|
|
3215
3222
|
]
|
|
3216
|
-
parts << %(<autoFilter ref="#{tbl[:ref]}"/>) unless tbl[:auto_filter] == false
|
|
3223
|
+
parts << %(<autoFilter ref="#{xml_escape(tbl[:ref])}"/>) unless tbl[:auto_filter] == false
|
|
3217
3224
|
parts << %(<tableColumns count="#{tbl[:columns].size}">)
|
|
3218
3225
|
tbl[:columns].each_with_index do |col, i|
|
|
3219
3226
|
col = col.to_h if col.is_a?(Elements::MetadataRecord)
|
|
@@ -3229,11 +3236,11 @@ module Xlsxrb
|
|
|
3229
3236
|
calc_formula = col[:calculated_column_formula] || col[:data_formula] || col[:formula]
|
|
3230
3237
|
tot_formula = col[:totals_row_formula]
|
|
3231
3238
|
trf = col[:totals_row_function] || ("custom" if tot_formula)
|
|
3232
|
-
col_attrs << %( totalsRowFunction="#{trf}") if trf
|
|
3239
|
+
col_attrs << %( totalsRowFunction="#{xml_escape(trf)}") if trf
|
|
3233
3240
|
col_attrs << %( totalsRowLabel="#{xml_escape(col[:totals_row_label])}") if col[:totals_row_label]
|
|
3234
|
-
col_attrs << %( dataDxfId="#{col[:data_dxf_id]}") if col[:data_dxf_id]
|
|
3235
|
-
col_attrs << %( totalsRowDxfId="#{col[:totals_row_dxf_id]}") if col[:totals_row_dxf_id]
|
|
3236
|
-
col_attrs << %( headerRowDxfId="#{col[:header_row_dxf_id]}") if col[:header_row_dxf_id]
|
|
3241
|
+
col_attrs << %( dataDxfId="#{xml_escape(col[:data_dxf_id])}") if col[:data_dxf_id]
|
|
3242
|
+
col_attrs << %( totalsRowDxfId="#{xml_escape(col[:totals_row_dxf_id])}") if col[:totals_row_dxf_id]
|
|
3243
|
+
col_attrs << %( headerRowDxfId="#{xml_escape(col[:header_row_dxf_id])}") if col[:header_row_dxf_id]
|
|
3237
3244
|
col_attrs << %( dataCellStyle="#{xml_escape(col[:data_cell_style])}") if col[:data_cell_style]
|
|
3238
3245
|
if calc_formula || tot_formula
|
|
3239
3246
|
parts << "<tableColumn #{col_attrs}>"
|
|
@@ -3273,7 +3280,7 @@ module Xlsxrb
|
|
|
3273
3280
|
slc = show_last_column ? "1" : "0"
|
|
3274
3281
|
srs = show_row_stripes ? "1" : "0"
|
|
3275
3282
|
scs = show_column_stripes ? "1" : "0"
|
|
3276
|
-
parts << %(<tableStyleInfo name="#{xml_escape(style_name)}" showFirstColumn="#{sfc}" showLastColumn="#{slc}" showRowStripes="#{srs}" showColumnStripes="#{scs}"/>)
|
|
3283
|
+
parts << %(<tableStyleInfo name="#{xml_escape(style_name)}" showFirstColumn="#{xml_escape(sfc)}" showLastColumn="#{xml_escape(slc)}" showRowStripes="#{xml_escape(srs)}" showColumnStripes="#{xml_escape(scs)}"/>)
|
|
3277
3284
|
parts << "</table>"
|
|
3278
3285
|
parts.join
|
|
3279
3286
|
end
|
|
@@ -3289,11 +3296,11 @@ module Xlsxrb
|
|
|
3289
3296
|
next unless link[:url]
|
|
3290
3297
|
|
|
3291
3298
|
rid += 1
|
|
3292
|
-
parts << %(<Relationship Id="rId#{rid}" Type="#{DOC_REL_NS}/hyperlink" Target="#{xml_escape(link[:url])}" TargetMode="External"/>)
|
|
3299
|
+
parts << %(<Relationship Id="rId#{xml_escape(rid)}" Type="#{DOC_REL_NS}/hyperlink" Target="#{xml_escape(link[:url])}" TargetMode="External"/>)
|
|
3293
3300
|
end
|
|
3294
3301
|
sheet_tables.each_with_index do |_tbl, i|
|
|
3295
3302
|
rid += 1
|
|
3296
|
-
parts << %(<Relationship Id="rId#{rid}" Type="#{DOC_REL_NS}/table" Target="../tables/table#{table_start_index + i + 1}.xml"/>)
|
|
3303
|
+
parts << %(<Relationship Id="rId#{xml_escape(rid)}" Type="#{DOC_REL_NS}/table" Target="../tables/table#{xml_escape(table_start_index + i + 1)}.xml"/>)
|
|
3297
3304
|
end
|
|
3298
3305
|
parts << "</Relationships>"
|
|
3299
3306
|
parts.join
|
|
@@ -3328,7 +3335,7 @@ module Xlsxrb
|
|
|
3328
3335
|
parts = [XML_HEADER, %(<Relationships xmlns="#{REL_NS}">)]
|
|
3329
3336
|
rels_data.each_with_index do |rel, i|
|
|
3330
3337
|
ext_attr = rel[:external] ? ' TargetMode="External"' : ""
|
|
3331
|
-
parts << %(<Relationship Id="rId#{i + 1}" Type="#{rel[:type]}" Target="#{xml_escape(rel[:target])}"#{ext_attr}/>)
|
|
3338
|
+
parts << %(<Relationship Id="rId#{i + 1}" Type="#{xml_escape(rel[:type])}" Target="#{xml_escape(rel[:target])}"#{ext_attr}/>)
|
|
3332
3339
|
end
|
|
3333
3340
|
parts << "</Relationships>"
|
|
3334
3341
|
parts.join
|