axlsx 1.0.17 → 1.1.0
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.
- data/CHANGELOG.md +11 -3
- data/README.md +159 -51
- data/examples/example.csv +1000 -0
- data/examples/example.rb +255 -150
- data/examples/example.xlsx +0 -0
- data/examples/example_streamed.xlsx +0 -0
- data/examples/no-use_autowidth.xlsx +0 -0
- data/examples/shared_strings_example.xlsx +0 -0
- data/lib/axlsx/content_type/content_type.rb +12 -12
- data/lib/axlsx/content_type/default.rb +9 -6
- data/lib/axlsx/content_type/override.rb +12 -8
- data/lib/axlsx/doc_props/app.rb +37 -40
- data/lib/axlsx/doc_props/core.rb +12 -17
- data/lib/axlsx/drawing/axis.rb +38 -19
- data/lib/axlsx/drawing/bar_3D_chart.rb +33 -32
- data/lib/axlsx/drawing/bar_series.rb +13 -14
- data/lib/axlsx/drawing/cat_axis.rb +15 -14
- data/lib/axlsx/drawing/cat_axis_data.rb +16 -18
- data/lib/axlsx/drawing/chart.rb +39 -40
- data/lib/axlsx/drawing/drawing.rb +15 -12
- data/lib/axlsx/drawing/graphic_frame.rb +21 -21
- data/lib/axlsx/drawing/hyperlink.rb +12 -11
- data/lib/axlsx/drawing/line_3D_chart.rb +30 -28
- data/lib/axlsx/drawing/line_series.rb +11 -11
- data/lib/axlsx/drawing/marker.rb +10 -8
- data/lib/axlsx/drawing/named_axis_data.rb +36 -0
- data/lib/axlsx/drawing/one_cell_anchor.rb +17 -16
- data/lib/axlsx/drawing/pic.rb +25 -37
- data/lib/axlsx/drawing/picture_locking.rb +21 -18
- data/lib/axlsx/drawing/pie_3D_chart.rb +10 -8
- data/lib/axlsx/drawing/pie_series.rb +15 -12
- data/lib/axlsx/drawing/scaling.rb +10 -10
- data/lib/axlsx/drawing/scatter_chart.rb +69 -0
- data/lib/axlsx/drawing/scatter_series.rb +39 -0
- data/lib/axlsx/drawing/ser_axis.rb +10 -10
- data/lib/axlsx/drawing/series.rb +15 -15
- data/lib/axlsx/drawing/series_title.rb +14 -14
- data/lib/axlsx/drawing/title.rb +26 -26
- data/lib/axlsx/drawing/two_cell_anchor.rb +18 -20
- data/lib/axlsx/drawing/val_axis.rb +8 -7
- data/lib/axlsx/drawing/val_axis_data.rb +17 -17
- data/lib/axlsx/drawing/view_3D.rb +22 -20
- data/lib/axlsx/package.rb +60 -43
- data/lib/axlsx/rels/relationship.rb +11 -8
- data/lib/axlsx/rels/relationships.rb +7 -1
- data/lib/axlsx/stylesheet/#num_fmt.rb# +69 -0
- data/lib/axlsx/stylesheet/border.rb +27 -23
- data/lib/axlsx/stylesheet/border_pr.rb +16 -15
- data/lib/axlsx/stylesheet/cell_alignment.rb +23 -21
- data/lib/axlsx/stylesheet/cell_protection.rb +10 -7
- data/lib/axlsx/stylesheet/cell_style.rb +8 -5
- data/lib/axlsx/stylesheet/color.rb +20 -14
- data/lib/axlsx/stylesheet/fill.rb +7 -5
- data/lib/axlsx/stylesheet/font.rb +21 -14
- data/lib/axlsx/stylesheet/gradient_fill.rb +19 -16
- data/lib/axlsx/stylesheet/gradient_stop.rb +9 -5
- data/lib/axlsx/stylesheet/num_fmt.rb +12 -6
- data/lib/axlsx/stylesheet/pattern_fill.rb +25 -10
- data/lib/axlsx/stylesheet/styles.rb +47 -35
- data/lib/axlsx/stylesheet/table_style.rb +9 -4
- data/lib/axlsx/stylesheet/table_style_element.rb +10 -7
- data/lib/axlsx/stylesheet/table_styles.rb +11 -8
- data/lib/axlsx/stylesheet/xf.rb +29 -25
- data/lib/axlsx/util/constants.rb +20 -14
- data/lib/axlsx/util/simple_typed_list.rb +18 -9
- data/lib/axlsx/util/validators.rb +13 -6
- data/lib/axlsx/version.rb +1 -1
- data/lib/axlsx/workbook/shared_strings_table.rb +19 -21
- data/lib/axlsx/workbook/workbook.rb +58 -34
- data/lib/axlsx/workbook/worksheet/cell.rb +149 -132
- data/lib/axlsx/workbook/worksheet/col.rb +114 -0
- data/lib/axlsx/workbook/worksheet/col.rb~ +0 -0
- data/lib/axlsx/workbook/worksheet/date_time_converter.rb +29 -0
- data/lib/axlsx/workbook/worksheet/page_margins.rb +97 -0
- data/lib/axlsx/workbook/worksheet/row.rb +40 -23
- data/lib/axlsx/workbook/worksheet/table.rb +96 -0
- data/lib/axlsx/workbook/worksheet/table.rb~ +97 -0
- data/lib/axlsx/workbook/worksheet/worksheet.rb +243 -127
- data/lib/axlsx.rb +30 -9
- data/lib/schema/dc.xsd +5 -5
- data/lib/schema/dcmitype.xsd +5 -3
- data/lib/schema/dcterms.xsd +15 -15
- data/lib/schema/opc-coreProperties.xsd +6 -2
- data/lib/schema/xml.xsd +7 -8
- data/test/#benchmark.txt# +7 -0
- data/test/#tc_helper.rb# +3 -0
- data/test/benchmark.rb +81 -0
- data/test/benchmark.rb~ +0 -0
- data/test/benchmark.txt +6 -0
- data/test/benchmark.txt~ +6 -0
- data/test/content_type/tc_content_type.rb +30 -32
- data/test/content_type/tc_default.rb +8 -23
- data/test/content_type/tc_override.rb +7 -21
- data/test/doc_props/tc_app.rb +2 -8
- data/test/doc_props/tc_core.rb +6 -7
- data/test/drawing/tc_axis.rb +7 -3
- data/test/drawing/tc_bar_3D_chart.rb +6 -7
- data/test/drawing/tc_bar_series.rb +4 -5
- data/test/drawing/tc_cat_axis.rb +2 -3
- data/test/drawing/tc_cat_axis_data.rb +2 -3
- data/test/drawing/tc_chart.rb +13 -14
- data/test/drawing/tc_drawing.rb +7 -8
- data/test/drawing/tc_graphic_frame.rb +3 -4
- data/test/drawing/tc_hyperlink.rb +2 -3
- data/test/drawing/tc_line_3d_chart.rb +5 -6
- data/test/drawing/tc_line_series.rb +3 -4
- data/test/drawing/tc_marker.rb +3 -4
- data/test/drawing/tc_one_cell_anchor.rb +6 -7
- data/test/drawing/tc_pic.rb +8 -9
- data/test/drawing/tc_picture_locking.rb +2 -3
- data/test/drawing/tc_pie_3D_chart.rb +5 -6
- data/test/drawing/tc_pie_series.rb +4 -5
- data/test/drawing/tc_scaling.rb +3 -4
- data/test/drawing/tc_scatter_chart.rb +43 -0
- data/test/drawing/tc_scatter_series.rb +20 -0
- data/test/drawing/tc_ser_axis.rb +2 -3
- data/test/drawing/tc_series.rb +4 -5
- data/test/drawing/tc_series_title.rb +4 -5
- data/test/drawing/tc_title.rb +4 -5
- data/test/drawing/tc_two_cell_anchor.rb +4 -5
- data/test/drawing/tc_val_axis.rb +2 -3
- data/test/drawing/tc_val_axis_data.rb +2 -3
- data/test/drawing/tc_view_3D.rb +6 -7
- data/test/example.csv +1000 -0
- data/test/example.xlsx +0 -0
- data/test/example_streamed.xlsx +0 -0
- data/test/profile.rb +33 -0
- data/test/rels/tc_relationship.rb +5 -6
- data/test/rels/tc_relationships.rb +4 -5
- data/test/stylesheet/tc_border.rb +3 -4
- data/test/stylesheet/tc_border_pr.rb +3 -4
- data/test/stylesheet/tc_cell_alignment.rb +10 -6
- data/test/stylesheet/tc_cell_protection.rb +2 -3
- data/test/stylesheet/tc_cell_style.rb +2 -3
- data/test/stylesheet/tc_color.rb +2 -3
- data/test/stylesheet/tc_fill.rb +1 -2
- data/test/stylesheet/tc_font.rb +12 -5
- data/test/stylesheet/tc_gradient_fill.rb +1 -2
- data/test/stylesheet/tc_gradient_stop.rb +1 -2
- data/test/stylesheet/tc_num_fmt.rb +1 -2
- data/test/stylesheet/tc_pattern_fill.rb +3 -4
- data/test/stylesheet/tc_styles.rb +16 -6
- data/test/stylesheet/tc_table_style.rb +2 -3
- data/test/stylesheet/tc_table_style_element.rb +2 -3
- data/test/stylesheet/tc_table_styles.rb +3 -4
- data/test/stylesheet/tc_xf.rb +16 -17
- data/test/tc_axlsx.rb +39 -0
- data/test/tc_axlsx.rb~ +0 -0
- data/test/tc_helper.rb +3 -0
- data/test/tc_helper.rb~ +3 -0
- data/test/tc_package.rb +13 -10
- data/test/util/tc_simple_typed_list.rb +8 -9
- data/test/util/tc_validators.rb +7 -8
- data/test/workbook/tc_shared_strings_table.rb +5 -6
- data/test/workbook/tc_workbook.rb +24 -6
- data/test/workbook/worksheet/table/tc_table.rb +71 -0
- data/test/workbook/worksheet/table/tc_table.rb~ +72 -0
- data/test/workbook/worksheet/tc_cell.rb +62 -18
- data/test/workbook/worksheet/tc_col.rb +59 -0
- data/test/workbook/worksheet/tc_col.rb~ +10 -0
- data/test/workbook/worksheet/tc_date_time_converter.rb +126 -0
- data/test/workbook/worksheet/tc_page_margins.rb +97 -0
- data/test/workbook/worksheet/tc_row.rb +54 -4
- data/test/workbook/worksheet/tc_worksheet.rb +177 -34
- metadata +69 -41
- data/test/drawing/tc_hyperlink.rb~ +0 -71
- data/test/workbook/tc_shared_strings_table.rb~ +0 -8
data/lib/axlsx/version.rb
CHANGED
|
@@ -5,6 +5,6 @@ module Axlsx
|
|
|
5
5
|
# When using bunle exec rake and referencing the gem on github or locally
|
|
6
6
|
# it will use the gemspec, which preloads this constant for the gem's version.
|
|
7
7
|
# We check to make sure that it has not already been loaded
|
|
8
|
-
VERSION="1.0
|
|
8
|
+
VERSION="1.1.0" unless defined? Axlsx::VERSION
|
|
9
9
|
|
|
10
10
|
end
|
|
@@ -3,7 +3,7 @@ module Axlsx
|
|
|
3
3
|
|
|
4
4
|
# The Shared String Table class is responsible for managing and serializing common strings in a workbook.
|
|
5
5
|
# While the ECMA-376 spec allows for both inline and shared strings it seems that at least some applications like iWorks Numbers
|
|
6
|
-
# and Google Docs require that the shared string table is populated in order to interoperate properly.
|
|
6
|
+
# and Google Docs require that the shared string table is populated in order to interoperate properly.
|
|
7
7
|
# As a developer, you should never need to directly work against this class. Simply set 'use_shared_strings'
|
|
8
8
|
# on the package or workbook to generate a package that uses the shared strings table instead of inline strings.
|
|
9
9
|
# @note Serialization performance is affected by using this serialization method so if you do not need interoperability
|
|
@@ -15,57 +15,55 @@ module Axlsx
|
|
|
15
15
|
# @return [Integer]
|
|
16
16
|
attr_reader :count
|
|
17
17
|
|
|
18
|
-
# The total number of unique strings in the workbook.
|
|
18
|
+
# The total number of unique strings in the workbook.
|
|
19
19
|
# @return [Integer]
|
|
20
20
|
def unique_count
|
|
21
21
|
@unique_cells.size
|
|
22
22
|
end
|
|
23
23
|
|
|
24
24
|
# An array of unique cells. Multiple attributes of the cell are used in comparison
|
|
25
|
-
# each of these unique cells is parsed into the shared string table.
|
|
25
|
+
# each of these unique cells is parsed into the shared string table.
|
|
26
26
|
# @see Cell#sharable
|
|
27
27
|
attr_reader :unique_cells
|
|
28
28
|
|
|
29
29
|
# Creates a new Shared Strings Table agains an array of cells
|
|
30
30
|
# @param [Array] cells This is an array of all of the cells in the workbook
|
|
31
31
|
def initialize(cells)
|
|
32
|
-
cells = cells.flatten.reject { |c| c.type != :string || c.value.start_with?('=') }
|
|
32
|
+
cells = cells.flatten.reject { |c| c.type != :string || c.value.nil? || c.value.start_with?('=') }
|
|
33
33
|
@count = cells.size
|
|
34
34
|
@unique_cells = []
|
|
35
|
+
@shared_xml_string = ""
|
|
35
36
|
resolve(cells)
|
|
36
37
|
end
|
|
37
38
|
|
|
38
|
-
|
|
39
|
-
#
|
|
39
|
+
# Serializes the object
|
|
40
|
+
# @param [String] str
|
|
40
41
|
# @return [String]
|
|
41
|
-
def
|
|
42
|
-
|
|
43
|
-
xml.sst(:xmlns => Axlsx::XML_NS, :count => count, :uniqueCount => unique_count) {
|
|
44
|
-
@unique_cells.each do |cell|
|
|
45
|
-
xml.si { cell.run_xml(xml) }
|
|
46
|
-
end
|
|
47
|
-
}
|
|
48
|
-
end
|
|
49
|
-
builder.to_xml(:save_with => 0)
|
|
42
|
+
def to_xml_string
|
|
43
|
+
'<?xml version="1.0" encoding="UTF-8"?><sst xmlns="' << XML_NS << '" count="' << @count.to_s << '" uniqueCount="' << unique_count.to_s << '">' << @shared_xml_string << '</sst>'
|
|
50
44
|
end
|
|
51
45
|
|
|
52
46
|
private
|
|
53
|
-
|
|
54
|
-
# Interate over all of the cells in the array.
|
|
55
|
-
# if our unique cells array does not contain a sharable cell,
|
|
47
|
+
|
|
48
|
+
# Interate over all of the cells in the array.
|
|
49
|
+
# if our unique cells array does not contain a sharable cell,
|
|
56
50
|
# add the cell to our unique cells array and set the ssti attribute on the index of this cell in the shared strings table
|
|
57
51
|
# if a sharable cell already exists in our unique_cells array, set the ssti attribute of the cell and move on.
|
|
58
52
|
# @return [Array] unique cells
|
|
59
53
|
def resolve(cells)
|
|
60
54
|
cells.each do |cell|
|
|
61
|
-
|
|
55
|
+
cell_hash = cell.shareable_hash
|
|
56
|
+
index = @unique_cells.index do |item|
|
|
57
|
+
item == cell_hash
|
|
58
|
+
end
|
|
62
59
|
if index == nil
|
|
63
60
|
cell.send :ssti=, @unique_cells.size
|
|
64
|
-
@
|
|
61
|
+
@shared_xml_string << '<si>' << cell.run_xml_string << '</si>'
|
|
62
|
+
@unique_cells << cell_hash
|
|
65
63
|
else
|
|
66
64
|
cell.send :ssti=, index
|
|
67
65
|
end
|
|
68
66
|
end
|
|
69
|
-
end
|
|
67
|
+
end
|
|
70
68
|
end
|
|
71
69
|
end
|
|
@@ -1,14 +1,18 @@
|
|
|
1
1
|
# -*- coding: utf-8 -*-
|
|
2
|
-
module Axlsx
|
|
2
|
+
module Axlsx
|
|
3
3
|
|
|
4
|
+
require 'axlsx/workbook/worksheet/date_time_converter.rb'
|
|
4
5
|
require 'axlsx/workbook/worksheet/cell.rb'
|
|
6
|
+
require 'axlsx/workbook/worksheet/page_margins.rb'
|
|
5
7
|
require 'axlsx/workbook/worksheet/row.rb'
|
|
8
|
+
require 'axlsx/workbook/worksheet/col.rb'
|
|
6
9
|
require 'axlsx/workbook/worksheet/worksheet.rb'
|
|
7
10
|
require 'axlsx/workbook/shared_strings_table.rb'
|
|
11
|
+
require 'axlsx/workbook/worksheet/table.rb'
|
|
8
12
|
|
|
9
13
|
# The Workbook class is an xlsx workbook that manages worksheets, charts, drawings and styles.
|
|
10
14
|
# The following parts of the Office Open XML spreadsheet specification are not implimented in this version.
|
|
11
|
-
#
|
|
15
|
+
#
|
|
12
16
|
# bookViews
|
|
13
17
|
# calcPr
|
|
14
18
|
# customWorkbookViews
|
|
@@ -38,13 +42,13 @@ require 'axlsx/workbook/shared_strings_table.rb'
|
|
|
38
42
|
attr_reader :use_shared_strings
|
|
39
43
|
|
|
40
44
|
# @see use_shared_strings
|
|
41
|
-
def use_shared_strings=(v)
|
|
45
|
+
def use_shared_strings=(v)
|
|
42
46
|
Axlsx::validate_boolean(v)
|
|
43
47
|
@use_shared_strings = v
|
|
44
48
|
end
|
|
45
49
|
|
|
46
50
|
|
|
47
|
-
|
|
51
|
+
# A collection of worksheets associated with this workbook.
|
|
48
52
|
# @note The recommended way to manage worksheets is add_worksheet
|
|
49
53
|
# @see Workbook#add_worksheet
|
|
50
54
|
# @see Worksheet
|
|
@@ -72,6 +76,14 @@ require 'axlsx/workbook/shared_strings_table.rb'
|
|
|
72
76
|
# @return [SimpleTypedList]
|
|
73
77
|
attr_reader :drawings
|
|
74
78
|
|
|
79
|
+
# A colllection of tables associated with this workbook
|
|
80
|
+
# @note The recommended way to manage drawings is Worksheet#add_table
|
|
81
|
+
# @see Worksheet#add_table
|
|
82
|
+
# @see Table
|
|
83
|
+
# @return [SimpleTypedList]
|
|
84
|
+
attr_reader :tables
|
|
85
|
+
|
|
86
|
+
|
|
75
87
|
# The styles associated with this workbook
|
|
76
88
|
# @note The recommended way to manage styles is Styles#add_style
|
|
77
89
|
# @see Style#add_style
|
|
@@ -86,39 +98,35 @@ require 'axlsx/workbook/shared_strings_table.rb'
|
|
|
86
98
|
# Indicates if the epoc date for serialization should be 1904. If false, 1900 is used.
|
|
87
99
|
@@date1904 = false
|
|
88
100
|
|
|
89
|
-
|
|
101
|
+
|
|
102
|
+
# lets come back to this later when we are ready for parsing.
|
|
90
103
|
#def self.parse entry
|
|
91
104
|
# io = entry.get_input_stream
|
|
92
105
|
# w = self.new
|
|
93
106
|
# w.parser_xml = Nokogiri::XML(io.read)
|
|
94
|
-
# w.parse_string :date1904, "//xmlns:workbookPr/@date1904"
|
|
107
|
+
# w.parse_string :date1904, "//xmlns:workbookPr/@date1904"
|
|
95
108
|
# w
|
|
96
109
|
#end
|
|
97
110
|
|
|
98
111
|
# Creates a new Workbook
|
|
99
112
|
# The recomended way to work with workbooks is via Package#workbook
|
|
100
|
-
# @option options [Boolean] date1904. If this is not specified,
|
|
113
|
+
# @option options [Boolean] date1904. If this is not specified, date1904 is set to false. Office 2011 for Mac defaults to false.
|
|
101
114
|
def initialize(options={})
|
|
102
115
|
@styles = Styles.new
|
|
103
116
|
@worksheets = SimpleTypedList.new Worksheet
|
|
104
117
|
@drawings = SimpleTypedList.new Drawing
|
|
105
118
|
@charts = SimpleTypedList.new Chart
|
|
106
119
|
@images = SimpleTypedList.new Pic
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
end
|
|
120
|
+
@tables = SimpleTypedList.new Table
|
|
121
|
+
@use_autowidth = true
|
|
110
122
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
# @return [Boolean]
|
|
114
|
-
def is_bsd?
|
|
115
|
-
platform = RUBY_PLATFORM.downcase
|
|
116
|
-
platform.include?('freebsd') || platform.include?('darwin')
|
|
123
|
+
self.date1904= !options[:date1904].nil? && options[:date1904]
|
|
124
|
+
yield self if block_given?
|
|
117
125
|
end
|
|
118
126
|
|
|
119
127
|
# Instance level access to the class variable 1904
|
|
120
128
|
# @return [Boolean]
|
|
121
|
-
def date1904() @@date1904; end
|
|
129
|
+
def date1904() @@date1904; end
|
|
122
130
|
|
|
123
131
|
# see @date1904
|
|
124
132
|
def date1904=(v) Axlsx::validate_boolean v; @@date1904 = v; end
|
|
@@ -131,9 +139,18 @@ require 'axlsx/workbook/shared_strings_table.rb'
|
|
|
131
139
|
# @return [Boolean]
|
|
132
140
|
def self.date1904() @@date1904; end
|
|
133
141
|
|
|
142
|
+
# Indicates if the workbook should use autowidths or not.
|
|
143
|
+
# this must be set before instantiating a worksheet to avoid Rmagix inclusion
|
|
144
|
+
# @return [Boolean]
|
|
145
|
+
def use_autowidth() @use_autowidth; end
|
|
146
|
+
|
|
147
|
+
# see @use_autowidth
|
|
148
|
+
def use_autowidth=(v) Axlsx::validate_boolean v; @use_autowidth = v; end
|
|
149
|
+
|
|
134
150
|
# Adds a worksheet to this workbook
|
|
135
151
|
# @return [Worksheet]
|
|
136
152
|
# @option options [String] name The name of the worksheet.
|
|
153
|
+
# @option options [Hash] page_margins The page margins for the worksheet.
|
|
137
154
|
# @see Worksheet#initialize
|
|
138
155
|
def add_worksheet(options={})
|
|
139
156
|
worksheet = Worksheet.new(self, options)
|
|
@@ -147,7 +164,7 @@ require 'axlsx/workbook/shared_strings_table.rb'
|
|
|
147
164
|
r = Relationships.new
|
|
148
165
|
@worksheets.each do |sheet|
|
|
149
166
|
r << Relationship.new(WORKSHEET_R, WORKSHEET_PN % (r.size+1))
|
|
150
|
-
end
|
|
167
|
+
end
|
|
151
168
|
r << Relationship.new(STYLES_R, STYLES_PN)
|
|
152
169
|
if use_shared_strings
|
|
153
170
|
r << Relationship.new(SHARED_STRINGS_R, SHARED_STRINGS_PN)
|
|
@@ -162,32 +179,39 @@ require 'axlsx/workbook/shared_strings_table.rb'
|
|
|
162
179
|
end
|
|
163
180
|
|
|
164
181
|
# returns a range of cells in a worksheet
|
|
165
|
-
# @param [String] cell_def The excel style reference defining the worksheet and cells. The range must specify the sheet to
|
|
182
|
+
# @param [String] cell_def The excel style reference defining the worksheet and cells. The range must specify the sheet to
|
|
166
183
|
# retrieve the cells from. e.g. range('Sheet1!A1:B2') will return an array of four cells [A1, A2, B1, B2] while range('Sheet1!A1') will return a single Cell.
|
|
167
184
|
# @return [Cell, Array]
|
|
168
185
|
def [](cell_def)
|
|
169
186
|
sheet_name = cell_def.split('!')[0] if cell_def.match('!')
|
|
170
187
|
worksheet = self.worksheets.select { |s| s.name == sheet_name }.first
|
|
171
|
-
raise ArgumentError, 'Unknown Sheet' unless sheet_name && worksheet.is_a?(Worksheet)
|
|
188
|
+
raise ArgumentError, 'Unknown Sheet' unless sheet_name && worksheet.is_a?(Worksheet)
|
|
172
189
|
worksheet[cell_def.gsub(/.+!/,"")]
|
|
173
190
|
end
|
|
174
191
|
|
|
175
|
-
#
|
|
192
|
+
# Serialize the workbook
|
|
193
|
+
# @param [String] str
|
|
176
194
|
# @return [String]
|
|
177
|
-
def
|
|
195
|
+
def to_xml_string(str='')
|
|
178
196
|
add_worksheet unless worksheets.size > 0
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
197
|
+
str << '<?xml version="1.0" encoding="UTF-8"?>'
|
|
198
|
+
str << '<workbook xmlns="' << XML_NS << '" xmlns:r="' << XML_NS_R << '">'
|
|
199
|
+
str << '<workbookPr date1904="' << @@date1904.to_s << '"/>'
|
|
200
|
+
str << '<sheets>'
|
|
201
|
+
@worksheets.each_with_index do |sheet, index|
|
|
202
|
+
str << '<sheet name="' << sheet.name << '" sheetId="' << (index+1).to_s << '" r:id="' << sheet.rId << '"/>'
|
|
203
|
+
end
|
|
204
|
+
str << '</sheets>'
|
|
205
|
+
str << '<definedNames>'
|
|
206
|
+
@worksheets.each_with_index do |sheet, index|
|
|
207
|
+
if sheet.auto_filter
|
|
208
|
+
str << '<definedName name="_xlnm._FilterDatabase" localSheetId="' << index.to_s << '" hidden="1">'
|
|
209
|
+
str << sheet.abs_auto_filter << '</definedName>'
|
|
210
|
+
end
|
|
211
|
+
end
|
|
212
|
+
str << '</definedNames>'
|
|
213
|
+
str << '</workbook>'
|
|
191
214
|
end
|
|
215
|
+
|
|
192
216
|
end
|
|
193
217
|
end
|