axlsx 1.1.7 → 1.1.8
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +41 -5
- data/Rakefile +3 -2
- data/examples/chart_colors.rb +18 -3
- data/examples/example.rb +100 -46
- data/examples/extractive.pdf +0 -0
- data/lib/axlsx.rb +7 -6
- data/lib/axlsx/content_type/content_type.rb +2 -0
- data/lib/axlsx/content_type/default.rb +21 -12
- data/lib/axlsx/content_type/override.rb +22 -11
- data/lib/axlsx/doc_props/app.rb +36 -32
- data/lib/axlsx/doc_props/core.rb +9 -5
- data/lib/axlsx/drawing/ax_data_source.rb +7 -6
- data/lib/axlsx/drawing/axis.rb +48 -27
- data/lib/axlsx/drawing/bar_3D_chart.rb +47 -37
- data/lib/axlsx/drawing/bar_series.rb +1 -0
- data/lib/axlsx/drawing/cat_axis.rb +42 -38
- data/lib/axlsx/drawing/chart.rb +34 -27
- data/lib/axlsx/drawing/drawing.rb +5 -4
- data/lib/axlsx/drawing/line_3D_chart.rb +1 -1
- data/lib/axlsx/drawing/num_data_source.rb +1 -1
- data/lib/axlsx/drawing/pie_3D_chart.rb +7 -7
- data/lib/axlsx/drawing/two_cell_anchor.rb +3 -8
- data/lib/axlsx/drawing/view_3D.rb +41 -31
- data/lib/axlsx/drawing/vml_drawing.rb +1 -1
- data/lib/axlsx/package.rb +11 -11
- data/lib/axlsx/rels/relationship.rb +3 -3
- data/lib/axlsx/stylesheet/styles.rb +1 -1
- data/lib/axlsx/util/constants.rb +4 -0
- data/lib/axlsx/util/simple_typed_list.rb +2 -2
- data/lib/axlsx/util/validators.rb +2 -2
- data/lib/axlsx/version.rb +1 -1
- data/lib/axlsx/workbook/workbook.rb +1 -2
- data/lib/axlsx/workbook/worksheet/cell.rb +1 -1
- data/lib/axlsx/workbook/worksheet/data_bar.rb +1 -1
- data/lib/axlsx/workbook/worksheet/page_setup.rb +9 -0
- data/lib/axlsx/workbook/worksheet/protected_range.rb +46 -0
- data/lib/axlsx/workbook/worksheet/worksheet.rb +180 -56
- data/test/content_type/tc_content_type.rb +1 -6
- data/test/doc_props/tc_core.rb +1 -1
- data/test/drawing/tc_axis.rb +8 -0
- data/test/drawing/tc_bar_3D_chart.rb +12 -12
- data/test/drawing/tc_bar_series.rb +0 -1
- data/test/drawing/tc_chart.rb +1 -5
- data/test/drawing/tc_pie_3D_chart.rb +3 -7
- data/test/drawing/tc_view_3D.rb +18 -18
- data/test/tc_package.rb +2 -0
- data/test/workbook/worksheet/tc_page_setup.rb +20 -3
- data/test/workbook/worksheet/tc_protected_range.rb +18 -0
- data/test/workbook/worksheet/tc_selection.rb +1 -1
- data/test/workbook/worksheet/tc_worksheet.rb +39 -18
- metadata +54 -103
- data/examples/axis-titles.xlsx +0 -0
- data/examples/basic_charts.xlsx +0 -0
- data/examples/chart_colors.xlsx +0 -0
- data/examples/charts.xlsx +0 -0
- data/examples/conditional_formatting/getting_barred.xlsx +0 -0
- data/examples/doc/_index.html +0 -84
- data/examples/doc/class_list.html +0 -47
- data/examples/doc/css/common.css +0 -1
- data/examples/doc/css/full_list.css +0 -55
- data/examples/doc/css/style.css +0 -322
- data/examples/doc/file_list.html +0 -46
- data/examples/doc/frames.html +0 -13
- data/examples/doc/index.html +0 -84
- data/examples/doc/js/app.js +0 -205
- data/examples/doc/js/full_list.js +0 -173
- data/examples/doc/js/jquery.js +0 -16
- data/examples/doc/method_list.html +0 -46
- data/examples/doc/top-level-namespace.html +0 -95
- data/examples/example.xlsx +0 -0
- data/examples/example_streamed.xlsx +0 -0
- data/examples/examples_saved.xlsx +0 -0
- data/examples/extractive.xlsx +0 -0
- data/examples/fish.xlsx +0 -0
- data/examples/no-use_autowidth.xlsx +0 -0
- data/examples/pareto.rb +0 -28
- data/examples/pareto.xlsx +0 -0
- data/examples/pie_chart_excel.xlsx +0 -0
- data/examples/pie_chart_saved.xlsx +0 -0
- data/examples/shared_strings_example.xlsx +0 -0
- data/examples/sheet_protection.xlsx +0 -0
- data/examples/sheet_view.xlsx +0 -0
- data/examples/two_cell_anchor_image.xlsx +0 -0
- data/examples/~$example.xlsx +0 -0
- data/lib/axlsx/drawing/ax_data_source.rb~ +0 -55
- data/lib/axlsx/drawing/data_source.rb~ +0 -51
- data/lib/axlsx/drawing/hlink_click.rb~ +0 -0
- data/lib/axlsx/drawing/hyperlink.rb~ +0 -64
- data/lib/axlsx/drawing/num_data.rb~ +0 -51
- data/lib/axlsx/drawing/num_data_source.rb~ +0 -54
- data/lib/axlsx/drawing/num_val.rb~ +0 -40
- data/lib/axlsx/drawing/picture_locking.rb~ +0 -36
- data/lib/axlsx/drawing/ref.rb~ +0 -41
- data/lib/axlsx/drawing/str_data.rb~ +0 -58
- data/lib/axlsx/drawing/str_val.rb~ +0 -35
- data/lib/axlsx/drawing/vml_drawing.rb~ +0 -6
- data/lib/axlsx/drawing/vml_shape.rb~ +0 -61
- data/lib/axlsx/util/cbf.rb +0 -333
- data/lib/axlsx/util/cfb.rb~ +0 -201
- data/lib/axlsx/util/font_tables.rb~ +0 -0
- data/lib/axlsx/util/ms_off_crypto.rb +0 -189
- data/lib/axlsx/util/ms_off_crypto.rb~ +0 -3
- data/lib/axlsx/util/ms_offcrypto.rb~ +0 -0
- data/lib/axlsx/util/parser.rb~ +0 -6
- data/lib/axlsx/util/storage.rb~ +0 -0
- data/lib/axlsx/workbook/shared_strings_table.rb~ +0 -69
- data/lib/axlsx/workbook/worksheet/cfvo.rb~ +0 -0
- data/lib/axlsx/workbook/worksheet/col.rb~ +0 -0
- data/lib/axlsx/workbook/worksheet/color_scale.rb~ +0 -46
- data/lib/axlsx/workbook/worksheet/comment.rb~ +0 -91
- data/lib/axlsx/workbook/worksheet/comments.rb~ +0 -86
- data/lib/axlsx/workbook/worksheet/data_bar.rb~ +0 -0
- data/lib/axlsx/workbook/worksheet/icon_set.rb~ +0 -95
- data/lib/axlsx/workbook/worksheet/shared_strings_table.rb~ +0 -0
- data/lib/axlsx/workbook/worksheet/table.rb~ +0 -97
- data/lib/schema/dc.xsd~ +0 -118
- data/lib/schema/dcterms.xsd~ +0 -331
- data/lib/schema/opc-coreProperties.xsd~ +0 -50
- data/test/drawing/tc_data_source.rb~ +0 -30
- data/test/drawing/tc_num_data.rb~ +0 -35
- data/test/drawing/tc_num_val.rb~ +0 -29
- data/test/drawing/tc_str_data.rb~ +0 -30
- data/test/drawing/tc_str_val.rb~ +0 -26
- data/test/drawing/tc_vml_drawing.rb~ +0 -0
- data/test/workbook/worksheet/table/tc_table.rb~ +0 -72
- data/test/workbook/worksheet/tc_cfvo.rb~ +0 -20
- data/test/workbook/worksheet/tc_col.rb~ +0 -10
- data/test/workbook/worksheet/tc_color_scale.rb~ +0 -0
- data/test/workbook/worksheet/tc_data_bar.rb~ +0 -0
- data/test/workbook/worksheet/tc_icon_set.rb~ +0 -0
File without changes
|
File without changes
|
@@ -1,46 +0,0 @@
|
|
1
|
-
module Axlsx
|
2
|
-
# Conditional Format Rule color scale object
|
3
|
-
# Describes a gradated color scale in this conditional formatting rule.
|
4
|
-
|
5
|
-
# @note The recommended way to manage these rules is via Worksheet#add_conditional_formatting
|
6
|
-
# @see Worksheet#add_conditional_formatting
|
7
|
-
# @see ConditionalFormattingRule#initialize
|
8
|
-
class ColorScale
|
9
|
-
|
10
|
-
# A simple typed list of cfvos
|
11
|
-
# @return [SimpleTypedList]
|
12
|
-
# @see cfvo
|
13
|
-
attr_reader :cfvos
|
14
|
-
|
15
|
-
# A simple types list of colors
|
16
|
-
# @return [SimpleTypedList]
|
17
|
-
# @see Color
|
18
|
-
attr_reader :colors
|
19
|
-
|
20
|
-
def initializer
|
21
|
-
initialize_cfvos
|
22
|
-
initialize_colors
|
23
|
-
yield self if block_given?
|
24
|
-
end
|
25
|
-
|
26
|
-
def add
|
27
|
-
@cfvos << Cfvo.new(:type => :min, :val => 0)
|
28
|
-
@colors << Color.new :rgb => "FF000000"
|
29
|
-
{:cfvo => @cfvos.last, :color => @colors.last}
|
30
|
-
end
|
31
|
-
|
32
|
-
protected
|
33
|
-
|
34
|
-
def initialize_cfvos
|
35
|
-
@cfvos = SimpleTypedList.new Cfvo
|
36
|
-
@cfvos.concat [Cfvo.new(:type => :min, :val => 0), Cfvo.new(:type => :max, :val => 0)]
|
37
|
-
@cfvos.lock
|
38
|
-
end
|
39
|
-
|
40
|
-
def initialize_colors
|
41
|
-
@colors = SimpleTypedList.new Color
|
42
|
-
@colors.concat [Color.new(:rgb => "FFFF0000", Color.new(:rgb => "FF0000FF")]
|
43
|
-
@colors.lock
|
44
|
-
end
|
45
|
-
|
46
|
-
end
|
@@ -1,91 +0,0 @@
|
|
1
|
-
module Axlsx
|
2
|
-
|
3
|
-
# A comment is the text data for a comment
|
4
|
-
class Comment
|
5
|
-
|
6
|
-
# The text to render
|
7
|
-
# @return [String]
|
8
|
-
attr_reader :text
|
9
|
-
|
10
|
-
# The index of the the author for this comment in the owning Comments object
|
11
|
-
# @see Comments
|
12
|
-
# @return [Integer]
|
13
|
-
attr_reader :author_index
|
14
|
-
|
15
|
-
# The owning Comments object
|
16
|
-
# @return [Comments]
|
17
|
-
attr_reader :comments
|
18
|
-
|
19
|
-
|
20
|
-
# The string based cell position reference (e.g. 'A1') that determines the positioning of this comment
|
21
|
-
attr_reader :ref
|
22
|
-
|
23
|
-
# TODO
|
24
|
-
# r (Rich Text Run)
|
25
|
-
# rPh (Phonetic Text Run)
|
26
|
-
# phoneticPr (Phonetic Properties)
|
27
|
-
|
28
|
-
def initialize(comments, options={})
|
29
|
-
raise ArgumentError, "A comment needs a parent comments object" unless comments.is_a?(Comments)
|
30
|
-
@comments = comments
|
31
|
-
options.each do |o|
|
32
|
-
self.send("#{o[0]}=", o[1]) if self.respond_to? "#{o[0]}="
|
33
|
-
end
|
34
|
-
yield self if block_given?
|
35
|
-
end
|
36
|
-
|
37
|
-
def pn
|
38
|
-
"#{COMMENT_PN % (index+1)}"
|
39
|
-
end
|
40
|
-
|
41
|
-
def vml_shape
|
42
|
-
@vml_shape ||= initialize_vml_shape
|
43
|
-
end
|
44
|
-
|
45
|
-
def initialize_vml_shape
|
46
|
-
ws = self.comments.worksheet
|
47
|
-
@vml_shape = VmlShape.new(self, :row => ws[ref].row.index, :column => ws[ref].index) do |vml|
|
48
|
-
vml.left_column = vml.row + 1
|
49
|
-
vml.right_column = vml.column + 4
|
50
|
-
vml.top_row = vml.row
|
51
|
-
vml.bottom_row = vml.row + 4
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
# The index of this comment
|
56
|
-
# @return [Integer]
|
57
|
-
def index
|
58
|
-
@comments.comment_list.index(self)
|
59
|
-
end
|
60
|
-
|
61
|
-
def ref=(v)
|
62
|
-
Axlsx::DataTypeValidator.validate "Comment.ref", [String, Cell], v
|
63
|
-
@ref = v if v.is_a?(String)
|
64
|
-
@ref = v.r if v.is_a?(Cell)
|
65
|
-
end
|
66
|
-
|
67
|
-
def text=(v)
|
68
|
-
Axlsx::validate_string(v)
|
69
|
-
@text = v
|
70
|
-
end
|
71
|
-
|
72
|
-
def author_index=(v)
|
73
|
-
Axlsx::validate_unsigned_int(v)
|
74
|
-
@author_index = v
|
75
|
-
end
|
76
|
-
|
77
|
-
def to_xml_string(str = "")
|
78
|
-
author = @comments.authors[author_index]
|
79
|
-
str << '<comment ref="' << ref << '" authorId="' << author_index.to_s << '">'
|
80
|
-
str << '<text><r>'
|
81
|
-
str << '<rPr> <b/><color indexed="81"/></rPr>'
|
82
|
-
str << '<t>' << author.to_s << ':
|
83
|
-
</t></r>'
|
84
|
-
str << '<r>'
|
85
|
-
str << '<rPr><color indexed="81"/></rPr>'
|
86
|
-
str << '<t>' << text << '</t></r></text>'
|
87
|
-
str << '</comment>'
|
88
|
-
end
|
89
|
-
|
90
|
-
end
|
91
|
-
end
|
@@ -1,86 +0,0 @@
|
|
1
|
-
module Axlsx
|
2
|
-
|
3
|
-
class Comments
|
4
|
-
|
5
|
-
# a collection of the comment authors
|
6
|
-
# @return [SimpleTypedList]
|
7
|
-
attr_reader :authors
|
8
|
-
|
9
|
-
# a collection of comment objects
|
10
|
-
# @return [SimpleTypedList]
|
11
|
-
attr_reader :comment_list
|
12
|
-
|
13
|
-
|
14
|
-
# The worksheet that these comments belong to
|
15
|
-
# @return [Worksheet]
|
16
|
-
attr_reader :worksheet
|
17
|
-
|
18
|
-
# Creates a new Comments object
|
19
|
-
def initialize(worksheet)
|
20
|
-
raise ArgumentError, "you must provide a worksheet" unless worksheet.is_a?(Worksheet)
|
21
|
-
@worksheet = worksheet
|
22
|
-
@authors = SimpleTypedList.new String
|
23
|
-
@comment_list = SimpleTypedList.new Comment
|
24
|
-
end
|
25
|
-
|
26
|
-
def add_comment(options={})
|
27
|
-
raise ArgumentError, "Comment require an author" unless options[:author]
|
28
|
-
raise ArgumentError, "Comment requires text" unless options[:text]
|
29
|
-
options[:author_index] = @authors.index(options[:author]) || @authors << options[:author]
|
30
|
-
@comment_list << Comment.new(self, options)
|
31
|
-
@comment_list.last
|
32
|
-
end
|
33
|
-
|
34
|
-
def to_xml_string(str="")
|
35
|
-
end
|
36
|
-
|
37
|
-
end
|
38
|
-
|
39
|
-
class Comment
|
40
|
-
|
41
|
-
attr_reader :text
|
42
|
-
|
43
|
-
attr_reader :author_index
|
44
|
-
|
45
|
-
attr_reader :comments
|
46
|
-
|
47
|
-
# TODO
|
48
|
-
# r (Rich Text Run)
|
49
|
-
# rPh (Phonetic Text Run)
|
50
|
-
# phoneticPr (Phonetic Properties)
|
51
|
-
def initialize(comments, options={})
|
52
|
-
raise ArgumentError, "A comment needs a parent comments object" unless comments.is_a?(Comments)
|
53
|
-
@comments = comments
|
54
|
-
options.each do |o|
|
55
|
-
self.send("#{o[0]}=", o[1]) if self.respond_to? "#{o[0]}="
|
56
|
-
end
|
57
|
-
yield self if block_given?
|
58
|
-
end
|
59
|
-
|
60
|
-
def pn
|
61
|
-
"#{COMMENT_PN % (index+1)}"
|
62
|
-
end
|
63
|
-
|
64
|
-
# The index of this comment
|
65
|
-
# @return [Integer]
|
66
|
-
def index
|
67
|
-
@comments.comment_list.index(self)
|
68
|
-
end
|
69
|
-
|
70
|
-
|
71
|
-
def text=(v)
|
72
|
-
Axlsx::validate_string(v)
|
73
|
-
@text = v
|
74
|
-
end
|
75
|
-
|
76
|
-
def author_index=(v)
|
77
|
-
Axlsx::validate_unsigned_int(v)
|
78
|
-
@author_index = v
|
79
|
-
end
|
80
|
-
|
81
|
-
def to_xml_string(str = "")
|
82
|
-
end
|
83
|
-
|
84
|
-
end
|
85
|
-
|
86
|
-
end
|
File without changes
|
@@ -1,95 +0,0 @@
|
|
1
|
-
module Axlsx
|
2
|
-
# Conditional Format Rule data bar object
|
3
|
-
# Describes a data bar conditional formatting rule.
|
4
|
-
|
5
|
-
# @note The recommended way to manage these rules is via Worksheet#add_conditional_formatting
|
6
|
-
# @see Worksheet#add_conditional_formatting
|
7
|
-
# @see ConditionalFormattingRule#initialize
|
8
|
-
class DataBar
|
9
|
-
CHILD_ELEMENTS = [:value_objects]
|
10
|
-
|
11
|
-
# minLength attribute
|
12
|
-
# The minimum length of the data bar, as a percentage of the cell width.
|
13
|
-
# The default value is 10
|
14
|
-
# @return [Integer]
|
15
|
-
attr_reader :minLength
|
16
|
-
|
17
|
-
# maxLength attribute
|
18
|
-
# The maximum length of the data bar, as a percentage of the cell width.
|
19
|
-
# The default value is 90
|
20
|
-
# @return [Integer]
|
21
|
-
attr_reader :maxLength
|
22
|
-
|
23
|
-
# maxLength attribute
|
24
|
-
# Indicates whether to show the values of the cells on which this data bar is applied.
|
25
|
-
# The default value is true
|
26
|
-
# @return [Boolean]
|
27
|
-
attr_reader :showValue
|
28
|
-
|
29
|
-
# A simple typed list of cfvos
|
30
|
-
# @return [SimpleTypedList]
|
31
|
-
# @see Cfvo
|
32
|
-
attr_reader :value_objects
|
33
|
-
|
34
|
-
# color
|
35
|
-
# the color object used in the data bar formatting
|
36
|
-
# @return [Color]
|
37
|
-
def color
|
38
|
-
@color ||= Color.new :rgb => "FF0000FF"
|
39
|
-
end
|
40
|
-
|
41
|
-
# Creates a new data bar conditional formatting object
|
42
|
-
# @option options [Integer] minLength
|
43
|
-
# @option options [Integer] maxLength
|
44
|
-
# @option options [Boolean] showValue
|
45
|
-
# @option options [String] color - the rbg value used to color the bars
|
46
|
-
def initialize(options = {})
|
47
|
-
@minLength = 10
|
48
|
-
@maxLength = 90
|
49
|
-
@showValue = true
|
50
|
-
initialize_value_objects
|
51
|
-
options.each do |o|
|
52
|
-
self.send("#{o[0]}=", o[1]) if self.respond_to? "#{o[0]}="
|
53
|
-
end
|
54
|
-
yield self if block_given?
|
55
|
-
end
|
56
|
-
|
57
|
-
# @see minLength
|
58
|
-
def minLength=(v); Axlsx.validate_unsigned_int(v); @minLength = v end
|
59
|
-
# @see maxLength
|
60
|
-
def maxLength=(v); Axlsx.validate_unsigned_int(v); @maxLength = v end
|
61
|
-
|
62
|
-
# @see showValue
|
63
|
-
def showValue=(v); Axlsx.validate_boolean(v); @showValue = v end
|
64
|
-
|
65
|
-
# Sets the color for the data bars.
|
66
|
-
# @param [Color|String] The color object, or rgb string value to apply
|
67
|
-
def color=(v)
|
68
|
-
@color = v if v.is_a? Color
|
69
|
-
self.color.rgb = v if v.is_a? String
|
70
|
-
@color
|
71
|
-
end
|
72
|
-
|
73
|
-
# Serialize this object to an xml string
|
74
|
-
# @param [String] str
|
75
|
-
# @return [String]
|
76
|
-
def to_xml_string(str="")
|
77
|
-
str << '<dataBar '
|
78
|
-
str << instance_values.map { |key, value| '' << key << '="' << value.to_s << '"' unless CHILD_ELEMENTS.include?(key.to_sym) }.join(' ')
|
79
|
-
str << '>'
|
80
|
-
@value_objects.each { |cfvo| cfvo.to_xml_string(str) }
|
81
|
-
self.color.to_xml_string(str)
|
82
|
-
str << '</dataBar>'
|
83
|
-
end
|
84
|
-
|
85
|
-
private
|
86
|
-
|
87
|
-
# Initalize the simple typed list of value objects
|
88
|
-
# I am keeping this private for now as I am not sure what impact changes to the required two cfvo objects will do.
|
89
|
-
def initialize_value_objects
|
90
|
-
@value_objects = SimpleTypedList.new Cfvo
|
91
|
-
@value_objects.concat [Cfvo.new(:type => :min, :val => 0), Cfvo.new(:type => :max, :val => 0)]
|
92
|
-
@value_objects.lock
|
93
|
-
end
|
94
|
-
end
|
95
|
-
end
|
File without changes
|
@@ -1,97 +0,0 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
module Axlsx
|
3
|
-
# Table
|
4
|
-
# @note Worksheet#add_table is the recommended way to create charts for your worksheets.
|
5
|
-
# @see README for examples
|
6
|
-
class Table
|
7
|
-
|
8
|
-
|
9
|
-
# The reference to the table data
|
10
|
-
# @return [String]
|
11
|
-
attr_reader :ref
|
12
|
-
|
13
|
-
# The name of the table.
|
14
|
-
# @return [String]
|
15
|
-
attr_reader :name
|
16
|
-
|
17
|
-
# The style for the table.
|
18
|
-
# @return [TableStyle]
|
19
|
-
attr_reader :style
|
20
|
-
|
21
|
-
# Creates a new Table object
|
22
|
-
# @param [String] ref The reference to the table data.
|
23
|
-
# @param [Sheet] ref The sheet containing the table data.
|
24
|
-
# @option options [Cell, String] name
|
25
|
-
# @option options [TableStyle] style
|
26
|
-
def initialize(ref, sheet, options={})
|
27
|
-
@ref = ref
|
28
|
-
@sheet = sheet
|
29
|
-
@style = nil
|
30
|
-
@sheet.workbook.tables << self
|
31
|
-
@name = "Table#{index+1}"
|
32
|
-
options.each do |o|
|
33
|
-
self.send("#{o[0]}=", o[1]) if self.respond_to? "#{o[0]}="
|
34
|
-
end
|
35
|
-
yield self if block_given?
|
36
|
-
end
|
37
|
-
|
38
|
-
# The index of this chart in the workbooks charts collection
|
39
|
-
# @return [Integer]
|
40
|
-
def index
|
41
|
-
@sheet.workbook.tables.index(self)
|
42
|
-
end
|
43
|
-
|
44
|
-
# The part name for this table
|
45
|
-
# @return [String]
|
46
|
-
def pn
|
47
|
-
"#{TABLE_PN % (index+1)}"
|
48
|
-
end
|
49
|
-
|
50
|
-
# The relation reference id for this table
|
51
|
-
# @return [String]
|
52
|
-
def rId
|
53
|
-
"rId#{index+1}"
|
54
|
-
end
|
55
|
-
|
56
|
-
# The name of the Table.
|
57
|
-
# @param [String, Cell] v
|
58
|
-
# @return [Title]
|
59
|
-
def name=(v)
|
60
|
-
DataTypeValidator.validate "#{self.class}.name", [String], v
|
61
|
-
if v.is_a?(String)
|
62
|
-
@name = v
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
|
67
|
-
# The style for the table.
|
68
|
-
# TODO
|
69
|
-
# def style=(v) DataTypeValidator.validate "Chart.style", Integer, v, lambda { |arg| arg >= 1 && arg <= 48 }; @style = v; end
|
70
|
-
|
71
|
-
# Table Serialization
|
72
|
-
# serializes the table
|
73
|
-
def to_xml
|
74
|
-
builder = Nokogiri::XML::Builder.new(:encoding => ENCODING) do |xml|
|
75
|
-
xml.table(:xmlns => XML_NS, :id => index+1, :name => @name, :displayName => @name.gsub(/\s/,'_'), :ref => @ref, :totalsRowShown => 0) {
|
76
|
-
xml.autoFilter :ref=>@ref
|
77
|
-
xml.tableColumns(:count => header_cells.length) {
|
78
|
-
header_cells.each_with_index do |cell,index|
|
79
|
-
xml.tableColumn :id => index+1, :name => cell.value
|
80
|
-
end
|
81
|
-
}
|
82
|
-
xml.tableStyleInfo :showFirstColumn=>"0", :showLastColumn=>"0", :showRowStripes=>"1", :showColumnStripes=>"0", :name=>"TableStyleMedium9"
|
83
|
-
#TODO implement tableStyleInfo
|
84
|
-
}
|
85
|
-
end
|
86
|
-
builder.to_xml(:save_with => 0)
|
87
|
-
end
|
88
|
-
|
89
|
-
private
|
90
|
-
|
91
|
-
# get the header cells (hackish)
|
92
|
-
def header_cells
|
93
|
-
header = @ref.gsub(/^(\w+)(\d+)\:(\w+)\d+$/, '\1\2:\3\2')
|
94
|
-
@sheet[header]
|
95
|
-
end
|
96
|
-
end
|
97
|
-
end
|
data/lib/schema/dc.xsd~
DELETED
@@ -1,118 +0,0 @@
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
-
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
|
3
|
-
xmlns="http://purl.org/dc/elements/1.1/"
|
4
|
-
targetNamespace="http://purl.org/dc/elements/1.1/"
|
5
|
-
elementFormDefault="qualified"
|
6
|
-
attributeFormDefault="unqualified">
|
7
|
-
|
8
|
-
<xs:annotation>
|
9
|
-
<xs:documentation xml:lang="en">
|
10
|
-
DCMES 1.1 XML Schema
|
11
|
-
XML Schema for http://purl.org/dc/elements/1.1/ namespace
|
12
|
-
|
13
|
-
Created 2003-04-02
|
14
|
-
|
15
|
-
Created by
|
16
|
-
|
17
|
-
Tim Cole (t-cole3@uiuc.edu)
|
18
|
-
Tom Habing (thabing@uiuc.edu)
|
19
|
-
Jane Hunter (jane@dstc.edu.au)
|
20
|
-
Pete Johnston (p.johnston@ukoln.ac.uk),
|
21
|
-
Carl Lagoze (lagoze@cs.cornell.edu)
|
22
|
-
|
23
|
-
This schema declares XML elements for the 15 DC elements from the
|
24
|
-
http://purl.org/dc/elements/1.1/ namespace.
|
25
|
-
|
26
|
-
It defines a complexType SimpleLiteral which permits mixed content
|
27
|
-
and makes the xml:lang attribute available. It disallows child elements by
|
28
|
-
use of minOcccurs/maxOccurs.
|
29
|
-
|
30
|
-
However, this complexType does permit the derivation of other complexTypes
|
31
|
-
which would permit child elements.
|
32
|
-
|
33
|
-
All elements are declared as substitutable for the abstract element any,
|
34
|
-
which means that the default type for all elements is dc:SimpleLiteral.
|
35
|
-
|
36
|
-
</xs:documentation>
|
37
|
-
|
38
|
-
</xs:annotation>
|
39
|
-
|
40
|
-
|
41
|
-
<xs:import namespace="http://www.w3.org/XML/1998/namespace"
|
42
|
-
schemaLocation="http://www.w3.org/2001/03/xml.xsd">
|
43
|
-
</xs:import>
|
44
|
-
|
45
|
-
<xs:complexType name="SimpleLiteral">
|
46
|
-
<xs:annotation>
|
47
|
-
<xs:documentation xml:lang="en">
|
48
|
-
This is the default type for all of the DC elements.
|
49
|
-
It permits text content only with optional
|
50
|
-
xml:lang attribute.
|
51
|
-
Text is allowed because mixed="true", but sub-elements
|
52
|
-
are disallowed because minOccurs="0" and maxOccurs="0"
|
53
|
-
are on the xs:any tag.
|
54
|
-
|
55
|
-
This complexType allows for restriction or extension permitting
|
56
|
-
child elements.
|
57
|
-
</xs:documentation>
|
58
|
-
</xs:annotation>
|
59
|
-
|
60
|
-
<xs:complexContent mixed="true">
|
61
|
-
<xs:restriction base="xs:anyType">
|
62
|
-
<xs:sequence>
|
63
|
-
<xs:any processContents="lax" minOccurs="0" maxOccurs="0"/>
|
64
|
-
</xs:sequence>
|
65
|
-
<xs:attribute ref="xml:lang" use="optional"/>
|
66
|
-
</xs:restriction>
|
67
|
-
</xs:complexContent>
|
68
|
-
</xs:complexType>
|
69
|
-
|
70
|
-
<xs:element name="any" type="SimpleLiteral" abstract="true"/>
|
71
|
-
|
72
|
-
<xs:element name="title" substitutionGroup="any"/>
|
73
|
-
<xs:element name="creator" substitutionGroup="any"/>
|
74
|
-
<xs:element name="subject" substitutionGroup="any"/>
|
75
|
-
<xs:element name="description" substitutionGroup="any"/>
|
76
|
-
<xs:element name="publisher" substitutionGroup="any"/>
|
77
|
-
<xs:element name="contributor" substitutionGroup="any"/>
|
78
|
-
<xs:element name="date" substitutionGroup="any"/>
|
79
|
-
<xs:element name="type" substitutionGroup="any"/>
|
80
|
-
<xs:element name="format" substitutionGroup="any"/>
|
81
|
-
<xs:element name="identifier" substitutionGroup="any"/>
|
82
|
-
<xs:element name="source" substitutionGroup="any"/>
|
83
|
-
<xs:element name="language" substitutionGroup="any"/>
|
84
|
-
<xs:element name="relation" substitutionGroup="any"/>
|
85
|
-
<xs:element name="coverage" substitutionGroup="any"/>
|
86
|
-
<xs:element name="rights" substitutionGroup="any"/>
|
87
|
-
|
88
|
-
<xs:group name="elementsGroup">
|
89
|
-
<xs:annotation>
|
90
|
-
<xs:documentation xml:lang="en">
|
91
|
-
This group is included as a convenience for schema authors
|
92
|
-
who need to refer to all the elements in the
|
93
|
-
http://purl.org/dc/elements/1.1/ namespace.
|
94
|
-
</xs:documentation>
|
95
|
-
</xs:annotation>
|
96
|
-
|
97
|
-
<xs:sequence>
|
98
|
-
<xs:choice minOccurs="0" maxOccurs="unbounded">
|
99
|
-
<xs:element ref="any"/>
|
100
|
-
</xs:choice>
|
101
|
-
</xs:sequence>
|
102
|
-
</xs:group>
|
103
|
-
|
104
|
-
<xs:complexType name="elementContainer">
|
105
|
-
<xs:annotation>
|
106
|
-
<xs:documentation xml:lang="en">
|
107
|
-
This complexType is included as a convenience for schema authors who need to define a root
|
108
|
-
or container element for all of the DC elements.
|
109
|
-
</xs:documentation>
|
110
|
-
</xs:annotation>
|
111
|
-
|
112
|
-
<xs:choice>
|
113
|
-
<xs:group ref="elementsGroup"/>
|
114
|
-
</xs:choice>
|
115
|
-
</xs:complexType>
|
116
|
-
|
117
|
-
|
118
|
-
</xs:schema>
|