xlsxwriter 0.2.1.pre → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +4 -3
- data/ext/xlsxwriter/chart.c +88 -80
- data/ext/xlsxwriter/chart.h +2 -2
- data/ext/xlsxwriter/chartsheet.c +307 -0
- data/ext/xlsxwriter/chartsheet.h +15 -0
- data/ext/xlsxwriter/common.h +104 -0
- data/ext/xlsxwriter/extconf.rb +8 -8
- data/ext/xlsxwriter/libxlsxwriter/License.txt +24 -2
- data/ext/xlsxwriter/libxlsxwriter/Makefile +46 -12
- data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/app.h +1 -1
- data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/chart.h +196 -30
- data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/chartsheet.h +3 -3
- data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/comment.h +76 -0
- data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/common.h +24 -5
- data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/content_types.h +5 -1
- data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/core.h +1 -1
- data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/custom.h +1 -1
- data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/drawing.h +6 -17
- data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/format.h +20 -6
- data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/hash_table.h +1 -1
- data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/packager.h +3 -1
- data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/relationships.h +1 -1
- data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/shared_strings.h +1 -1
- data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/styles.h +11 -5
- data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/theme.h +1 -1
- data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/third_party/md5.h +43 -0
- data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/utility.h +42 -3
- data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/vml.h +55 -0
- data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/workbook.h +83 -18
- data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/worksheet.h +1519 -109
- data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/xmlwriter.h +4 -2
- data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter.h +3 -2
- data/ext/xlsxwriter/libxlsxwriter/src/Makefile +25 -7
- data/ext/xlsxwriter/libxlsxwriter/src/app.c +1 -1
- data/ext/xlsxwriter/libxlsxwriter/src/chart.c +332 -48
- data/ext/xlsxwriter/libxlsxwriter/src/chartsheet.c +20 -19
- data/ext/xlsxwriter/libxlsxwriter/src/comment.c +443 -0
- data/ext/xlsxwriter/libxlsxwriter/src/content_types.c +20 -1
- data/ext/xlsxwriter/libxlsxwriter/src/core.c +2 -2
- data/ext/xlsxwriter/libxlsxwriter/src/custom.c +1 -1
- data/ext/xlsxwriter/libxlsxwriter/src/drawing.c +58 -20
- data/ext/xlsxwriter/libxlsxwriter/src/format.c +98 -25
- data/ext/xlsxwriter/libxlsxwriter/src/hash_table.c +1 -1
- data/ext/xlsxwriter/libxlsxwriter/src/packager.c +269 -12
- data/ext/xlsxwriter/libxlsxwriter/src/relationships.c +1 -1
- data/ext/xlsxwriter/libxlsxwriter/src/shared_strings.c +2 -4
- data/ext/xlsxwriter/libxlsxwriter/src/styles.c +334 -48
- data/ext/xlsxwriter/libxlsxwriter/src/theme.c +1 -1
- data/ext/xlsxwriter/libxlsxwriter/src/utility.c +71 -8
- data/ext/xlsxwriter/libxlsxwriter/src/vml.c +1032 -0
- data/ext/xlsxwriter/libxlsxwriter/src/workbook.c +343 -27
- data/ext/xlsxwriter/libxlsxwriter/src/worksheet.c +3759 -478
- data/ext/xlsxwriter/libxlsxwriter/src/xmlwriter.c +81 -2
- data/ext/xlsxwriter/libxlsxwriter/third_party/md5/Makefile +42 -0
- data/ext/xlsxwriter/libxlsxwriter/third_party/md5/md5.c +291 -0
- data/ext/xlsxwriter/libxlsxwriter/third_party/md5/md5.h +43 -0
- data/ext/xlsxwriter/shared_strings.c +65 -0
- data/ext/xlsxwriter/shared_strings.h +15 -0
- data/ext/xlsxwriter/workbook.c +96 -20
- data/ext/xlsxwriter/worksheet.c +125 -235
- data/ext/xlsxwriter/worksheet.h +2 -1
- data/ext/xlsxwriter/xlsxwriter.c +4 -0
- data/lib/xlsxwriter/rich_string.rb +0 -2
- data/lib/xlsxwriter/version.rb +1 -1
- data/lib/xlsxwriter/worksheet.rb +2 -2
- data/test/{run-test.rb → run_test.rb} +3 -3
- data/test/support/chart_test.rb +3 -3
- data/test/support/with_xlsx_file.rb +4 -2
- data/test/support/xlsx_comparable.rb +40 -26
- data/test/test_array_formula.rb +42 -0
- data/test/test_autofilter.rb +72 -0
- data/test/{test-chart-area.rb → test_chart_area.rb} +2 -2
- data/test/{test-chart-axis.rb → test_chart_axis.rb} +16 -16
- data/test/test_chart_bar.rb +382 -0
- data/test/test_chart_blank.rb +27 -0
- data/test/{test-chart-column.rb → test_chart_column.rb} +2 -2
- data/test/{test-chart-doughnut.rb → test_chart_doughnut.rb} +2 -2
- data/test/{test-chart-legend.rb → test_chart_legend.rb} +2 -2
- data/test/{test-chart-pie.rb → test_chart_pie.rb} +2 -2
- data/test/{test-chart-scatter.rb → test_chart_scatter.rb} +3 -4
- data/test/{test-chart-size.rb → test_chart_size.rb} +2 -2
- data/test/{test-chart-title.rb → test_chart_title.rb} +3 -3
- data/test/test_chartsheet.rb +201 -0
- data/test/{test-data.rb → test_data.rb} +1 -1
- data/test/{test-data-validation.rb → test_data_validation.rb} +23 -24
- data/test/{test-default-row.rb → test_default_row.rb} +1 -1
- data/test/{test-defined-name.rb → test_defined_name.rb} +12 -12
- data/test/{test-escapes.rb → test_escapes.rb} +5 -2
- data/test/{test-fit-to-pages.rb → test_fit_to_pages.rb} +6 -6
- data/test/{test-formatting.rb → test_formatting.rb} +10 -10
- data/test/{test-gridlines.rb → test_gridlines.rb} +3 -3
- data/test/{test-hyperlink.rb → test_hyperlink.rb} +22 -11
- data/test/{test-image.rb → test_image.rb} +6 -4
- data/test/{test-macro.rb → test_macro.rb} +1 -1
- data/test/{test-merge-range.rb → test_merge_range.rb} +1 -1
- data/test/{test-misc.rb → test_misc.rb} +2 -2
- data/test/{test-optimize.rb → test_optimize.rb} +2 -4
- data/test/{test-outline.rb → test_outline.rb} +14 -14
- data/test/{test-page-breaks.rb → test_page_breaks.rb} +2 -2
- data/test/{test-page-setup.rb → test_page_setup.rb} +2 -2
- data/test/{test-panes.rb → test_panes.rb} +1 -1
- data/test/{test-print-area.rb → test_print_area.rb} +3 -3
- data/test/{test-print-options.rb → test_print_options.rb} +7 -7
- data/test/{test-print-scale.rb → test_print_scale.rb} +2 -2
- data/test/{test-properties.rb → test_properties.rb} +2 -2
- data/test/{test-protect.rb → test_protect.rb} +3 -3
- data/test/{test-repeat.rb → test_repeat.rb} +3 -3
- data/test/{test-rich-string.rb → test_rich_string.rb} +5 -9
- data/test/{test-row-col-format.rb → test_row_col_format.rb} +1 -1
- data/test/{test-ruby-worksheet.rb → test_ruby_worksheet.rb} +2 -2
- data/test/{test-set-selection.rb → test_set_selection.rb} +2 -2
- data/test/{test-set-start-page.rb → test_set_start_page.rb} +2 -2
- data/test/{test-simple.rb → test_simple.rb} +10 -10
- data/test/{test-types.rb → test_types.rb} +1 -1
- data/test/{xlsx-func-testcase.rb → xlsx_func_testcase.rb} +1 -0
- metadata +135 -104
- data/test/test-array-formula.rb +0 -35
- data/test/test-autofilter.rb +0 -72
- data/test/test-chart-bar.rb +0 -74
- /data/test/{test-errors.rb → test_errors.rb} +0 -0
@@ -0,0 +1,307 @@
|
|
1
|
+
#include "chart.h"
|
2
|
+
#include "chartsheet.h"
|
3
|
+
#include "common.h"
|
4
|
+
#include "workbook.h"
|
5
|
+
#include "xlsxwriter_ext.h"
|
6
|
+
|
7
|
+
VALUE cChartsheet;
|
8
|
+
|
9
|
+
void chartsheet_free(void *p);
|
10
|
+
|
11
|
+
|
12
|
+
VALUE
|
13
|
+
chartsheet_alloc(VALUE klass) {
|
14
|
+
VALUE obj;
|
15
|
+
struct chartsheet *ptr;
|
16
|
+
|
17
|
+
obj = Data_Make_Struct(klass, struct chartsheet, NULL, chartsheet_free, ptr);
|
18
|
+
|
19
|
+
ptr->chartsheet = NULL;
|
20
|
+
|
21
|
+
return obj;
|
22
|
+
}
|
23
|
+
|
24
|
+
/* :nodoc: */
|
25
|
+
VALUE
|
26
|
+
chartsheet_init(int argc, VALUE *argv, VALUE self) {
|
27
|
+
char *name = NULL;
|
28
|
+
struct workbook *wb_ptr;
|
29
|
+
struct chartsheet *ptr;
|
30
|
+
|
31
|
+
Data_Get_Struct(self, struct chartsheet, ptr);
|
32
|
+
|
33
|
+
if (argc == 2) {
|
34
|
+
name = StringValueCStr(argv[1]);
|
35
|
+
}
|
36
|
+
|
37
|
+
rb_iv_set(self, "@workbook", argv[0]);
|
38
|
+
|
39
|
+
Data_Get_Struct(argv[0], struct workbook, wb_ptr);
|
40
|
+
ptr->chartsheet = workbook_add_chartsheet(wb_ptr->workbook, name);
|
41
|
+
if (!ptr->chartsheet)
|
42
|
+
rb_raise(eXlsxWriterError, "chartsheet was not created");
|
43
|
+
return self;
|
44
|
+
}
|
45
|
+
|
46
|
+
/* :nodoc: */
|
47
|
+
VALUE
|
48
|
+
chartsheet_release(VALUE self) {
|
49
|
+
struct chartsheet *ptr;
|
50
|
+
Data_Get_Struct(self, struct chartsheet, ptr);
|
51
|
+
|
52
|
+
chartsheet_free(ptr);
|
53
|
+
return self;
|
54
|
+
}
|
55
|
+
|
56
|
+
void
|
57
|
+
chartsheet_free(void *p) {
|
58
|
+
struct chartsheet *ptr = p;
|
59
|
+
|
60
|
+
if (ptr->chartsheet)
|
61
|
+
ptr->chartsheet = NULL;
|
62
|
+
}
|
63
|
+
|
64
|
+
|
65
|
+
/* call-seq: cs.activate -> self
|
66
|
+
*
|
67
|
+
* Set the chartsheet to be active on opening the workbook.
|
68
|
+
*/
|
69
|
+
VALUE
|
70
|
+
chartsheet_activate_(VALUE self) {
|
71
|
+
LXW_NO_RESULT_CALL(chartsheet, activate);
|
72
|
+
return self;
|
73
|
+
}
|
74
|
+
|
75
|
+
/* call-seq: cs.chart = chart
|
76
|
+
*
|
77
|
+
* Set the chart chartsheet contains.
|
78
|
+
*/
|
79
|
+
VALUE
|
80
|
+
chartsheet_set_chart_(VALUE self, VALUE chart) {
|
81
|
+
struct chart *chart_ptr;
|
82
|
+
Data_Get_Struct(chart, struct chart, chart_ptr);
|
83
|
+
|
84
|
+
LXW_ERR_RESULT_CALL(chartsheet, set_chart, chart_ptr->chart);
|
85
|
+
return self;
|
86
|
+
}
|
87
|
+
|
88
|
+
/* call-seq: cs.hide -> self
|
89
|
+
*
|
90
|
+
* Hide the chartsheet.
|
91
|
+
*/
|
92
|
+
VALUE
|
93
|
+
chartsheet_hide_(VALUE self) {
|
94
|
+
LXW_NO_RESULT_CALL(chartsheet, hide);
|
95
|
+
return self;
|
96
|
+
}
|
97
|
+
|
98
|
+
/* call-seq: cs.paper=(type) -> type
|
99
|
+
*
|
100
|
+
* Sets the paper +type+ for printing. See {libxlsxwriter doc}[https://libxlsxwriter.github.io/worksheet_8h.html#a9f8af12017797b10c5ee68e04149032f] for options.
|
101
|
+
*/
|
102
|
+
VALUE
|
103
|
+
chartsheet_set_paper_(VALUE self, VALUE paper_type) {
|
104
|
+
LXW_NO_RESULT_CALL(chartsheet, set_paper, NUM2INT(paper_type));
|
105
|
+
return self;
|
106
|
+
}
|
107
|
+
|
108
|
+
/* call-seq: cs.protect(password[, opts]) -> self
|
109
|
+
*
|
110
|
+
* Protects the worksheet elements from modification.
|
111
|
+
* See {libxlsxwriter doc}[https://libxlsxwriter.github.io/worksheet_8h.html#a1b49e135d4debcdb25941f2f40f04cb0]
|
112
|
+
* for options.
|
113
|
+
*/
|
114
|
+
VALUE
|
115
|
+
chartsheet_protect_(int argc, VALUE *argv, VALUE self) {
|
116
|
+
rb_check_arity(argc, 0, 2);
|
117
|
+
struct _protect_options po = _extract_protect_options(argc, argv);
|
118
|
+
LXW_NO_RESULT_CALL(chartsheet, protect, po.password, (po.with_options ? &po.options : NULL));
|
119
|
+
return self;
|
120
|
+
}
|
121
|
+
|
122
|
+
/* call-seq: cs.set_fitst_sheet -> self
|
123
|
+
*
|
124
|
+
* Set the sheet to be the first visible in the sheets list (which is placed
|
125
|
+
* under the work area in Excel).
|
126
|
+
*/
|
127
|
+
VALUE
|
128
|
+
chartsheet_set_first_sheet_(VALUE self) {
|
129
|
+
LXW_NO_RESULT_CALL(chartsheet, set_first_sheet);
|
130
|
+
return self;
|
131
|
+
}
|
132
|
+
|
133
|
+
/* call-seq: cs.set_footer(text[, opts])
|
134
|
+
*
|
135
|
+
* See Worksheet#set_header for params description.
|
136
|
+
*/
|
137
|
+
VALUE
|
138
|
+
chartsheet_set_footer_(int argc, VALUE *argv, VALUE self) {
|
139
|
+
rb_check_arity(argc, 1, 2);
|
140
|
+
struct _header_options ho = _extract_header_options(argc, argv);
|
141
|
+
struct chartsheet *ptr;
|
142
|
+
Data_Get_Struct(self, struct chartsheet, ptr);
|
143
|
+
lxw_error err;
|
144
|
+
if (!ho.with_options) {
|
145
|
+
err = chartsheet_set_footer(ptr->chartsheet, ho.str);
|
146
|
+
} else {
|
147
|
+
err = chartsheet_set_footer_opt(ptr->chartsheet, ho.str, &ho.options);
|
148
|
+
}
|
149
|
+
handle_lxw_error(err);
|
150
|
+
return self;
|
151
|
+
}
|
152
|
+
|
153
|
+
/* call-seq: cs.select -> self
|
154
|
+
*
|
155
|
+
* Set the chartsheet to be selected on opening the workbook.
|
156
|
+
*/
|
157
|
+
VALUE
|
158
|
+
chartsheet_select_(VALUE self) {
|
159
|
+
LXW_NO_RESULT_CALL(chartsheet, select);
|
160
|
+
return self;
|
161
|
+
}
|
162
|
+
|
163
|
+
/* call-seq: cs.set_header(text[, opts])
|
164
|
+
*
|
165
|
+
* See Worksheet#set_header for params description.
|
166
|
+
*/
|
167
|
+
VALUE
|
168
|
+
chartsheet_set_header_(int argc, VALUE *argv, VALUE self) {
|
169
|
+
rb_check_arity(argc, 1, 2);
|
170
|
+
struct _header_options ho = _extract_header_options(argc, argv);
|
171
|
+
struct chartsheet *ptr;
|
172
|
+
Data_Get_Struct(self, struct chartsheet, ptr);
|
173
|
+
lxw_error err;
|
174
|
+
if (!ho.with_options) {
|
175
|
+
err = chartsheet_set_header(ptr->chartsheet, ho.str);
|
176
|
+
} else {
|
177
|
+
err = chartsheet_set_header_opt(ptr->chartsheet, ho.str, &ho.options);
|
178
|
+
}
|
179
|
+
handle_lxw_error(err);
|
180
|
+
return self;
|
181
|
+
}
|
182
|
+
|
183
|
+
/* call-seq: cs.set_landscape -> self
|
184
|
+
*
|
185
|
+
* Sets print orientation of the chartsheet to landscape.
|
186
|
+
*/
|
187
|
+
VALUE
|
188
|
+
chartsheet_set_landscape_(VALUE self) {
|
189
|
+
LXW_NO_RESULT_CALL(chartsheet, set_landscape);
|
190
|
+
return self;
|
191
|
+
}
|
192
|
+
|
193
|
+
/* Sets the chartsheet margins (Numeric) for the printed page. */
|
194
|
+
VALUE
|
195
|
+
chartsheet_set_margins_(VALUE self, VALUE left, VALUE right, VALUE top, VALUE bottom) {
|
196
|
+
LXW_NO_RESULT_CALL(chartsheet, set_margins, NUM2DBL(left), NUM2DBL(right), NUM2DBL(top), NUM2DBL(bottom));
|
197
|
+
return self;
|
198
|
+
}
|
199
|
+
|
200
|
+
/* call-seq: cs.set_portrait -> self
|
201
|
+
*
|
202
|
+
* Sets print orientation of the chartsheet to portrait.
|
203
|
+
*/
|
204
|
+
VALUE
|
205
|
+
chartsheet_set_portrait_(VALUE self) {
|
206
|
+
LXW_NO_RESULT_CALL(chartsheet, set_portrait);
|
207
|
+
return self;
|
208
|
+
}
|
209
|
+
|
210
|
+
/* call-seq: cs.tab_color=(color) -> color
|
211
|
+
*
|
212
|
+
* Set the tab color (from RGB integer).
|
213
|
+
*
|
214
|
+
* ws.tab_color = 0xF0F0F0
|
215
|
+
*/
|
216
|
+
VALUE
|
217
|
+
chartsheet_set_tab_color_(VALUE self, VALUE color) {
|
218
|
+
LXW_NO_RESULT_CALL(chartsheet, set_tab_color, NUM2INT(color));
|
219
|
+
return color;
|
220
|
+
}
|
221
|
+
|
222
|
+
/* call-seq: cs.zoom=(zoom) -> zoom
|
223
|
+
*
|
224
|
+
* Sets the worksheet zoom factor in the range 10 <= +zoom+ <= 400.
|
225
|
+
*/
|
226
|
+
VALUE
|
227
|
+
chartsheet_set_zoom_(VALUE self, VALUE val) {
|
228
|
+
LXW_NO_RESULT_CALL(chartsheet, set_zoom, NUM2INT(val));
|
229
|
+
return self;
|
230
|
+
}
|
231
|
+
|
232
|
+
/* call-seq: cs.horizontal_dpi -> int
|
233
|
+
*
|
234
|
+
* Returns the horizontal dpi.
|
235
|
+
*/
|
236
|
+
VALUE
|
237
|
+
chartsheet_get_horizontal_dpi_(VALUE self) {
|
238
|
+
struct chartsheet *ptr;
|
239
|
+
Data_Get_Struct(self, struct chartsheet, ptr);
|
240
|
+
return INT2NUM(ptr->chartsheet->worksheet->horizontal_dpi);
|
241
|
+
}
|
242
|
+
|
243
|
+
/* call-seq: cs.horizontal_dpi=(dpi) -> dpi
|
244
|
+
*
|
245
|
+
* Sets the horizontal dpi.
|
246
|
+
*/
|
247
|
+
VALUE
|
248
|
+
chartsheet_set_horizontal_dpi_(VALUE self, VALUE val) {
|
249
|
+
struct chartsheet *ptr;
|
250
|
+
Data_Get_Struct(self, struct chartsheet, ptr);
|
251
|
+
ptr->chartsheet->worksheet->horizontal_dpi = NUM2INT(val);
|
252
|
+
return val;
|
253
|
+
}
|
254
|
+
|
255
|
+
/* call-seq: cs.vertical_dpi -> int
|
256
|
+
*
|
257
|
+
* Returns the vertical dpi.
|
258
|
+
*/
|
259
|
+
VALUE
|
260
|
+
chartsheet_get_vertical_dpi_(VALUE self) {
|
261
|
+
struct chartsheet *ptr;
|
262
|
+
Data_Get_Struct(self, struct chartsheet, ptr);
|
263
|
+
return INT2NUM(ptr->chartsheet->worksheet->vertical_dpi);
|
264
|
+
}
|
265
|
+
|
266
|
+
/* call-seq: cs.vertical_dpi=(dpi) -> dpi
|
267
|
+
*
|
268
|
+
* Sets the vertical dpi.
|
269
|
+
*/
|
270
|
+
VALUE
|
271
|
+
chartsheet_set_vertical_dpi_(VALUE self, VALUE val) {
|
272
|
+
struct chartsheet *ptr;
|
273
|
+
Data_Get_Struct(self, struct chartsheet, ptr);
|
274
|
+
ptr->chartsheet->worksheet->vertical_dpi = NUM2INT(val);
|
275
|
+
return val;
|
276
|
+
}
|
277
|
+
|
278
|
+
|
279
|
+
|
280
|
+
void
|
281
|
+
init_xlsxwriter_chartsheet() {
|
282
|
+
/* Xlsx chartsheet */
|
283
|
+
cChartsheet = rb_define_class_under(mXlsxWriter, "Chartsheet", rb_cObject);
|
284
|
+
|
285
|
+
rb_define_alloc_func(cChartsheet, chartsheet_alloc);
|
286
|
+
rb_define_method(cChartsheet, "initialize", chartsheet_init, -1);
|
287
|
+
rb_define_method(cChartsheet, "free", chartsheet_release, 0);
|
288
|
+
rb_define_method(cChartsheet, "activate", chartsheet_activate_, 0);
|
289
|
+
rb_define_method(cChartsheet, "chart=", chartsheet_set_chart_, 1);
|
290
|
+
rb_define_method(cChartsheet, "hide", chartsheet_hide_, 0);
|
291
|
+
rb_define_method(cChartsheet, "paper=", chartsheet_set_paper_, 1);
|
292
|
+
rb_define_method(cChartsheet, "protect", chartsheet_protect_, -1);
|
293
|
+
rb_define_method(cChartsheet, "select", chartsheet_select_, 0);
|
294
|
+
rb_define_method(cChartsheet, "set_first_sheet", chartsheet_set_first_sheet_, 0);
|
295
|
+
rb_define_method(cChartsheet, "set_footer", chartsheet_set_footer_, -1);
|
296
|
+
rb_define_method(cChartsheet, "set_header", chartsheet_set_header_, -1);
|
297
|
+
rb_define_method(cChartsheet, "set_landscape", chartsheet_set_landscape_, 0);
|
298
|
+
rb_define_method(cChartsheet, "set_margins", chartsheet_set_margins_, 4);
|
299
|
+
rb_define_method(cChartsheet, "set_portrait", chartsheet_set_portrait_, 0);
|
300
|
+
rb_define_method(cChartsheet, "tab_color=", chartsheet_set_tab_color_, 1);
|
301
|
+
rb_define_method(cChartsheet, "zoom=", chartsheet_set_zoom_, 1);
|
302
|
+
|
303
|
+
rb_define_method(cChartsheet, "horizontal_dpi", chartsheet_get_horizontal_dpi_, 0);
|
304
|
+
rb_define_method(cChartsheet, "horizontal_dpi=", chartsheet_set_horizontal_dpi_, 1);
|
305
|
+
rb_define_method(cChartsheet, "vertical_dpi", chartsheet_get_vertical_dpi_, 0);
|
306
|
+
rb_define_method(cChartsheet, "vertical_dpi=", chartsheet_set_vertical_dpi_, 1);
|
307
|
+
}
|
@@ -0,0 +1,15 @@
|
|
1
|
+
#include <ruby.h>
|
2
|
+
#include <xlsxwriter.h>
|
3
|
+
|
4
|
+
#ifndef __CHARTSHEET__
|
5
|
+
#define __CHARTSHEET__
|
6
|
+
|
7
|
+
struct chartsheet {
|
8
|
+
lxw_chartsheet *chartsheet;
|
9
|
+
};
|
10
|
+
|
11
|
+
void init_xlsxwriter_chartsheet();
|
12
|
+
|
13
|
+
extern VALUE cChartsheet;
|
14
|
+
|
15
|
+
#endif // __CHARTSHEET__
|
@@ -0,0 +1,104 @@
|
|
1
|
+
#include <ruby.h>
|
2
|
+
#include <ruby/intern.h>
|
3
|
+
#include <xlsxwriter_ext.h>
|
4
|
+
|
5
|
+
#ifndef __COMMON__
|
6
|
+
#define __COMMON__
|
7
|
+
|
8
|
+
#define LXW_NO_RESULT_CALL(cls, method, ...) { \
|
9
|
+
struct cls *ptr; \
|
10
|
+
Data_Get_Struct(self, struct cls, ptr); \
|
11
|
+
cls ## _ ## method(ptr->cls, ##__VA_ARGS__); }
|
12
|
+
|
13
|
+
#define LXW_ERR_RESULT_CALL(cls, method, ...) { \
|
14
|
+
struct cls *ptr; \
|
15
|
+
Data_Get_Struct(self, struct cls, ptr); \
|
16
|
+
lxw_error err = cls ## _ ## method(ptr->cls, ##__VA_ARGS__); \
|
17
|
+
handle_lxw_error(err); }
|
18
|
+
|
19
|
+
|
20
|
+
struct _protect_options {
|
21
|
+
uint8_t with_options;
|
22
|
+
const char *password;
|
23
|
+
lxw_protection options;
|
24
|
+
};
|
25
|
+
|
26
|
+
static inline struct _protect_options
|
27
|
+
_extract_protect_options(int argc, VALUE *argv) {
|
28
|
+
VALUE val;
|
29
|
+
VALUE opts = Qnil;
|
30
|
+
struct _protect_options po = {0};
|
31
|
+
// All options are off by default
|
32
|
+
if (argc > 0 && !NIL_P(argv[0])) {
|
33
|
+
switch (TYPE(argv[0])) {
|
34
|
+
case T_STRING:
|
35
|
+
po.password = StringValueCStr(argv[0]);
|
36
|
+
break;
|
37
|
+
case T_HASH:
|
38
|
+
opts = argv[0];
|
39
|
+
break;
|
40
|
+
default:
|
41
|
+
rb_raise(rb_eArgError, "Wrong argument %"PRIsVALUE", expected a String or Hash", rb_obj_class(argv[0]));
|
42
|
+
}
|
43
|
+
}
|
44
|
+
|
45
|
+
if (argc > 1) {
|
46
|
+
if (TYPE(argv[1]) == T_HASH) {
|
47
|
+
opts = argv[1];
|
48
|
+
} else {
|
49
|
+
rb_raise(rb_eArgError, "Expected a Hash, but got %"PRIsVALUE, rb_obj_class(argv[1]));
|
50
|
+
}
|
51
|
+
}
|
52
|
+
|
53
|
+
if (!NIL_P(opts)) {
|
54
|
+
#define PR_OPT(field) { \
|
55
|
+
val = rb_hash_aref(opts, ID2SYM(rb_intern(#field))); \
|
56
|
+
if (!NIL_P(val) && val) { \
|
57
|
+
po.options.field = 1; \
|
58
|
+
po.with_options = 1; \
|
59
|
+
} \
|
60
|
+
}
|
61
|
+
PR_OPT(no_select_locked_cells);
|
62
|
+
PR_OPT(no_select_unlocked_cells);
|
63
|
+
PR_OPT(format_cells);
|
64
|
+
PR_OPT(format_columns);
|
65
|
+
PR_OPT(format_rows);
|
66
|
+
PR_OPT(insert_columns);
|
67
|
+
PR_OPT(insert_rows);
|
68
|
+
PR_OPT(insert_hyperlinks);
|
69
|
+
PR_OPT(delete_columns);
|
70
|
+
PR_OPT(delete_rows);
|
71
|
+
PR_OPT(sort);
|
72
|
+
PR_OPT(autofilter);
|
73
|
+
PR_OPT(pivot_tables);
|
74
|
+
PR_OPT(scenarios);
|
75
|
+
PR_OPT(objects);
|
76
|
+
#undef PR_OPT
|
77
|
+
}
|
78
|
+
|
79
|
+
return po;
|
80
|
+
}
|
81
|
+
|
82
|
+
|
83
|
+
struct _header_options {
|
84
|
+
char with_options;
|
85
|
+
const char *str;
|
86
|
+
lxw_header_footer_options options;
|
87
|
+
};
|
88
|
+
|
89
|
+
static inline struct _header_options
|
90
|
+
_extract_header_options(int argc, VALUE *argv) {
|
91
|
+
struct _header_options ho = { 0 };
|
92
|
+
ho.str = StringValueCStr(argv[0]);
|
93
|
+
if (argc > 1 && !NIL_P(argv[1])) {
|
94
|
+
VALUE margin = rb_hash_aref(argv[1], ID2SYM(rb_intern("margin")));
|
95
|
+
if (!NIL_P(margin)) {
|
96
|
+
ho.with_options = '\1';
|
97
|
+
ho.options.margin = NUM2DBL(margin);
|
98
|
+
}
|
99
|
+
}
|
100
|
+
return ho;
|
101
|
+
}
|
102
|
+
|
103
|
+
|
104
|
+
#endif // __COMMON__
|
data/ext/xlsxwriter/extconf.rb
CHANGED
@@ -1,14 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'mkmf'
|
4
|
+
require 'English'
|
2
5
|
|
3
|
-
libxlsxwriter_dir = File.expand_path('
|
4
|
-
make_pid = spawn({'CFLAGS' => '-fPIC -O2'}, $make, chdir: libxlsxwriter_dir)
|
6
|
+
libxlsxwriter_dir = File.expand_path('libxlsxwriter', __dir__)
|
7
|
+
make_pid = spawn({ 'CFLAGS' => '-fPIC -O2' }, $make, chdir: libxlsxwriter_dir)
|
5
8
|
Process.wait(make_pid)
|
6
|
-
raise 'Make failed for xlsxwriter' unless
|
9
|
+
raise 'Make failed for xlsxwriter' unless $CHILD_STATUS.success?
|
7
10
|
|
8
|
-
|
9
|
-
|
10
|
-
$CFLAGS="-I'#{libxlsxwriter_dir}/include' -g -Wall -O2"
|
11
|
-
# $LDFLAGS="-L./libxlsxwriter/lib/ -Wl,-Bstatic -lxlsxwriter -Wl,-Bdynamic"
|
12
|
-
$LDFLAGS="-lz #{libxlsxwriter_dir}/lib/libxlsxwriter.a"
|
11
|
+
$CFLAGS = "-I'#{libxlsxwriter_dir}/include' -g -Wall -Werror -O2"
|
12
|
+
$LDFLAGS = "-lz #{libxlsxwriter_dir}/lib/libxlsxwriter.a"
|
13
13
|
|
14
14
|
create_makefile 'xlsxwriter/xlsxwriter'
|
@@ -4,7 +4,7 @@
|
|
4
4
|
|
5
5
|
Libxlsxwriter is released under a FreeBSD license:
|
6
6
|
|
7
|
-
Copyright 2014-
|
7
|
+
Copyright 2014-2020, John McNamara <jmcnamara@cpan.org>
|
8
8
|
All rights reserved.
|
9
9
|
|
10
10
|
Redistribution and use in source and binary forms, with or without
|
@@ -35,7 +35,8 @@ Libxlsxwriter is released under a FreeBSD license:
|
|
35
35
|
|
36
36
|
|
37
37
|
Libxlsxwriter includes `queue.h` and `tree.h` from FreeBSD, the `minizip`
|
38
|
-
component of `zlib` and `
|
38
|
+
component of `zlib`, `tmpfileplus` and `md5` which have the following
|
39
|
+
licenses:
|
39
40
|
|
40
41
|
|
41
42
|
Queue.h from FreeBSD:
|
@@ -146,5 +147,26 @@ See the [Mozilla Public License, v. 2.0](http://mozilla.org/MPL/2.0/).
|
|
146
147
|
Note, it is possible to compile libxlsxwriter using the standard library
|
147
148
|
`tmpfile()` function instead of `tmpfileplus`, see @ref gsg_tmpdir.
|
148
149
|
|
150
|
+
[Openwall MD5](https://openwall.info/wiki/people/solar/software/public-domain-source-code/md5)
|
151
|
+
has the following licence:
|
152
|
+
|
153
|
+
This software was written by Alexander Peslyak in 2001. No copyright is
|
154
|
+
claimed, and the software is hereby placed in the public domain.
|
155
|
+
In case this attempt to disclaim copyright and place the software in the
|
156
|
+
public domain is deemed null and void, then the software is
|
157
|
+
Copyright (c) 2001 Alexander Peslyak and it is hereby released to the
|
158
|
+
general public under the following terms:
|
159
|
+
|
160
|
+
Redistribution and use in source and binary forms, with or without
|
161
|
+
modification, are permitted.
|
162
|
+
|
163
|
+
There's ABSOLUTELY NO WARRANTY, express or implied.
|
164
|
+
|
165
|
+
(This is a heavily cut-down "BSD license".)
|
166
|
+
|
167
|
+
Note, the MD5 library is used to avoid including duplicate image files in the
|
168
|
+
xlsx file. If this functionality isn't required it is possible to compile
|
169
|
+
libxlsxwriter without this library by passing `USE_NO_MD5=1` to make.
|
170
|
+
|
149
171
|
Next: @ref changes
|
150
172
|
*/
|
@@ -2,7 +2,7 @@
|
|
2
2
|
#
|
3
3
|
# Makefile for libxlsxwriter library.
|
4
4
|
#
|
5
|
-
# Copyright 2014-
|
5
|
+
# Copyright 2014-2020, John McNamara, jmcnamara@cpan.org
|
6
6
|
#
|
7
7
|
|
8
8
|
# Keep the output quiet by default.
|
@@ -11,9 +11,11 @@ ifdef V
|
|
11
11
|
Q=
|
12
12
|
endif
|
13
13
|
|
14
|
-
|
14
|
+
DESTDIR ?=
|
15
|
+
PREFIX ?= /usr/local
|
15
16
|
|
16
17
|
PYTEST ?= py.test
|
18
|
+
PYTESTFILES ?= test
|
17
19
|
|
18
20
|
.PHONY: docs tags examples
|
19
21
|
|
@@ -24,6 +26,9 @@ ifndef USE_SYSTEM_MINIZIP
|
|
24
26
|
endif
|
25
27
|
ifndef USE_STANDARD_TMPFILE
|
26
28
|
$(Q)$(MAKE) -C third_party/tmpfileplus
|
29
|
+
endif
|
30
|
+
ifndef USE_NO_MD5
|
31
|
+
$(Q)$(MAKE) -C third_party/md5
|
27
32
|
endif
|
28
33
|
$(Q)$(MAKE) -C src
|
29
34
|
|
@@ -41,15 +46,18 @@ clean :
|
|
41
46
|
$(Q)rm -rf test/functional/__pycache__
|
42
47
|
$(Q)rm -f test/functional/*.pyc
|
43
48
|
$(Q)rm -f lib/*
|
44
|
-
ifndef
|
49
|
+
ifndef USE_SYSTEM_MINIZIP
|
45
50
|
$(Q)$(MAKE) clean -C third_party/minizip
|
46
51
|
endif
|
47
52
|
ifndef USE_STANDARD_TMPFILE
|
48
53
|
$(Q)$(MAKE) clean -C third_party/tmpfileplus
|
49
54
|
endif
|
55
|
+
ifndef USE_NO_MD5
|
56
|
+
$(Q)$(MAKE) clean -C third_party/md5
|
57
|
+
endif
|
50
58
|
|
51
59
|
# Run the unit tests.
|
52
|
-
test : all test_functional
|
60
|
+
test : all test_unit test_functional
|
53
61
|
|
54
62
|
# Test for C++ const correctness on APIs.
|
55
63
|
test_const : all
|
@@ -60,7 +68,7 @@ test_const : all
|
|
60
68
|
# Run the functional tests.
|
61
69
|
test_functional : all
|
62
70
|
$(Q)$(MAKE) -C test/functional/src
|
63
|
-
$(Q)$(PYTEST) test/functional -v
|
71
|
+
$(Q)$(PYTEST) test/functional -v -k $(PYTESTFILES)
|
64
72
|
|
65
73
|
# Run all tests.
|
66
74
|
test_unit :
|
@@ -70,10 +78,26 @@ ifndef USE_SYSTEM_MINIZIP
|
|
70
78
|
endif
|
71
79
|
ifndef USE_STANDARD_TMPFILE
|
72
80
|
$(Q)$(MAKE) -C third_party/tmpfileplus
|
81
|
+
endif
|
82
|
+
ifndef USE_NO_MD5
|
83
|
+
$(Q)$(MAKE) -C third_party/md5
|
73
84
|
endif
|
74
85
|
$(Q)$(MAKE) -C src test_lib
|
75
86
|
$(Q)$(MAKE) -C test/unit test
|
76
87
|
|
88
|
+
# Test Cmake. This test should really be done with Cmake in the cmake dir but
|
89
|
+
# this is a workaround for now.
|
90
|
+
test_cmake :
|
91
|
+
ifneq ($(findstring m32,$(CFLAGS)),m32)
|
92
|
+
$(Q)$(MAKE) -C src clean
|
93
|
+
$(Q)cd cmake; cmake .. -DBUILD_TESTS=ON -DBUILD_EXAMPLES=ON; make clean; make; cp libxlsxwriter.a ../src/
|
94
|
+
$(Q)cmake/xlsxwriter_unit
|
95
|
+
$(Q)$(MAKE) -C test/functional/src
|
96
|
+
$(Q)$(PYTEST) test/functional -v -k $(PYTESTFILES)
|
97
|
+
else
|
98
|
+
@echo "Skipping Cmake tests on 32 bit target."
|
99
|
+
endif
|
100
|
+
|
77
101
|
# Test the functional test exes with valgrind (in 64bit mode only).
|
78
102
|
test_valgrind : all
|
79
103
|
ifndef NO_VALGRIND
|
@@ -98,17 +122,20 @@ doc: docs
|
|
98
122
|
docs:
|
99
123
|
$(Q)$(MAKE) -C docs
|
100
124
|
|
125
|
+
docs_doxygen_only:
|
126
|
+
$(Q)$(MAKE) -C docs docs_doxygen_only
|
127
|
+
|
101
128
|
# Simple minded install.
|
102
129
|
install: all
|
103
|
-
$(Q)mkdir -p $(
|
104
|
-
$(Q)cp -R include/* $(
|
105
|
-
$(Q)mkdir -p $(
|
106
|
-
$(Q)cp lib/* $(
|
130
|
+
$(Q)mkdir -p $(DESTDIR)$(PREFIX)/include
|
131
|
+
$(Q)cp -R include/* $(DESTDIR)$(PREFIX)/include
|
132
|
+
$(Q)mkdir -p $(DESTDIR)$(PREFIX)/lib
|
133
|
+
$(Q)cp lib/* $(DESTDIR)$(PREFIX)/lib
|
107
134
|
|
108
135
|
# Simpler minded uninstall.
|
109
136
|
uninstall:
|
110
|
-
$(Q)rm -rf $(
|
111
|
-
$(Q)rm $(
|
137
|
+
$(Q)rm -rf $(DESTDIR)$(PREFIX)/include/xlsxwriter*
|
138
|
+
$(Q)rm $(DESTDIR)$(PREFIX)/lib/libxlsxwriter.*
|
112
139
|
|
113
140
|
# Strip the lib files.
|
114
141
|
strip:
|
@@ -121,12 +148,15 @@ ifndef USE_SYSTEM_MINIZIP
|
|
121
148
|
endif
|
122
149
|
ifndef USE_STANDARD_TMPFILE
|
123
150
|
$(Q)$(MAKE) -C third_party/tmpfileplus
|
151
|
+
endif
|
152
|
+
ifndef USE_NO_MD5
|
153
|
+
$(Q)$(MAKE) -C third_party/md5
|
124
154
|
endif
|
125
155
|
$(Q)$(MAKE) -C src clean
|
126
156
|
$(Q)rm -f lib/*
|
127
157
|
$(Q)rm -rf cov-int
|
128
158
|
$(Q)rm -f libxlsxwriter-coverity.tgz
|
129
|
-
$(Q)../../cov-analysis-linux64-
|
159
|
+
$(Q)../../cov-analysis-linux64-2019.03/bin/cov-build --dir cov-int make -C src libxlsxwriter.a
|
130
160
|
$(Q)tar -czf libxlsxwriter-coverity.tgz cov-int
|
131
161
|
$(Q)$(MAKE) -C src clean
|
132
162
|
$(Q)rm -f lib/*
|
@@ -138,6 +168,9 @@ ifndef USE_SYSTEM_MINIZIP
|
|
138
168
|
endif
|
139
169
|
ifndef USE_STANDARD_TMPFILE
|
140
170
|
$(Q)$(MAKE) -C third_party/tmpfileplus
|
171
|
+
endif
|
172
|
+
ifndef USE_NO_MD5
|
173
|
+
$(Q)$(MAKE) -C third_party/md5
|
141
174
|
endif
|
142
175
|
$(Q)$(MAKE) -C src clean
|
143
176
|
$(Q)rm -f lib/*
|
@@ -152,6 +185,7 @@ spellcheck:
|
|
152
185
|
$(Q)for f in examples/*.c; do aspell --lang=en_US --check $$f; done
|
153
186
|
$(Q)aspell --lang=en_US --check Changes.txt
|
154
187
|
$(Q)aspell --lang=en_US --check Readme.md
|
188
|
+
$(Q)aspell --lang=en_US --check docs/src/examples.txt
|
155
189
|
|
156
190
|
releasecheck:
|
157
191
|
$(Q)dev/release/release_check.sh
|