xlsxwriter 0.0.3 → 0.0.4.pre.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ext/xlsxwriter/libxlsxwriter/{LICENSE.txt → License.txt} +64 -3
- data/ext/xlsxwriter/libxlsxwriter/Makefile +42 -7
- data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter.h +1 -1
- data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/app.h +2 -2
- data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/chart.h +2481 -97
- data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/common.h +41 -2
- data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/core.h +1 -1
- data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/format.h +5 -5
- data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/packager.h +8 -3
- data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/styles.h +1 -1
- data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/utility.h +1 -0
- data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/workbook.h +2 -2
- data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/worksheet.h +381 -1
- data/ext/xlsxwriter/libxlsxwriter/src/Makefile +25 -5
- data/ext/xlsxwriter/libxlsxwriter/src/app.c +17 -13
- data/ext/xlsxwriter/libxlsxwriter/src/chart.c +3903 -976
- data/ext/xlsxwriter/libxlsxwriter/src/content_types.c +18 -14
- data/ext/xlsxwriter/libxlsxwriter/src/core.c +9 -9
- data/ext/xlsxwriter/libxlsxwriter/src/format.c +2 -2
- data/ext/xlsxwriter/libxlsxwriter/src/packager.c +179 -95
- data/ext/xlsxwriter/libxlsxwriter/src/relationships.c +11 -8
- data/ext/xlsxwriter/libxlsxwriter/src/shared_strings.c +2 -0
- data/ext/xlsxwriter/libxlsxwriter/src/styles.c +10 -8
- data/ext/xlsxwriter/libxlsxwriter/src/utility.c +18 -1
- data/ext/xlsxwriter/libxlsxwriter/src/workbook.c +41 -25
- data/ext/xlsxwriter/libxlsxwriter/src/worksheet.c +672 -42
- data/ext/xlsxwriter/libxlsxwriter/third_party/minizip/Makefile +6 -1
- data/lib/xlsxwriter/version.rb +1 -1
- data/lib/xlsxwriter/worksheet.rb +11 -5
- metadata +6 -6
@@ -16,8 +16,8 @@
|
|
16
16
|
#define __LXW_COMMON_H__
|
17
17
|
|
18
18
|
#include <time.h>
|
19
|
-
#include "
|
20
|
-
#include "
|
19
|
+
#include "third_party/queue.h"
|
20
|
+
#include "third_party/tree.h"
|
21
21
|
|
22
22
|
#ifndef TESTING
|
23
23
|
#define STATIC static
|
@@ -89,6 +89,9 @@ typedef enum lxw_error {
|
|
89
89
|
/** Worksheet name is already in use. */
|
90
90
|
LXW_ERROR_SHEETNAME_ALREADY_USED,
|
91
91
|
|
92
|
+
/** Parameter exceeds Excel's limit of 32 characters. */
|
93
|
+
LXW_ERROR_32_STRING_LENGTH_EXCEEDED,
|
94
|
+
|
92
95
|
/** Parameter exceeds Excel's limit of 128 characters. */
|
93
96
|
LXW_ERROR_128_STRING_LENGTH_EXCEEDED,
|
94
97
|
|
@@ -223,6 +226,42 @@ enum lxw_custom_property_types {
|
|
223
226
|
#define LXW_WARN_FORMAT2(message, var1, var2) \
|
224
227
|
fprintf(stderr, "[WARNING]: " message "\n", var1, var2)
|
225
228
|
|
229
|
+
/* Chart axis type checks. */
|
230
|
+
#define LXW_WARN_CAT_AXIS_ONLY(function) \
|
231
|
+
if (!axis->is_category) { \
|
232
|
+
fprintf(stderr, "[WARNING]: " \
|
233
|
+
function "() is only valid for category axes\n"); \
|
234
|
+
return; \
|
235
|
+
}
|
236
|
+
|
237
|
+
#define LXW_WARN_VALUE_AXIS_ONLY(function) \
|
238
|
+
if (!axis->is_value) { \
|
239
|
+
fprintf(stderr, "[WARNING]: " \
|
240
|
+
function "() is only valid for value axes\n"); \
|
241
|
+
return; \
|
242
|
+
}
|
243
|
+
|
244
|
+
#define LXW_WARN_DATE_AXIS_ONLY(function) \
|
245
|
+
if (!axis->is_date) { \
|
246
|
+
fprintf(stderr, "[WARNING]: " \
|
247
|
+
function "() is only valid for date axes\n"); \
|
248
|
+
return; \
|
249
|
+
}
|
250
|
+
|
251
|
+
#define LXW_WARN_CAT_AND_DATE_AXIS_ONLY(function) \
|
252
|
+
if (!axis->is_category && !axis->is_date) { \
|
253
|
+
fprintf(stderr, "[WARNING]: " \
|
254
|
+
function "() is only valid for category and date axes\n"); \
|
255
|
+
return; \
|
256
|
+
}
|
257
|
+
|
258
|
+
#define LXW_WARN_VALUE_AND_DATE_AXIS_ONLY(function) \
|
259
|
+
if (!axis->is_value && !axis->is_date) { \
|
260
|
+
fprintf(stderr, "[WARNING]: " \
|
261
|
+
function "() is only valid for value and date axes\n"); \
|
262
|
+
return; \
|
263
|
+
}
|
264
|
+
|
226
265
|
#ifndef LXW_BIG_ENDIAN
|
227
266
|
#define LXW_UINT32_NETWORK(n) ((((n) & 0xFF) << 24) | \
|
228
267
|
(((n) & 0xFF00) << 8) | \
|
@@ -81,8 +81,8 @@ typedef int32_t lxw_color_t;
|
|
81
81
|
#define LXW_PROPERTY_UNSET -1
|
82
82
|
#define LXW_COLOR_UNSET -1
|
83
83
|
#define LXW_COLOR_MASK 0xFFFFFF
|
84
|
-
#define LXW_MIN_FONT_SIZE 1
|
85
|
-
#define LXW_MAX_FONT_SIZE 409
|
84
|
+
#define LXW_MIN_FONT_SIZE 1.0
|
85
|
+
#define LXW_MAX_FONT_SIZE 409.0
|
86
86
|
|
87
87
|
#define LXW_FORMAT_FIELD_COPY(dst, src) \
|
88
88
|
do{ \
|
@@ -360,7 +360,7 @@ typedef struct lxw_format {
|
|
360
360
|
uint16_t font_index;
|
361
361
|
uint8_t has_font;
|
362
362
|
uint8_t has_dxf_font;
|
363
|
-
|
363
|
+
double font_size;
|
364
364
|
uint8_t bold;
|
365
365
|
uint8_t italic;
|
366
366
|
lxw_color_t font_color;
|
@@ -427,7 +427,7 @@ typedef struct lxw_format {
|
|
427
427
|
typedef struct lxw_font {
|
428
428
|
|
429
429
|
char font_name[LXW_FORMAT_FIELD_LEN];
|
430
|
-
|
430
|
+
double font_size;
|
431
431
|
uint8_t bold;
|
432
432
|
uint8_t italic;
|
433
433
|
uint8_t underline;
|
@@ -529,7 +529,7 @@ void format_set_font_name(lxw_format *format, const char *font_name);
|
|
529
529
|
* size in the row. You can also explicitly specify the height of a
|
530
530
|
* row using the worksheet_set_row() function.
|
531
531
|
*/
|
532
|
-
void format_set_font_size(lxw_format *format,
|
532
|
+
void format_set_font_size(lxw_format *format, double size);
|
533
533
|
|
534
534
|
/**
|
535
535
|
* @brief Set the color of the font used in the cell.
|
@@ -10,7 +10,12 @@
|
|
10
10
|
#define __LXW_PACKAGER_H__
|
11
11
|
|
12
12
|
#include <stdint.h>
|
13
|
-
|
13
|
+
|
14
|
+
#ifdef USE_SYSTEM_MINIZIP
|
15
|
+
#include "minizip/zip.h"
|
16
|
+
#else
|
17
|
+
#include "third_party/zip.h"
|
18
|
+
#endif
|
14
19
|
|
15
20
|
#include "common.h"
|
16
21
|
#include "workbook.h"
|
@@ -27,7 +32,7 @@
|
|
27
32
|
|
28
33
|
#define LXW_ZIP_BUFFER_SIZE (16384)
|
29
34
|
|
30
|
-
/*
|
35
|
+
/* If zlib returns Z_ERRNO then errno is set and we can trap that. Otherwise
|
31
36
|
* return a default libxlsxwriter error. */
|
32
37
|
#define RETURN_ON_ZIP_ERROR(err, default_err) \
|
33
38
|
if (err == Z_ERRNO) \
|
@@ -64,7 +69,7 @@ extern "C" {
|
|
64
69
|
|
65
70
|
lxw_packager *lxw_packager_new(const char *filename, char *tmpdir);
|
66
71
|
void lxw_packager_free(lxw_packager *packager);
|
67
|
-
|
72
|
+
lxw_error lxw_create_package(lxw_packager *self);
|
68
73
|
|
69
74
|
/* Declarations required for unit testing. */
|
70
75
|
#ifdef TESTING
|
@@ -46,7 +46,7 @@ void lxw_styles_assemble_xml_file(lxw_styles *self);
|
|
46
46
|
|
47
47
|
STATIC void _styles_xml_declaration(lxw_styles *self);
|
48
48
|
STATIC void _write_style_sheet(lxw_styles *self);
|
49
|
-
STATIC void _write_font_size(lxw_styles *self,
|
49
|
+
STATIC void _write_font_size(lxw_styles *self, double font_size);
|
50
50
|
STATIC void _write_font_color_theme(lxw_styles *self, uint8_t theme);
|
51
51
|
STATIC void _write_font_name(lxw_styles *self, const char *font_name);
|
52
52
|
STATIC void _write_font_family(lxw_styles *self, uint8_t font_family);
|
@@ -145,6 +145,7 @@ uint16_t lxw_name_to_col_2(const char *col_str);
|
|
145
145
|
double lxw_datetime_to_excel_date(lxw_datetime *datetime, uint8_t date_1904);
|
146
146
|
|
147
147
|
char *lxw_strdup(const char *str);
|
148
|
+
char *lxw_strdup_formula(const char *formula);
|
148
149
|
|
149
150
|
size_t lxw_utf8_strlen(const char *str);
|
150
151
|
|
@@ -671,8 +671,8 @@ lxw_error workbook_define_name(lxw_workbook *workbook, const char *name,
|
|
671
671
|
/**
|
672
672
|
* @brief Get a worksheet object from its name.
|
673
673
|
*
|
674
|
-
* @param workbook
|
675
|
-
* @param name
|
674
|
+
* @param workbook Pointer to a lxw_workbook instance.
|
675
|
+
* @param name Worksheet name.
|
676
676
|
*
|
677
677
|
* @return A lxw_worksheet object.
|
678
678
|
*
|
@@ -76,14 +76,131 @@
|
|
76
76
|
enum lxw_gridlines {
|
77
77
|
/** Hide screen and print gridlines. */
|
78
78
|
LXW_HIDE_ALL_GRIDLINES = 0,
|
79
|
+
|
79
80
|
/** Show screen gridlines. */
|
80
81
|
LXW_SHOW_SCREEN_GRIDLINES,
|
82
|
+
|
81
83
|
/** Show print gridlines. */
|
82
84
|
LXW_SHOW_PRINT_GRIDLINES,
|
85
|
+
|
83
86
|
/** Show screen and print gridlines. */
|
84
87
|
LXW_SHOW_ALL_GRIDLINES
|
85
88
|
};
|
86
89
|
|
90
|
+
/** Data validation property values. */
|
91
|
+
enum lxw_validation_boolean {
|
92
|
+
LXW_VALIDATION_DEFAULT,
|
93
|
+
|
94
|
+
/** Turn a data validation property off. */
|
95
|
+
LXW_VALIDATION_OFF,
|
96
|
+
|
97
|
+
/** Turn a data validation property on. Data validation properties are
|
98
|
+
* generally on by default. */
|
99
|
+
LXW_VALIDATION_ON
|
100
|
+
};
|
101
|
+
|
102
|
+
/** Data validation types. */
|
103
|
+
enum lxw_validation_types {
|
104
|
+
LXW_VALIDATION_TYPE_NONE,
|
105
|
+
|
106
|
+
/** Restrict cell input to whole/integer numbers only. */
|
107
|
+
LXW_VALIDATION_TYPE_INTEGER,
|
108
|
+
|
109
|
+
/** Restrict cell input to whole/integer numbers only, using a cell
|
110
|
+
* reference. */
|
111
|
+
LXW_VALIDATION_TYPE_INTEGER_FORMULA,
|
112
|
+
|
113
|
+
/** Restrict cell input to decimal numbers only. */
|
114
|
+
LXW_VALIDATION_TYPE_DECIMAL,
|
115
|
+
|
116
|
+
/** Restrict cell input to decimal numbers only, using a cell
|
117
|
+
* reference. */
|
118
|
+
LXW_VALIDATION_TYPE_DECIMAL_FORMULA,
|
119
|
+
|
120
|
+
/** Restrict cell input to a list of strings in a dropdown. */
|
121
|
+
LXW_VALIDATION_TYPE_LIST,
|
122
|
+
|
123
|
+
/** Restrict cell input to a list of strings in a dropdown, using a
|
124
|
+
* cell range. */
|
125
|
+
LXW_VALIDATION_TYPE_LIST_FORMULA,
|
126
|
+
|
127
|
+
/** Restrict cell input to date values only, using a lxw_datetime type. */
|
128
|
+
LXW_VALIDATION_TYPE_DATE,
|
129
|
+
|
130
|
+
/** Restrict cell input to date values only, using a cell reference. */
|
131
|
+
LXW_VALIDATION_TYPE_DATE_FORMULA,
|
132
|
+
|
133
|
+
/* Restrict cell input to date values only, as a serial number.
|
134
|
+
* Undocumented. */
|
135
|
+
LXW_VALIDATION_TYPE_DATE_NUMBER,
|
136
|
+
|
137
|
+
/** Restrict cell input to time values only, using a lxw_datetime type. */
|
138
|
+
LXW_VALIDATION_TYPE_TIME,
|
139
|
+
|
140
|
+
/** Restrict cell input to time values only, using a cell reference. */
|
141
|
+
LXW_VALIDATION_TYPE_TIME_FORMULA,
|
142
|
+
|
143
|
+
/* Restrict cell input to time values only, as a serial number.
|
144
|
+
* Undocumented. */
|
145
|
+
LXW_VALIDATION_TYPE_TIME_NUMBER,
|
146
|
+
|
147
|
+
/** Restrict cell input to strings of defined length, using a cell
|
148
|
+
* reference. */
|
149
|
+
LXW_VALIDATION_TYPE_LENGTH,
|
150
|
+
|
151
|
+
/** Restrict cell input to strings of defined length, using a cell
|
152
|
+
* reference. */
|
153
|
+
LXW_VALIDATION_TYPE_LENGTH_FORMULA,
|
154
|
+
|
155
|
+
/** Restrict cell to input controlled by a custom formula that returns
|
156
|
+
* `TRUE/FALSE`. */
|
157
|
+
LXW_VALIDATION_TYPE_CUSTOM_FORMULA,
|
158
|
+
|
159
|
+
/** Allow any type of input. Mainly only useful for pop-up messages. */
|
160
|
+
LXW_VALIDATION_TYPE_ANY
|
161
|
+
};
|
162
|
+
|
163
|
+
/** Data validation criteria uses to control the selection of data. */
|
164
|
+
enum lxw_validation_criteria {
|
165
|
+
LXW_VALIDATION_CRITERIA_NONE,
|
166
|
+
|
167
|
+
/** Select data between two values. */
|
168
|
+
LXW_VALIDATION_CRITERIA_BETWEEN,
|
169
|
+
|
170
|
+
/** Select data that is not between two values. */
|
171
|
+
LXW_VALIDATION_CRITERIA_NOT_BETWEEN,
|
172
|
+
|
173
|
+
/** Select data equal to a value. */
|
174
|
+
LXW_VALIDATION_CRITERIA_EQUAL_TO,
|
175
|
+
|
176
|
+
/** Select data not equal to a value. */
|
177
|
+
LXW_VALIDATION_CRITERIA_NOT_EQUAL_TO,
|
178
|
+
|
179
|
+
/** Select data greater than a value. */
|
180
|
+
LXW_VALIDATION_CRITERIA_GREATER_THAN,
|
181
|
+
|
182
|
+
/** Select data less than a value. */
|
183
|
+
LXW_VALIDATION_CRITERIA_LESS_THAN,
|
184
|
+
|
185
|
+
/** Select data greater than or equal to a value. */
|
186
|
+
LXW_VALIDATION_CRITERIA_GREATER_THAN_OR_EQUAL_TO,
|
187
|
+
|
188
|
+
/** Select data less than or equal to a value. */
|
189
|
+
LXW_VALIDATION_CRITERIA_LESS_THAN_OR_EQUAL_TO
|
190
|
+
};
|
191
|
+
|
192
|
+
/** Data validation error types for pop-up messages. */
|
193
|
+
enum lxw_validation_error_types {
|
194
|
+
/** Show a "Stop" data validation pop-up message. This is the default. */
|
195
|
+
LXW_VALIDATION_ERROR_TYPE_STOP,
|
196
|
+
|
197
|
+
/** Show an "Error" data validation pop-up message. */
|
198
|
+
LXW_VALIDATION_ERROR_TYPE_WARNING,
|
199
|
+
|
200
|
+
/** Show an "Information" data validation pop-up message. */
|
201
|
+
LXW_VALIDATION_ERROR_TYPE_INFORMATION
|
202
|
+
};
|
203
|
+
|
87
204
|
enum cell_types {
|
88
205
|
NUMBER_CELL = 1,
|
89
206
|
STRING_CELL,
|
@@ -140,6 +257,7 @@ struct lxw_table_rows {
|
|
140
257
|
|
141
258
|
STAILQ_HEAD(lxw_merged_ranges, lxw_merged_range);
|
142
259
|
STAILQ_HEAD(lxw_selections, lxw_selection);
|
260
|
+
STAILQ_HEAD(lxw_data_validations, lxw_data_validation);
|
143
261
|
STAILQ_HEAD(lxw_image_data, lxw_image_options);
|
144
262
|
STAILQ_HEAD(lxw_chart_data, lxw_image_options);
|
145
263
|
|
@@ -229,6 +347,180 @@ typedef struct lxw_selection {
|
|
229
347
|
|
230
348
|
} lxw_selection;
|
231
349
|
|
350
|
+
/**
|
351
|
+
* @brief Worksheet data validation options.
|
352
|
+
*/
|
353
|
+
typedef struct lxw_data_validation {
|
354
|
+
|
355
|
+
/**
|
356
|
+
* Set the validation type. Should be a #lxw_validation_types value.
|
357
|
+
*/
|
358
|
+
uint8_t validate;
|
359
|
+
|
360
|
+
/**
|
361
|
+
* Set the validation criteria type to select the data. Should be a
|
362
|
+
* #lxw_validation_criteria value.
|
363
|
+
*/
|
364
|
+
uint8_t criteria;
|
365
|
+
|
366
|
+
/** Controls whether a data validation is not applied to blank data in the
|
367
|
+
* cell. Should be a #lxw_validation_boolean value. It is on by
|
368
|
+
* default.
|
369
|
+
*/
|
370
|
+
uint8_t ignore_blank;
|
371
|
+
|
372
|
+
/**
|
373
|
+
* This parameter is used to toggle on and off the 'Show input message
|
374
|
+
* when cell is selected' option in the Excel data validation dialog. When
|
375
|
+
* the option is off an input message is not displayed even if it has been
|
376
|
+
* set using input_message. Should be a #lxw_validation_boolean value. It
|
377
|
+
* is on by default.
|
378
|
+
*/
|
379
|
+
uint8_t show_input;
|
380
|
+
|
381
|
+
/**
|
382
|
+
* This parameter is used to toggle on and off the 'Show error alert
|
383
|
+
* after invalid data is entered' option in the Excel data validation
|
384
|
+
* dialog. When the option is off an error message is not displayed even
|
385
|
+
* if it has been set using error_message. Should be a
|
386
|
+
* #lxw_validation_boolean value. It is on by default.
|
387
|
+
*/
|
388
|
+
uint8_t show_error;
|
389
|
+
|
390
|
+
/**
|
391
|
+
* This parameter is used to specify the type of error dialog that is
|
392
|
+
* displayed. Should be a #lxw_validation_error_types value.
|
393
|
+
*/
|
394
|
+
uint8_t error_type;
|
395
|
+
|
396
|
+
/**
|
397
|
+
* This parameter is used to toggle on and off the 'In-cell dropdown'
|
398
|
+
* option in the Excel data validation dialog. When the option is on a
|
399
|
+
* dropdown list will be shown for list validations. Should be a
|
400
|
+
* #lxw_validation_boolean value. It is on by default.
|
401
|
+
*/
|
402
|
+
uint8_t dropdown;
|
403
|
+
|
404
|
+
uint8_t is_between;
|
405
|
+
|
406
|
+
/**
|
407
|
+
* This parameter is used to set the limiting value to which the criteria
|
408
|
+
* is applied using a whole or decimal number.
|
409
|
+
*/
|
410
|
+
double value_number;
|
411
|
+
|
412
|
+
/**
|
413
|
+
* This parameter is used to set the limiting value to which the criteria
|
414
|
+
* is applied using a cell reference. It is valid for any of the
|
415
|
+
* `_FORMULA` validation types.
|
416
|
+
*/
|
417
|
+
char *value_formula;
|
418
|
+
|
419
|
+
/**
|
420
|
+
* This parameter is used to set a list of strings for a drop down list.
|
421
|
+
* The list should be a `NULL` terminated array of char* strings:
|
422
|
+
*
|
423
|
+
* @code
|
424
|
+
* char *list[] = {"open", "high", "close", NULL};
|
425
|
+
*
|
426
|
+
* data_validation->validate = LXW_VALIDATION_TYPE_LIST;
|
427
|
+
* data_validation->value_list = list;
|
428
|
+
* @endcode
|
429
|
+
*
|
430
|
+
* The `value_formula` parameter can also be used to specify a list from
|
431
|
+
* an Excel cell range.
|
432
|
+
*
|
433
|
+
* Note, the string list is restricted by Excel to 255 characters,
|
434
|
+
* including comma separators.
|
435
|
+
*/
|
436
|
+
char **value_list;
|
437
|
+
|
438
|
+
/**
|
439
|
+
* This parameter is used to set the limiting value to which the date or
|
440
|
+
* time criteria is applied using a #lxw_datetime struct.
|
441
|
+
*/
|
442
|
+
lxw_datetime value_datetime;
|
443
|
+
|
444
|
+
/**
|
445
|
+
* This parameter is the same as `value_number` but for the minimum value
|
446
|
+
* when a `BETWEEN` criteria is used.
|
447
|
+
*/
|
448
|
+
double minimum_number;
|
449
|
+
|
450
|
+
/**
|
451
|
+
* This parameter is the same as `value_formula` but for the minimum value
|
452
|
+
* when a `BETWEEN` criteria is used.
|
453
|
+
*/
|
454
|
+
char *minimum_formula;
|
455
|
+
|
456
|
+
/**
|
457
|
+
* This parameter is the same as `value_datetime` but for the minimum value
|
458
|
+
* when a `BETWEEN` criteria is used.
|
459
|
+
*/
|
460
|
+
lxw_datetime minimum_datetime;
|
461
|
+
|
462
|
+
/**
|
463
|
+
* This parameter is the same as `value_number` but for the maximum value
|
464
|
+
* when a `BETWEEN` criteria is used.
|
465
|
+
*/
|
466
|
+
double maximum_number;
|
467
|
+
|
468
|
+
/**
|
469
|
+
* This parameter is the same as `value_formula` but for the maximum value
|
470
|
+
* when a `BETWEEN` criteria is used.
|
471
|
+
*/
|
472
|
+
char *maximum_formula;
|
473
|
+
|
474
|
+
/**
|
475
|
+
* This parameter is the same as `value_datetime` but for the maximum value
|
476
|
+
* when a `BETWEEN` criteria is used.
|
477
|
+
*/
|
478
|
+
lxw_datetime maximum_datetime;
|
479
|
+
|
480
|
+
/**
|
481
|
+
* The input_title parameter is used to set the title of the input message
|
482
|
+
* that is displayed when a cell is entered. It has no default value and
|
483
|
+
* is only displayed if the input message is displayed. See the
|
484
|
+
* `input_message` parameter below.
|
485
|
+
*
|
486
|
+
* The maximum title length is 32 characters.
|
487
|
+
*/
|
488
|
+
char *input_title;
|
489
|
+
|
490
|
+
/**
|
491
|
+
* The input_message parameter is used to set the input message that is
|
492
|
+
* displayed when a cell is entered. It has no default value.
|
493
|
+
*
|
494
|
+
* The message can be split over several lines using newlines. The maximum
|
495
|
+
* message length is 255 characters.
|
496
|
+
*/
|
497
|
+
char *input_message;
|
498
|
+
|
499
|
+
/**
|
500
|
+
* The error_title parameter is used to set the title of the error message
|
501
|
+
* that is displayed when the data validation criteria is not met. The
|
502
|
+
* default error title is 'Microsoft Excel'. The maximum title length is
|
503
|
+
* 32 characters.
|
504
|
+
*/
|
505
|
+
char *error_title;
|
506
|
+
|
507
|
+
/**
|
508
|
+
* The error_message parameter is used to set the error message that is
|
509
|
+
* displayed when a cell is entered. The default error message is "The
|
510
|
+
* value you entered is not valid. A user has restricted values that can
|
511
|
+
* be entered into the cell".
|
512
|
+
*
|
513
|
+
* The message can be split over several lines using newlines. The maximum
|
514
|
+
* message length is 255 characters.
|
515
|
+
*/
|
516
|
+
char *error_message;
|
517
|
+
|
518
|
+
char sqref[LXW_MAX_CELL_RANGE_LENGTH];
|
519
|
+
|
520
|
+
STAILQ_ENTRY (lxw_data_validation) list_pointers;
|
521
|
+
|
522
|
+
} lxw_data_validation;
|
523
|
+
|
232
524
|
/**
|
233
525
|
* @brief Options for inserted images
|
234
526
|
*
|
@@ -354,6 +646,7 @@ typedef struct lxw_worksheet {
|
|
354
646
|
struct lxw_cell **array;
|
355
647
|
struct lxw_merged_ranges *merged_ranges;
|
356
648
|
struct lxw_selections *selections;
|
649
|
+
struct lxw_data_validations *data_validations;
|
357
650
|
struct lxw_image_data *image_data;
|
358
651
|
struct lxw_chart_data *chart_data;
|
359
652
|
|
@@ -416,6 +709,7 @@ typedef struct lxw_worksheet {
|
|
416
709
|
uint8_t vba_codename;
|
417
710
|
uint8_t vcenter;
|
418
711
|
uint8_t zoom_scale_normal;
|
712
|
+
uint8_t num_validations;
|
419
713
|
|
420
714
|
lxw_color_t tab_color;
|
421
715
|
|
@@ -561,6 +855,10 @@ extern "C" {
|
|
561
855
|
*
|
562
856
|
* @image html write_number02.png
|
563
857
|
*
|
858
|
+
* @note Excel doesn't support `NaN`, `Inf` or `-Inf` as a number value. If
|
859
|
+
* you are writing data that contains these values then your application
|
860
|
+
* should convert them to a string or handle them in some other way.
|
861
|
+
*
|
564
862
|
*/
|
565
863
|
lxw_error worksheet_write_number(lxw_worksheet *worksheet,
|
566
864
|
lxw_row_t row,
|
@@ -669,7 +967,7 @@ lxw_error worksheet_write_formula(lxw_worksheet *worksheet,
|
|
669
967
|
/**
|
670
968
|
* @brief Write an array formula to a worksheet cell.
|
671
969
|
*
|
672
|
-
* @param worksheet
|
970
|
+
* @param worksheet pointer to a lxw_worksheet instance to be updated.
|
673
971
|
* @param first_row The first row of the range. (All zero indexed.)
|
674
972
|
* @param first_col The first column of the range.
|
675
973
|
* @param last_row The last row of the range.
|
@@ -1470,6 +1768,87 @@ lxw_error worksheet_autofilter(lxw_worksheet *worksheet, lxw_row_t first_row,
|
|
1470
1768
|
lxw_col_t first_col, lxw_row_t last_row,
|
1471
1769
|
lxw_col_t last_col);
|
1472
1770
|
|
1771
|
+
/**
|
1772
|
+
* @brief Add a data validation to a cell.
|
1773
|
+
*
|
1774
|
+
* @param worksheet Pointer to a lxw_worksheet instance to be updated.
|
1775
|
+
* @param row The zero indexed row number.
|
1776
|
+
* @param col The zero indexed column number.
|
1777
|
+
* @param validation A #lxw_data_validation object to control the validation.
|
1778
|
+
*
|
1779
|
+
* @return A #lxw_error code.
|
1780
|
+
*
|
1781
|
+
* The `%worksheet_data_validation_cell()` function is used to construct an
|
1782
|
+
* Excel data validation or to limit the user input to a dropdown list of
|
1783
|
+
* values:
|
1784
|
+
*
|
1785
|
+
* @code
|
1786
|
+
*
|
1787
|
+
* lxw_data_validation *data_validation = calloc(1, sizeof(lxw_data_validation));
|
1788
|
+
*
|
1789
|
+
* data_validation->validate = LXW_VALIDATION_TYPE_INTEGER;
|
1790
|
+
* data_validation->criteria = LXW_VALIDATION_CRITERIA_BETWEEN;
|
1791
|
+
* data_validation->minimum_number = 1;
|
1792
|
+
* data_validation->maximum_number = 10;
|
1793
|
+
*
|
1794
|
+
* worksheet_data_validation_cell(worksheet, 2, 1, data_validation);
|
1795
|
+
*
|
1796
|
+
* // Same as above with the CELL() macro.
|
1797
|
+
* worksheet_data_validation_cell(worksheet, CELL("B3"), data_validation);
|
1798
|
+
*
|
1799
|
+
* @endcode
|
1800
|
+
*
|
1801
|
+
* @image html data_validate4.png
|
1802
|
+
*
|
1803
|
+
* Data validation and the various options of #lxw_data_validation are
|
1804
|
+
* described in more detail in @ref working_with_data_validation.
|
1805
|
+
*/
|
1806
|
+
lxw_error worksheet_data_validation_cell(lxw_worksheet *worksheet,
|
1807
|
+
lxw_row_t row, lxw_col_t col,
|
1808
|
+
lxw_data_validation *validation);
|
1809
|
+
|
1810
|
+
/**
|
1811
|
+
* @brief Add a data validation to a range cell.
|
1812
|
+
*
|
1813
|
+
* @param worksheet Pointer to a lxw_worksheet instance to be updated.
|
1814
|
+
* @param first_row The first row of the range. (All zero indexed.)
|
1815
|
+
* @param first_col The first column of the range.
|
1816
|
+
* @param last_row The last row of the range.
|
1817
|
+
* @param last_col The last col of the range.
|
1818
|
+
* @param validation A #lxw_data_validation object to control the validation.
|
1819
|
+
*
|
1820
|
+
* @return A #lxw_error code.
|
1821
|
+
*
|
1822
|
+
* The `%worksheet_data_validation_range()` function is the same as the
|
1823
|
+
* `%worksheet_data_validation_cell()`, see above, except the data validation
|
1824
|
+
* is applied to a range of cells:
|
1825
|
+
*
|
1826
|
+
* @code
|
1827
|
+
*
|
1828
|
+
* lxw_data_validation *data_validation = calloc(1, sizeof(lxw_data_validation));
|
1829
|
+
*
|
1830
|
+
* data_validation->validate = LXW_VALIDATION_TYPE_INTEGER;
|
1831
|
+
* data_validation->criteria = LXW_VALIDATION_CRITERIA_BETWEEN;
|
1832
|
+
* data_validation->minimum_number = 1;
|
1833
|
+
* data_validation->maximum_number = 10;
|
1834
|
+
*
|
1835
|
+
* worksheet_data_validation_range(worksheet, 2, 1, 4, 1, data_validation);
|
1836
|
+
*
|
1837
|
+
* // Same as above with the RANGE() macro.
|
1838
|
+
* worksheet_data_validation_range(worksheet, RANGE("B3:B5"), data_validation);
|
1839
|
+
*
|
1840
|
+
* @endcode
|
1841
|
+
*
|
1842
|
+
* Data validation and the various options of #lxw_data_validation are
|
1843
|
+
* described in more detail in @ref working_with_data_validation.
|
1844
|
+
*/
|
1845
|
+
lxw_error worksheet_data_validation_range(lxw_worksheet *worksheet,
|
1846
|
+
lxw_row_t first_row,
|
1847
|
+
lxw_col_t first_col,
|
1848
|
+
lxw_row_t last_row,
|
1849
|
+
lxw_col_t last_col,
|
1850
|
+
lxw_data_validation *validation);
|
1851
|
+
|
1473
1852
|
/**
|
1474
1853
|
* @brief Make a worksheet the active, i.e., visible worksheet.
|
1475
1854
|
*
|
@@ -2630,6 +3009,7 @@ STATIC void _worksheet_write_print_options(lxw_worksheet *worksheet);
|
|
2630
3009
|
STATIC void _worksheet_write_sheet_pr(lxw_worksheet *worksheet);
|
2631
3010
|
STATIC void _worksheet_write_tab_color(lxw_worksheet *worksheet);
|
2632
3011
|
STATIC void _worksheet_write_sheet_protection(lxw_worksheet *worksheet);
|
3012
|
+
STATIC void _worksheet_write_data_validations(lxw_worksheet *self);
|
2633
3013
|
#endif /* TESTING */
|
2634
3014
|
|
2635
3015
|
/* *INDENT-OFF* */
|