write_xlsx 1.08.2 → 1.09.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Changes +9 -0
- data/README.md +1 -1
- data/examples/background.rb +19 -0
- data/lib/write_xlsx/chart/axis.rb +3 -3
- data/lib/write_xlsx/chart/scatter.rb +0 -15
- data/lib/write_xlsx/chart/series.rb +1 -1
- data/lib/write_xlsx/chart.rb +28 -28
- data/lib/write_xlsx/chartsheet.rb +3 -3
- data/lib/write_xlsx/drawing.rb +39 -39
- data/lib/write_xlsx/format.rb +11 -179
- data/lib/write_xlsx/package/app.rb +2 -2
- data/lib/write_xlsx/package/button.rb +8 -8
- data/lib/write_xlsx/package/comments.rb +8 -8
- data/lib/write_xlsx/package/content_types.rb +18 -9
- data/lib/write_xlsx/package/core.rb +5 -5
- data/lib/write_xlsx/package/custom.rb +2 -2
- data/lib/write_xlsx/package/metadata.rb +159 -0
- data/lib/write_xlsx/package/packager.rb +21 -0
- data/lib/write_xlsx/package/shared_strings.rb +6 -6
- data/lib/write_xlsx/package/styles.rb +11 -11
- data/lib/write_xlsx/package/table.rb +23 -23
- data/lib/write_xlsx/package/theme.rb +1 -1
- data/lib/write_xlsx/package/vml.rb +43 -43
- data/lib/write_xlsx/shape.rb +17 -15
- data/lib/write_xlsx/sparkline.rb +340 -340
- data/lib/write_xlsx/utility.rb +4 -23
- data/lib/write_xlsx/version.rb +1 -1
- data/lib/write_xlsx/workbook.rb +171 -644
- data/lib/write_xlsx/worksheet/cell_data.rb +25 -3
- data/lib/write_xlsx/worksheet/data_validation.rb +20 -20
- data/lib/write_xlsx/worksheet/hyperlink.rb +4 -4
- data/lib/write_xlsx/worksheet/page_setup.rb +12 -12
- data/lib/write_xlsx/worksheet.rb +295 -4184
- data/test/perl_output/background.xlsx +0 -0
- data/test/regression/images/logo.gif +0 -0
- data/test/regression/images/logo.jpg +0 -0
- data/test/regression/images/red.gif +0 -0
- data/test/regression/test_background01.rb +23 -0
- data/test/regression/test_background02.rb +23 -0
- data/test/regression/test_background03.rb +24 -0
- data/test/regression/test_background04.rb +25 -0
- data/test/regression/test_background05.rb +25 -0
- data/test/regression/test_background06.rb +31 -0
- data/test/regression/test_background07.rb +37 -0
- data/test/regression/test_chart_axis47.rb +52 -0
- data/test/regression/test_chart_axis48.rb +53 -0
- data/test/regression/test_dynamic_array01.rb +25 -0
- data/test/regression/test_image56.rb +23 -0
- data/test/regression/test_image57.rb +23 -0
- data/test/regression/test_set_column10.rb +55 -0
- data/test/regression/test_set_column11.rb +48 -0
- data/test/regression/test_set_row01.rb +35 -0
- data/test/regression/test_set_row02.rb +35 -0
- data/test/regression/test_set_row03.rb +35 -0
- data/test/regression/test_set_row04.rb +35 -0
- data/test/regression/xlsx_files/background01.xlsx +0 -0
- data/test/regression/xlsx_files/background02.xlsx +0 -0
- data/test/regression/xlsx_files/background03.xlsx +0 -0
- data/test/regression/xlsx_files/background04.xlsx +0 -0
- data/test/regression/xlsx_files/background05.xlsx +0 -0
- data/test/regression/xlsx_files/background06.xlsx +0 -0
- data/test/regression/xlsx_files/background07.xlsx +0 -0
- data/test/regression/xlsx_files/chart_axis47.xlsx +0 -0
- data/test/regression/xlsx_files/chart_axis48.xlsx +0 -0
- data/test/regression/xlsx_files/dynamic_array01.xlsx +0 -0
- data/test/regression/xlsx_files/image56.xlsx +0 -0
- data/test/regression/xlsx_files/image57.xlsx +0 -0
- data/test/regression/xlsx_files/set_row01.xlsx +0 -0
- data/test/regression/xlsx_files/set_row03.xlsx +0 -0
- data/test/test_example_match.rb +12 -0
- data/test/worksheet/test_pixels_to_row_col.rb +46 -0
- metadata +78 -2
@@ -16,8 +16,8 @@ module Writexlsx
|
|
16
16
|
def cell_attributes #:nodoc:
|
17
17
|
xf_index = xf ? xf.get_xf_index : 0
|
18
18
|
attributes = [
|
19
|
-
|
20
|
-
|
19
|
+
['r', xl_rowcol_to_cell(row, col)]
|
20
|
+
]
|
21
21
|
|
22
22
|
# Add the cell format index.
|
23
23
|
if xf_index != 0
|
@@ -100,7 +100,7 @@ module Writexlsx
|
|
100
100
|
elsif error_code.include?(@result)
|
101
101
|
attributes << ['t', 'e']
|
102
102
|
else
|
103
|
-
|
103
|
+
attributes << ['t', 'str']
|
104
104
|
end
|
105
105
|
end
|
106
106
|
@worksheet.writer.tag_elements('c', attributes) do
|
@@ -128,6 +128,28 @@ module Writexlsx
|
|
128
128
|
end
|
129
129
|
end
|
130
130
|
|
131
|
+
class DynamicFormulaArrayCellData < CellData # :nodoc:
|
132
|
+
def initialize(worksheet, row, col, formula, xf, range, result)
|
133
|
+
@worksheet = worksheet
|
134
|
+
@row, @col, @token, @xf, @range, @result = row, col, formula, xf, range, result
|
135
|
+
end
|
136
|
+
|
137
|
+
def data
|
138
|
+
@result || 0
|
139
|
+
end
|
140
|
+
|
141
|
+
def write_cell
|
142
|
+
# Add metadata linkage for dynamic array formulas.
|
143
|
+
attributes = cell_attributes
|
144
|
+
attributes << ['cm', '1']
|
145
|
+
|
146
|
+
@worksheet.writer.tag_elements('c', attributes) do
|
147
|
+
@worksheet.write_cell_array_formula(token, range)
|
148
|
+
@worksheet.write_cell_value(result)
|
149
|
+
end
|
150
|
+
end
|
151
|
+
end
|
152
|
+
|
131
153
|
class BooleanCellData < CellData # :nodoc:
|
132
154
|
def initialize(worksheet, row, col, val, xf)
|
133
155
|
@worksheet = worksheet
|
@@ -181,11 +181,11 @@ module Writexlsx
|
|
181
181
|
end
|
182
182
|
unless valid_validation_type.has_key?(@validate.downcase)
|
183
183
|
raise WriteXLSXOptionParameterError,
|
184
|
-
|
184
|
+
"Unknown validation type '#{@validate}' for parameter :validate in data_validation()"
|
185
185
|
end
|
186
186
|
if @error_type && !error_type_hash.has_key?(@error_type.downcase)
|
187
187
|
raise WriteXLSXOptionParameterError,
|
188
|
-
|
188
|
+
"Unknown criteria type '#param[:error_type}' for parameter :error_type in data_validation()"
|
189
189
|
end
|
190
190
|
end
|
191
191
|
|
@@ -199,7 +199,7 @@ module Writexlsx
|
|
199
199
|
if @criteria == 'between' || @criteria == 'notBetween'
|
200
200
|
unless has_key?(:maximum)
|
201
201
|
raise WriteXLSXOptionParameterError,
|
202
|
-
|
202
|
+
"Parameter :maximum is required in data_validation() when using :between or :not between criteria"
|
203
203
|
end
|
204
204
|
else
|
205
205
|
@maximum = nil
|
@@ -209,7 +209,7 @@ module Writexlsx
|
|
209
209
|
def check_valid_citeria_types
|
210
210
|
unless valid_criteria_type.has_key?(@criteria.downcase)
|
211
211
|
raise WriteXLSXOptionParameterError,
|
212
|
-
|
212
|
+
"Unknown criteria type '#{@criteria}' for parameter :criteria in data_validation()"
|
213
213
|
end
|
214
214
|
end
|
215
215
|
|
@@ -253,22 +253,22 @@ module Writexlsx
|
|
253
253
|
# List of valid input parameters.
|
254
254
|
def valid_validation_parameter
|
255
255
|
[
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
256
|
+
:validate,
|
257
|
+
:criteria,
|
258
|
+
:value,
|
259
|
+
:source,
|
260
|
+
:minimum,
|
261
|
+
:maximum,
|
262
|
+
:ignore_blank,
|
263
|
+
:dropdown,
|
264
|
+
:show_input,
|
265
|
+
:input_title,
|
266
|
+
:input_message,
|
267
|
+
:show_error,
|
268
|
+
:error_title,
|
269
|
+
:error_message,
|
270
|
+
:error_type,
|
271
|
+
:other_cells
|
272
272
|
]
|
273
273
|
end
|
274
274
|
|
@@ -87,9 +87,9 @@ module Writexlsx
|
|
87
87
|
|
88
88
|
def attributes(row, col, dummy = nil)
|
89
89
|
attr = [
|
90
|
-
|
91
|
-
|
92
|
-
|
90
|
+
['ref', xl_rowcol_to_cell(row, col)],
|
91
|
+
['location', @url]
|
92
|
+
]
|
93
93
|
|
94
94
|
attr << ['tooltip', @tip] if @tip
|
95
95
|
attr << ['display', @str]
|
@@ -116,7 +116,7 @@ module Writexlsx
|
|
116
116
|
|
117
117
|
# Add the file:/// URI to the url if non-local.
|
118
118
|
if url =~ %r![:]! || # Windows style "C:/" link.
|
119
|
-
|
119
|
+
url =~ %r!^\\\\! # Network share.
|
120
120
|
url = "file:///#{url}"
|
121
121
|
end
|
122
122
|
|
@@ -105,12 +105,12 @@ module Writexlsx
|
|
105
105
|
attributes << ['pageOrder', "overThenDown"] if @across
|
106
106
|
attributes << ['firstPageNumber', @page_start] if @page_start && @page_start > 1
|
107
107
|
attributes << ['orientation',
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
108
|
+
if @orientation
|
109
|
+
'portrait'
|
110
|
+
else
|
111
|
+
'landscape'
|
112
|
+
end
|
113
|
+
]
|
114
114
|
attributes << ['blackAndWhite', 1] if @black_white
|
115
115
|
attributes << ['useFirstPageNumber', 1] if ptrue?(@page_start)
|
116
116
|
|
@@ -180,12 +180,12 @@ module Writexlsx
|
|
180
180
|
|
181
181
|
def margin_attributes # :nodoc:
|
182
182
|
[
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
183
|
+
['left', @margin_left],
|
184
|
+
['right', @margin_right],
|
185
|
+
['top', @margin_top],
|
186
|
+
['bottom', @margin_bottom],
|
187
|
+
['header', @margin_header],
|
188
|
+
['footer', @margin_footer]
|
189
189
|
]
|
190
190
|
end
|
191
191
|
end
|