axlsx 1.0.16 → 1.0.18

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.
Files changed (91) hide show
  1. data/.yardopts +1 -0
  2. data/CHANGELOG.md +7 -0
  3. data/README.md +105 -46
  4. data/examples/example.rb +172 -142
  5. data/lib/axlsx/content_type/content_type.rb +4 -3
  6. data/lib/axlsx/content_type/default.rb +1 -0
  7. data/lib/axlsx/content_type/override.rb +1 -0
  8. data/lib/axlsx/doc_props/app.rb +1 -1
  9. data/lib/axlsx/doc_props/core.rb +1 -0
  10. data/lib/axlsx/drawing/axis.rb +1 -0
  11. data/lib/axlsx/drawing/bar_3D_chart.rb +1 -0
  12. data/lib/axlsx/drawing/bar_series.rb +1 -0
  13. data/lib/axlsx/drawing/cat_axis.rb +1 -0
  14. data/lib/axlsx/drawing/cat_axis_data.rb +1 -0
  15. data/lib/axlsx/drawing/chart.rb +4 -4
  16. data/lib/axlsx/drawing/drawing.rb +1 -0
  17. data/lib/axlsx/drawing/graphic_frame.rb +1 -0
  18. data/lib/axlsx/drawing/hyperlink.rb +1 -1
  19. data/lib/axlsx/drawing/line_3D_chart.rb +1 -0
  20. data/lib/axlsx/drawing/line_series.rb +1 -0
  21. data/lib/axlsx/drawing/marker.rb +1 -0
  22. data/lib/axlsx/drawing/one_cell_anchor.rb +1 -0
  23. data/lib/axlsx/drawing/pic.rb +2 -1
  24. data/lib/axlsx/drawing/picture_locking.rb +1 -0
  25. data/lib/axlsx/drawing/pie_3D_chart.rb +1 -0
  26. data/lib/axlsx/drawing/pie_series.rb +1 -0
  27. data/lib/axlsx/drawing/scaling.rb +1 -0
  28. data/lib/axlsx/drawing/ser_axis.rb +1 -0
  29. data/lib/axlsx/drawing/series.rb +1 -0
  30. data/lib/axlsx/drawing/series_title.rb +1 -0
  31. data/lib/axlsx/drawing/title.rb +1 -0
  32. data/lib/axlsx/drawing/two_cell_anchor.rb +1 -0
  33. data/lib/axlsx/drawing/val_axis.rb +1 -0
  34. data/lib/axlsx/drawing/val_axis_data.rb +1 -0
  35. data/lib/axlsx/drawing/view_3D.rb +1 -0
  36. data/lib/axlsx/package.rb +86 -38
  37. data/lib/axlsx/rels/relationship.rb +4 -3
  38. data/lib/axlsx/rels/relationships.rb +1 -0
  39. data/lib/axlsx/stylesheet/border.rb +1 -0
  40. data/lib/axlsx/stylesheet/border_pr.rb +1 -0
  41. data/lib/axlsx/stylesheet/cell_alignment.rb +1 -0
  42. data/lib/axlsx/stylesheet/cell_protection.rb +1 -0
  43. data/lib/axlsx/stylesheet/cell_style.rb +1 -0
  44. data/lib/axlsx/stylesheet/color.rb +1 -0
  45. data/lib/axlsx/stylesheet/fill.rb +1 -0
  46. data/lib/axlsx/stylesheet/font.rb +8 -0
  47. data/lib/axlsx/stylesheet/gradient_fill.rb +1 -1
  48. data/lib/axlsx/stylesheet/gradient_stop.rb +1 -1
  49. data/lib/axlsx/stylesheet/num_fmt.rb +1 -0
  50. data/lib/axlsx/stylesheet/pattern_fill.rb +1 -0
  51. data/lib/axlsx/stylesheet/styles.rb +12 -9
  52. data/lib/axlsx/stylesheet/table_style.rb +1 -0
  53. data/lib/axlsx/stylesheet/table_style_element.rb +1 -0
  54. data/lib/axlsx/stylesheet/table_styles.rb +1 -0
  55. data/lib/axlsx/stylesheet/xf.rb +1 -0
  56. data/lib/axlsx/util/cbf.rb +1 -0
  57. data/lib/axlsx/util/constants.rb +23 -14
  58. data/lib/axlsx/util/ms_off_crypto.rb +1 -1
  59. data/lib/axlsx/util/parser.rb +1 -0
  60. data/lib/axlsx/util/simple_typed_list.rb +2 -1
  61. data/lib/axlsx/util/storage.rb +1 -0
  62. data/lib/axlsx/util/validators.rb +11 -2
  63. data/lib/axlsx/version.rb +2 -1
  64. data/lib/axlsx/workbook/shared_strings_table.rb +71 -0
  65. data/lib/axlsx/workbook/shared_strings_table.rb~ +69 -0
  66. data/lib/axlsx/workbook/workbook.rb +47 -25
  67. data/lib/axlsx/workbook/worksheet/cell.rb +131 -78
  68. data/lib/axlsx/workbook/worksheet/date_time_converter.rb +29 -0
  69. data/lib/axlsx/workbook/worksheet/page_margins.rb +94 -0
  70. data/lib/axlsx/workbook/worksheet/row.rb +44 -12
  71. data/lib/axlsx/workbook/worksheet/shared_strings_table.rb~ +0 -0
  72. data/lib/axlsx/workbook/worksheet/worksheet.rb +158 -44
  73. data/lib/axlsx.rb +16 -10
  74. data/test/content_type/tc_content_type.rb +2 -0
  75. data/test/content_type/tc_default.rb +2 -0
  76. data/test/content_type/tc_override.rb +1 -0
  77. data/test/drawing/tc_chart.rb +2 -2
  78. data/test/stylesheet/tc_cell_alignment.rb +8 -3
  79. data/test/stylesheet/tc_font.rb +8 -0
  80. data/test/stylesheet/tc_styles.rb +6 -2
  81. data/test/tc_package.rb +31 -0
  82. data/test/workbook/tc_shared_strings_table.rb +39 -0
  83. data/test/workbook/tc_shared_strings_table.rb~ +8 -0
  84. data/test/workbook/tc_workbook.rb +8 -0
  85. data/test/workbook/worksheet/tc_cell.rb +52 -9
  86. data/test/workbook/worksheet/tc_date_time_converter.rb +127 -0
  87. data/test/workbook/worksheet/tc_date_time_converter.rb~ +69 -0
  88. data/test/workbook/worksheet/tc_page_margins.rb +100 -0
  89. data/test/workbook/worksheet/tc_row.rb +36 -0
  90. data/test/workbook/worksheet/tc_worksheet.rb +97 -3
  91. metadata +33 -40
data/examples/example.rb CHANGED
@@ -1,196 +1,226 @@
1
- #!/usr/bin/env ruby
1
+ #!/usr/bin/env ruby -w -s
2
2
  # -*- coding: utf-8 -*-
3
- require 'axlsx'
3
+ require 'axlsx.rb'
4
4
 
5
- p = Axlsx::Package.new
6
- wb = p.workbook
5
+ p = Axlsx::Package.new
6
+ wb = p.workbook
7
7
 
8
8
  #A Simple Workbook
9
9
 
10
- wb.add_worksheet(:name => "Basic Worksheet") do |sheet|
11
- sheet.add_row ["First Column", "Second", "Third"]
12
- sheet.add_row [1, 2, 3]
13
- end
10
+ wb.add_worksheet(:name => "Basic Worksheet") do |sheet|
11
+ sheet.add_row ["First Column", "Second", "Third"]
12
+ sheet.add_row [1, 2, 3]
13
+ end
14
14
 
15
15
  #Using Custom Styles
16
16
 
17
- wb.styles do |s|
18
- black_cell = s.add_style :bg_color => "00", :fg_color => "FF", :sz => 14, :alignment => { :horizontal=> :center }
19
- blue_cell = s.add_style :bg_color => "0000FF", :fg_color => "FF", :sz => 20, :alignment => { :horizontal=> :center }
20
- wb.add_worksheet(:name => "Custom Styles") do |sheet|
21
- sheet.add_row ["Text Autowidth", "Second", "Third"], :style => [black_cell, blue_cell, black_cell]
22
- sheet.add_row [1, 2, 3], :style => Axlsx::STYLE_THIN_BORDER
23
- end
24
- end
17
+ wb.styles do |s|
18
+ black_cell = s.add_style :bg_color => "00", :fg_color => "FF", :sz => 14, :alignment => { :horizontal=> :center }
19
+ blue_cell = s.add_style :bg_color => "0000FF", :fg_color => "FF", :sz => 20, :alignment => { :horizontal=> :center }
20
+ wb.add_worksheet(:name => "Custom Styles") do |sheet|
21
+ sheet.add_row ["Text Autowidth", "Second", "Third"], :style => [black_cell, blue_cell, black_cell]
22
+ sheet.add_row [1, 2, 3], :style => Axlsx::STYLE_THIN_BORDER
23
+ end
24
+ end
25
25
 
26
26
  ##Using Custom Formatting and date1904
27
- require 'date'
28
- wb.styles do |s|
29
- date = s.add_style(:format_code => "yyyy-mm-dd", :border => Axlsx::STYLE_THIN_BORDER)
30
- padded = s.add_style(:format_code => "00#", :border => Axlsx::STYLE_THIN_BORDER)
31
- percent = s.add_style(:format_code => "0000%", :border => Axlsx::STYLE_THIN_BORDER)
32
- wb.date1904 = true # required for generation on mac
33
- wb.add_worksheet(:name => "Formatting Data") do |sheet|
34
- sheet.add_row ["Custom Formatted Date", "Percent Formatted Float", "Padded Numbers"], :style => Axlsx::STYLE_THIN_BORDER
35
- sheet.add_row [Date::strptime('2012-01-19','%Y-%m-%d'), 0.2, 32], :style => [date, percent, padded]
36
- end
37
- end
27
+ require 'date'
28
+ wb.styles do |s|
29
+ date = s.add_style(:format_code => "yyyy-mm-dd", :border => Axlsx::STYLE_THIN_BORDER)
30
+ padded = s.add_style(:format_code => "00#", :border => Axlsx::STYLE_THIN_BORDER)
31
+ percent = s.add_style(:format_code => "0000%", :border => Axlsx::STYLE_THIN_BORDER)
32
+ # wb.date1904 = true # Use the 1904 date system (Used by Excel for Mac < 2011)
33
+ wb.add_worksheet(:name => "Formatting Data") do |sheet|
34
+ sheet.add_row ["Custom Formatted Date", "Percent Formatted Float", "Padded Numbers"], :style => Axlsx::STYLE_THIN_BORDER
35
+ sheet.add_row [Date::strptime('2012-01-19','%Y-%m-%d'), 0.2, 32], :style => [date, percent, padded]
36
+ end
37
+ end
38
38
 
39
39
  ##Add an Image
40
40
 
41
- wb.add_worksheet(:name => "Images") do |sheet|
42
- img = File.expand_path('examples/image1.jpeg')
43
- sheet.add_image(:image_src => img, :noSelect => true, :noMove => true) do |image|
44
- image.width=720
45
- image.height=666
46
- image.start_at 2, 2
47
- end
48
- end
41
+ wb.add_worksheet(:name => "Images") do |sheet|
42
+ img = File.expand_path('examples/image1.jpeg')
43
+ sheet.add_image(:image_src => img, :noSelect => true, :noMove => true) do |image|
44
+ image.width=720
45
+ image.height=666
46
+ image.start_at 2, 2
47
+ end
48
+ end
49
49
 
50
50
  ##Add an Image with a hyperlink
51
51
 
52
- wb.add_worksheet(:name => "Image with Hyperlink") do |sheet|
53
- img = File.expand_path('examples/image1.jpeg')
54
- sheet.add_image(:image_src => img, :noSelect => true, :noMove => true, :hyperlink=>"http://axlsx.blogspot.com") do |image|
55
- image.width=720
56
- image.height=666
57
- image.hyperlink.tooltip = "Labeled Link"
58
- image.start_at 2, 2
59
- end
60
- end
52
+ wb.add_worksheet(:name => "Image with Hyperlink") do |sheet|
53
+ img = File.expand_path('examples/image1.jpeg')
54
+ sheet.add_image(:image_src => img, :noSelect => true, :noMove => true, :hyperlink=>"http://axlsx.blogspot.com") do |image|
55
+ image.width=720
56
+ image.height=666
57
+ image.hyperlink.tooltip = "Labeled Link"
58
+ image.start_at 2, 2
59
+ end
60
+ end
61
61
 
62
62
  ##Asian Language Support
63
63
 
64
- wb.add_worksheet(:name => "Unicode Support") do |sheet|
65
- sheet.add_row ["日本語"]
66
- sheet.add_row ["华语/華語"]
67
- sheet.add_row ["한국어/조선말"]
68
- end
64
+ wb.add_worksheet(:name => "日本語でのシート名") do |sheet|
65
+ sheet.add_row ["日本語"]
66
+ sheet.add_row ["华语/華語"]
67
+ sheet.add_row ["한국어/조선말"]
68
+ end
69
69
 
70
70
  ##Styling Columns
71
71
 
72
- wb.styles do |s|
73
- percent = s.add_style :num_fmt => 9
74
- wb.add_worksheet(:name => "Styling Columns") do |sheet|
75
- sheet.add_row ['col 1', 'col 2', 'col 3', 'col 4']
76
- sheet.add_row [1, 2, 0.3, 4]
77
- sheet.add_row [1, 2, 0.2, 4]
78
- sheet.add_row [1, 2, 0.1, 4]
79
- sheet.col_style 2, percent, :row_offset => 1
80
- end
81
- end
72
+ wb.styles do |s|
73
+ percent = s.add_style :num_fmt => 9
74
+ wb.add_worksheet(:name => "Styling Columns") do |sheet|
75
+ sheet.add_row ['col 1', 'col 2', 'col 3', 'col 4']
76
+ sheet.add_row [1, 2, 0.3, 4]
77
+ sheet.add_row [1, 2, 0.2, 4]
78
+ sheet.add_row [1, 2, 0.1, 4]
79
+ sheet.col_style 2, percent, :row_offset => 1
80
+ end
81
+ end
82
82
 
83
83
  ##Styling Rows
84
84
 
85
- wb.styles do |s|
86
- head = s.add_style :bg_color => "00", :fg_color => "FF"
87
- percent = s.add_style :num_fmt => 9
88
- wb.add_worksheet(:name => "Styling Rows") do |sheet|
89
- sheet.add_row ['col 1', 'col 2', 'col 3', 'col 4']
90
- sheet.add_row [1, 2, 0.3, 4]
91
- sheet.add_row [1, 2, 0.2, 4]
92
- sheet.add_row [1, 2, 0.1, 4]
93
- sheet.col_style 2, percent, :row_offset => 1
94
- sheet.row_style 0, head
95
- end
96
- end
85
+ wb.styles do |s|
86
+ head = s.add_style :bg_color => "00", :fg_color => "FF"
87
+ percent = s.add_style :num_fmt => 9
88
+ wb.add_worksheet(:name => "Styling Rows") do |sheet|
89
+ sheet.add_row ['col 1', 'col 2', 'col 3', 'col 4']
90
+ sheet.add_row [1, 2, 0.3, 4]
91
+ sheet.add_row [1, 2, 0.2, 4]
92
+ sheet.add_row [1, 2, 0.1, 4]
93
+ sheet.col_style 2, percent, :row_offset => 1
94
+ sheet.row_style 0, head
95
+ end
96
+ end
97
97
 
98
98
  ##Styling Cell Overrides
99
99
 
100
- wb.add_worksheet(:name => "Cell Level Style Overrides") do |sheet|
101
- # cell level style overides when adding cells
102
- sheet.add_row ['col 1', 'col 2', 'col 3', 'col 4'], :sz => 16
103
- sheet.add_row [1, 2, 3, "=SUM(A2:C2)"]
104
- # cell level style overrides via sheet range
105
- sheet["A1:D1"].each { |c| c.color = "FF0000"}
106
- sheet['A1:D2'].each { |c| c.style = Axlsx::STYLE_THIN_BORDER }
107
- end
100
+ wb.add_worksheet(:name => "Cell Level Style Overrides") do |sheet|
101
+ # cell level style overides when adding cells
102
+ sheet.add_row ['col 1', 'col 2', 'col 3', 'col 4'], :sz => 16
103
+ sheet.add_row [1, 2, 3, "=SUM(A2:C2)"]
104
+ # cell level style overrides via sheet range
105
+ sheet["A1:D1"].each { |c| c.color = "FF0000"}
106
+ sheet['A1:D2'].each { |c| c.style = Axlsx::STYLE_THIN_BORDER }
107
+ end
108
108
 
109
109
  ##Using formula
110
110
 
111
- wb.add_worksheet(:name => "Using Formulas") do |sheet|
112
- sheet.add_row ['col 1', 'col 2', 'col 3', 'col 4']
113
- sheet.add_row [1, 2, 3, "=SUM(A2:C2)"]
114
- end
111
+ wb.add_worksheet(:name => "Using Formulas") do |sheet|
112
+ sheet.add_row ['col 1', 'col 2', 'col 3', 'col 4']
113
+ sheet.add_row [1, 2, 3, "=SUM(A2:C2)"]
114
+ end
115
+
116
+ ##Automatic cell types
117
+
118
+ wb.add_worksheet(:name => "Automatic cell types") do |sheet|
119
+ sheet.add_row ["Date", "Time", "String", "Boolean", "Float", "Integer"]
120
+ sheet.add_row [Date.today, Time.now, "value", true, 0.1, 1]
121
+ end
115
122
 
116
123
  ##Merging Cells.
117
124
 
118
- wb.add_worksheet(:name => 'Merging Cells') do |sheet|
119
- # cell level style overides when adding cells
120
- sheet.add_row ["col 1", "col 2", "col 3", "col 4"], :sz => 16
121
- sheet.add_row [1, 2, 3, "=SUM(A2:C2)"]
122
- sheet.add_row [2, 3, 4, "=SUM(A3:C3)"]
123
- sheet.add_row ["total", "", "", "=SUM(D2:D3)"]
124
- sheet.merge_cells("A4:C4")
125
- sheet["A1:D1"].each { |c| c.color = "FF0000"}
126
- sheet["A1:D4"].each { |c| c.style = Axlsx::STYLE_THIN_BORDER }
127
- end
125
+ wb.add_worksheet(:name => 'Merging Cells') do |sheet|
126
+ # cell level style overides when adding cells
127
+ sheet.add_row ["col 1", "col 2", "col 3", "col 4"], :sz => 16
128
+ sheet.add_row [1, 2, 3, "=SUM(A2:C2)"]
129
+ sheet.add_row [2, 3, 4, "=SUM(A3:C3)"]
130
+ sheet.add_row ["total", "", "", "=SUM(D2:D3)"]
131
+ sheet.merge_cells("A4:C4")
132
+ sheet["A1:D1"].each { |c| c.color = "FF0000"}
133
+ sheet["A1:D4"].each { |c| c.style = Axlsx::STYLE_THIN_BORDER }
134
+ end
128
135
 
129
136
  ##Generating A Bar Chart
130
137
 
131
- wb.add_worksheet(:name => "Bar Chart") do |sheet|
132
- sheet.add_row ["A Simple Bar Chart"]
133
- sheet.add_row ["First", "Second", "Third"]
134
- sheet.add_row [1, 2, 3]
135
- sheet.add_chart(Axlsx::Bar3DChart, :start_at => "A4", :end_at => "F17") do |chart|
136
- chart.add_series :data => sheet["A3:C3"], :labels => sheet["A2:C2"], :title => sheet["A1"]
137
- end
138
- end
138
+ wb.add_worksheet(:name => "Bar Chart") do |sheet|
139
+ sheet.add_row ["A Simple Bar Chart"]
140
+ sheet.add_row ["First", "Second", "Third"]
141
+ sheet.add_row [1, 2, 3]
142
+ sheet.add_chart(Axlsx::Bar3DChart, :start_at => "A4", :end_at => "F17") do |chart|
143
+ chart.add_series :data => sheet["A3:C3"], :labels => sheet["A2:C2"], :title => sheet["A1"]
144
+ end
145
+ end
139
146
 
140
147
  ##Generating A Pie Chart
141
148
 
142
- wb.add_worksheet(:name => "Pie Chart") do |sheet|
143
- sheet.add_row ["First", "Second", "Third", "Fourth"]
144
- sheet.add_row [1, 2, 3, "=PRODUCT(A2:C2)"]
145
- sheet.add_chart(Axlsx::Pie3DChart, :start_at => [0,2], :end_at => [5, 15], :title => "example 3: Pie Chart") do |chart|
146
- chart.add_series :data => sheet["A2:D2"], :labels => sheet["A1:D1"]
147
- end
148
- end
149
+ wb.add_worksheet(:name => "Pie Chart") do |sheet|
150
+ sheet.add_row ["First", "Second", "Third", "Fourth"]
151
+ sheet.add_row [1, 2, 3, "=PRODUCT(A2:C2)"]
152
+ sheet.add_chart(Axlsx::Pie3DChart, :start_at => [0,2], :end_at => [5, 15], :title => "example 3: Pie Chart") do |chart|
153
+ chart.add_series :data => sheet["A2:D2"], :labels => sheet["A1:D1"]
154
+ end
155
+ end
149
156
 
150
157
  ##Data over time
151
158
 
152
- wb.add_worksheet(:name=>'Charting Dates') do |sheet|
153
- # cell level style overides when adding cells
154
- sheet.add_row ['Date', 'Value'], :sz => 16
155
- sheet.add_row [Time.now - (7*60*60*24), 3]
156
- sheet.add_row [Time.now - (6*60*60*24), 7]
157
- sheet.add_row [Time.now - (5*60*60*24), 18]
158
- sheet.add_row [Time.now - (4*60*60*24), 1]
159
- sheet.add_chart(Axlsx::Bar3DChart) do |chart|
160
- chart.start_at "B7"
161
- chart.end_at "H27"
162
- chart.add_series(:data => sheet["B2:B5"], :labels => sheet["A2:A5"], :title => sheet["B1"])
163
- end
164
- end
159
+ wb.add_worksheet(:name=>'Charting Dates') do |sheet|
160
+ # cell level style overides when adding cells
161
+ sheet.add_row ['Date', 'Value'], :sz => 16
162
+ sheet.add_row [Time.now - (7*60*60*24), 3]
163
+ sheet.add_row [Time.now - (6*60*60*24), 7]
164
+ sheet.add_row [Time.now - (5*60*60*24), 18]
165
+ sheet.add_row [Time.now - (4*60*60*24), 1]
166
+ sheet.add_chart(Axlsx::Bar3DChart) do |chart|
167
+ chart.start_at "B7"
168
+ chart.end_at "H27"
169
+ chart.add_series(:data => sheet["B2:B5"], :labels => sheet["A2:A5"], :title => sheet["B1"])
170
+ end
171
+ end
165
172
 
166
173
  ##Generating A Line Chart
167
174
 
168
- wb.add_worksheet(:name => "Line Chart") do |sheet|
169
- sheet.add_row ["First", 1, 5, 7, 9]
170
- sheet.add_row ["Second", 5, 2, 14, 9]
171
- sheet.add_chart(Axlsx::Line3DChart, :title => "example 6: Line Chart", :rotX => 30, :rotY => 20) do |chart|
172
- chart.start_at 0, 2
173
- chart.end_at 10, 15
174
- chart.add_series :data => sheet["B1:E1"], :title => sheet["A1"]
175
- chart.add_series :data => sheet["B2:E2"], :title => sheet["A2"]
176
- end
177
- end
175
+ wb.add_worksheet(:name => "Line Chart") do |sheet|
176
+ sheet.add_row ["First", 1, 5, 7, 9]
177
+ sheet.add_row ["Second", 5, 2, 14, 9]
178
+ sheet.add_chart(Axlsx::Line3DChart, :title => "example 6: Line Chart", :rotX => 30, :rotY => 20) do |chart|
179
+ chart.start_at 0, 2
180
+ chart.end_at 10, 15
181
+ chart.add_series :data => sheet["B1:E1"], :title => sheet["A1"]
182
+ chart.add_series :data => sheet["B2:E2"], :title => sheet["A2"]
183
+ end
184
+ end
178
185
 
179
186
  ##Auto Filter
180
187
 
181
- wb.add_worksheet(:name => "Auto Filter") do |sheet|
182
- sheet.add_row ["Build Matrix"]
183
- sheet.add_row ["Build", "Duration", "Finished", "Rvm"]
184
- sheet.add_row ["19.1", "1 min 32 sec", "about 10 hours ago", "1.8.7"]
185
- sheet.add_row ["19.2", "1 min 28 sec", "about 10 hours ago", "1.9.2"]
186
- sheet.add_row ["19.3", "1 min 35 sec", "about 10 hours ago", "1.9.3"]
187
- sheet.auto_filter = "A2:D5"
188
- end
188
+ wb.add_worksheet(:name => "Auto Filter") do |sheet|
189
+ sheet.add_row ["Build Matrix"]
190
+ sheet.add_row ["Build", "Duration", "Finished", "Rvm"]
191
+ sheet.add_row ["19.1", "1 min 32 sec", "about 10 hours ago", "1.8.7"]
192
+ sheet.add_row ["19.2", "1 min 28 sec", "about 10 hours ago", "1.9.2"]
193
+ sheet.add_row ["19.3", "1 min 35 sec", "about 10 hours ago", "1.9.3"]
194
+ sheet.auto_filter = "A2:D5"
195
+ end
196
+
197
+ ##Specifying Column Widths
198
+
199
+ wb.add_worksheet(:name => "custom column widths") do |sheet|
200
+ sheet.add_row ["I use autowidth and am very wide", "I use a custom width and am narrow"]
201
+ sheet.column_widths nil, 3
202
+ end
203
+
204
+ ##Specify Page Margins for printing
205
+ margins = {:left => 3, :right => 3, :top => 1.2, :bottom => 1.2, :header => 0.7, :footer => 0.7}
206
+ wb.add_worksheet(:name => "print margins", :page_margins => margins) do |sheet|
207
+ sheet.add_row ["this sheet uses customized page margins for printing"]
208
+ end
189
209
 
190
210
  ##Validate and Serialize
191
211
 
192
- p.validate.each { |e| puts e.message }
193
- p.serialize("example.xlsx")
212
+ p.validate.each { |e| puts e.message }
213
+ p.serialize("example.xlsx")
214
+
215
+ s = p.to_stream()
216
+ File.open('example_streamed.xlsx', 'w') { |f| f.write(s.read) }
217
+
218
+
219
+ ##Using Shared Strings
220
+ p.use_shared_strings = true
221
+ p.serialize("shared_strings_example.xlsx")
222
+
223
+
224
+
194
225
 
195
-
196
226
 
@@ -1,14 +1,15 @@
1
+ # encoding: UTF-8
1
2
  module Axlsx
2
3
  require 'axlsx/content_type/default.rb'
3
4
  require 'axlsx/content_type/override.rb'
4
5
 
5
- # ContentTypes used in the package. This is automatcially managed by the package package.
6
+ # ContentTypes used in the package. This is automatically managed by the package package.
6
7
  class ContentType < SimpleTypedList
7
-
8
+
8
9
  def initialize
9
10
  super [Override, Default]
10
11
  end
11
-
12
+
12
13
  # Generates the xml document for [Content_Types].xml
13
14
  # @return [String] The document as a string.
14
15
  def to_xml()
@@ -1,3 +1,4 @@
1
+ # encoding: UTF-8
1
2
  module Axlsx
2
3
  # An default content part. These parts are automatically created by for you based on the content of your package.
3
4
  class Default
@@ -1,3 +1,4 @@
1
+ # encoding: UTF-8
1
2
  module Axlsx
2
3
  # An override content part. These parts are automatically created by for you based on the content of your package.
3
4
  class Override
@@ -1,4 +1,4 @@
1
- # -*- coding: utf-8 -*-
1
+ # encoding: UTF-8
2
2
  module Axlsx
3
3
  # App represents the app.xml document. The attributes for this object are primarily managed by the application the end user uses to edit the document. None of the attributes are required to serialize a valid xlsx object.
4
4
  # @see shared-documentPropertiesExtended.xsd
@@ -1,3 +1,4 @@
1
+ # encoding: UTF-8
1
2
  module Axlsx
2
3
  # The core object for the package.
3
4
  # @note Packages manage their own core object.
@@ -1,3 +1,4 @@
1
+ # encoding: UTF-8
1
2
  module Axlsx
2
3
  # the access class defines common properties and values for a chart axis.
3
4
  class Axis
@@ -1,3 +1,4 @@
1
+ # encoding: UTF-8
1
2
  module Axlsx
2
3
 
3
4
  # The Bar3DChart is a three dimentional barchart (who would have guessed?) that you can add to your worksheet.
@@ -1,3 +1,4 @@
1
+ # encoding: UTF-8
1
2
  module Axlsx
2
3
  # A BarSeries defines the title, data and labels for bar charts
3
4
  # @note The recommended way to manage series is to use Chart#add_series
@@ -1,3 +1,4 @@
1
+ # encoding: UTF-8
1
2
  module Axlsx
2
3
  #A CatAxis object defines a chart category axis
3
4
  class CatAxis < Axis
@@ -1,3 +1,4 @@
1
+ # encoding: UTF-8
1
2
  module Axlsx
2
3
  # The CatAxisData class serializes the category axis data for a chart
3
4
  class CatAxisData < SimpleTypedList
@@ -1,4 +1,4 @@
1
- # -*- coding: utf-8 -*-
1
+ # encoding: UTF-8
2
2
  module Axlsx
3
3
  # A Chart is the superclass for specific charts
4
4
  # @note Worksheet#add_chart is the recommended way to create charts for your worksheets.
@@ -52,8 +52,8 @@ module Axlsx
52
52
  options.each do |o|
53
53
  self.send("#{o[0]}=", o[1]) if self.respond_to? "#{o[0]}="
54
54
  end
55
- start_at *options[:start_at] if options[:start_at]
56
- end_at *options[:end_at] if options[:start_at]
55
+ start_at(*options[:start_at]) if options[:start_at]
56
+ end_at(*options[:end_at]) if options[:start_at]
57
57
  yield self if block_given?
58
58
  end
59
59
 
@@ -137,7 +137,7 @@ module Axlsx
137
137
  xml.layout
138
138
  xml.overlay :val => 0
139
139
  }
140
- end
140
+ end
141
141
  xml.plotVisOnly :val => 1
142
142
  xml.dispBlanksAs :val => :zero
143
143
  xml.showDLblsOverMax :val => 1
@@ -1,3 +1,4 @@
1
+ # encoding: UTF-8
1
2
  module Axlsx
2
3
  require 'axlsx/drawing/title.rb'
3
4
  require 'axlsx/drawing/series_title.rb'
@@ -1,3 +1,4 @@
1
+ # encoding: UTF-8
1
2
  module Axlsx
2
3
  # A graphic frame defines a container for a chart object
3
4
  # @note The recommended way to manage charts is Worksheet#add_chart
@@ -1,4 +1,4 @@
1
- # -*- coding: utf-8 -*-
1
+ # encoding: UTF-8
2
2
  module Axlsx
3
3
  # a hyperlink object adds an action to an image when clicked so that when the image is clicked the link is fecthed.
4
4
  # @note using the hyperlink option when calling add_image on a drawing object is the recommended way to manage hyperlinks
@@ -1,3 +1,4 @@
1
+ # encoding: UTF-8
1
2
  module Axlsx
2
3
 
3
4
  # The Line3DChart is a three dimentional line chart (who would have guessed?) that you can add to your worksheet.
@@ -1,3 +1,4 @@
1
+ # encoding: UTF-8
1
2
  module Axlsx
2
3
  # A LineSeries defines the title, data and labels for line charts
3
4
  # @note The recommended way to manage series is to use Chart#add_series
@@ -1,3 +1,4 @@
1
+ # encoding: UTF-8
1
2
  module Axlsx
2
3
  # The Marker class defines a point in the worksheet that drawing anchors attach to.
3
4
  # @note The recommended way to manage markers is Worksheet#add_chart Markers are created for a two cell anchor based on the :start and :end options.
@@ -1,3 +1,4 @@
1
+ # encoding: UTF-8
1
2
  module Axlsx
2
3
  # This class details a single cell anchor for drawings.
3
4
  # @note The recommended way to manage drawings, images and charts is Worksheet#add_chart or Worksheet#add_image.
@@ -1,4 +1,4 @@
1
- # -*- coding: utf-8 -*-
1
+ # encoding: UTF-8
2
2
  module Axlsx
3
3
  # a Pic object represents an image in your worksheet
4
4
  # Worksheet#add_image is the recommended way to manage images in your sheets
@@ -39,6 +39,7 @@ module Axlsx
39
39
  # @option options [Intger] height
40
40
  def initialize(anchor, options={})
41
41
  @anchor = anchor
42
+ @hyperlink = nil
42
43
  @anchor.drawing.worksheet.workbook.images << self
43
44
  options.each do |o|
44
45
  self.send("#{o[0]}=", o[1]) if self.respond_to? "#{o[0]}="
@@ -1,3 +1,4 @@
1
+ # encoding: UTF-8
1
2
  module Axlsx
2
3
  # The picture locking class defines the locking properties for pictures in your workbook.
3
4
  class PictureLocking
@@ -1,3 +1,4 @@
1
+ # encoding: UTF-8
1
2
  module Axlsx
2
3
 
3
4
 
@@ -1,3 +1,4 @@
1
+ # encoding: UTF-8
1
2
  module Axlsx
2
3
  # A PieSeries defines the data and labels and explosion for pie charts series.
3
4
  # @note The recommended way to manage series is to use Chart#add_series
@@ -1,3 +1,4 @@
1
+ # encoding: UTF-8
1
2
  module Axlsx
2
3
  # The Scaling class defines axis scaling
3
4
  class Scaling
@@ -1,3 +1,4 @@
1
+ # encoding: UTF-8
1
2
  module Axlsx
2
3
  #A SerAxis object defines a series axis
3
4
  class SerAxis < Axis
@@ -1,3 +1,4 @@
1
+ # encoding: UTF-8
1
2
  module Axlsx
2
3
  # A Series defines the common series attributes and is the super class for all concrete series types.
3
4
  # @note The recommended way to manage series is to use Chart#add_series
@@ -1,3 +1,4 @@
1
+ # encoding: UTF-8
1
2
  module Axlsx
2
3
  # A series title is a Title with a slightly different serialization than chart titles.
3
4
  class SeriesTitle < Title
@@ -1,3 +1,4 @@
1
+ # encoding: UTF-8
1
2
  module Axlsx
2
3
  # A Title stores information about the title of a chart
3
4
  class Title
@@ -1,3 +1,4 @@
1
+ # encoding: UTF-8
1
2
  module Axlsx
2
3
  # This class details the anchor points for drawings.
3
4
  # @note The recommended way to manage drawings and charts is Worksheet#add_chart. Anchors are specified by the :start_at and :end_at options to that method.
@@ -1,3 +1,4 @@
1
+ # encoding: UTF-8
1
2
  module Axlsx
2
3
  # the ValAxis class defines a chart value axis.
3
4
  class ValAxis < Axis
@@ -1,3 +1,4 @@
1
+ # encoding: UTF-8
1
2
  module Axlsx
2
3
  # The ValAxisData class manages the values for a chart value series.
3
4
  class ValAxisData < CatAxisData
@@ -1,3 +1,4 @@
1
+ # encoding: UTF-8
1
2
  module Axlsx
2
3
  # 3D attributes for a chart.
3
4
  class View3D