docs: fix minor issues in data_validate example

Closes #449
This commit is contained in:
John McNamara 2024-06-23 12:00:02 +01:00
parent 4acea2fcf8
commit 5024854a94
7 changed files with 20 additions and 20 deletions

View file

@ -20,7 +20,7 @@ It supports features such as:
- Defined names. - Defined names.
- Autofilters. - Autofilters.
- Charts. - Charts.
- Data validation and drop down lists. - Data validation and dropdown lists.
- Conditional formatting. - Conditional formatting.
- Worksheet PNG/JPEG/GIF images. - Worksheet PNG/JPEG/GIF images.
- Cell comments. - Cell comments.

View file

@ -35,7 +35,7 @@ my @examples = (
[ 'merge_range.c', 'Create a merged range of cells' ], [ 'merge_range.c', 'Create a merged range of cells' ],
[ 'merge_rich_string.c', 'Create a merged range with a rich string' ], [ 'merge_rich_string.c', 'Create a merged range with a rich string' ],
[ 'autofilter.c', 'An example of a worksheet autofilter' ], [ 'autofilter.c', 'An example of a worksheet autofilter' ],
[ 'data_validate.c', 'Examples of worksheet data validation and drop down lists' ], [ 'data_validate.c', 'Examples of worksheet data validation and dropdown lists' ],
[ 'conditional_format1.c', 'A simple conditional formatting example' ], [ 'conditional_format1.c', 'A simple conditional formatting example' ],
[ 'conditional_format2.c', 'An advanced conditional formatting example' ], [ 'conditional_format2.c', 'An advanced conditional formatting example' ],
[ 'tables.c', 'Example of table to a worksheet.' ], [ 'tables.c', 'Example of table to a worksheet.' ],

View file

@ -19,7 +19,7 @@ features such as:
- Defined names. - Defined names.
- Autofilters. - Autofilters.
- Charts. - Charts.
- Data validation and drop down lists. - Data validation and dropdown lists.
- Conditional formatting. - Conditional formatting.
- Worksheet PNG/JPEG/GIF images. - Worksheet PNG/JPEG/GIF images.
- Cell comments. - Cell comments.

View file

@ -250,7 +250,7 @@ criteria is applied using a cell reference. It is valid for any of the
`value_list`: `value_list`:
The `value_list` parameter is used to set a list of strings for a drop down The `value_list` parameter is used to set a list of strings for a dropdown
list. The list should be a `NULL` terminated array of char* strings: list. The list should be a `NULL` terminated array of char* strings:
@code @code
@ -457,13 +457,13 @@ set using `error_message`. It is on by default.
data_validation->minimum_number = 0.1; data_validation->minimum_number = 0.1;
data_validation->maximum_number = 0.5; data_validation->maximum_number = 0.5;
// Select a value from a drop down list. // Select a value from a dropdown list.
char *list[] = {"open", "high", "close", NULL}; char *list[] = {"open", "high", "close", NULL};
data_validation->validate = LXW_VALIDATION_TYPE_LIST; data_validation->validate = LXW_VALIDATION_TYPE_LIST;
data_validation->value_list = list; data_validation->value_list = list;
// Select a value from a drop down list (using a cell range). // Select a value from a dropdown list (using a cell range).
data_validation->validate = LXW_VALIDATION_TYPE_LIST; data_validation->validate = LXW_VALIDATION_TYPE_LIST;
data_validation->value_formula = "=$E$4:$G$4"; data_validation->value_formula = "=$E$4:$G$4";

View file

@ -4,7 +4,7 @@
* *
* Data validation is a feature of Excel which allows you to restrict the data * Data validation is a feature of Excel which allows you to restrict the data
* that a user enters in a cell and to display help and warning messages. It * that a user enters in a cell and to display help and warning messages. It
* also allows you to restrict input to values in a drop down list. * also allows you to restrict input to values in a dropdown list.
* *
* Copyright 2014-2021, John McNamara, jmcnamara@cpan.org * Copyright 2014-2021, John McNamara, jmcnamara@cpan.org
*/ */
@ -28,7 +28,7 @@ void write_worksheet_data(lxw_worksheet *worksheet, lxw_format *format) {
worksheet_write_number(worksheet, CELL("E3"), 1, NULL); worksheet_write_number(worksheet, CELL("E3"), 1, NULL);
worksheet_write_number(worksheet, CELL("F3"), 10, NULL); worksheet_write_number(worksheet, CELL("F3"), 10, NULL);
worksheet_write_string(worksheet, CELL("D4"), "List Data", NULL); worksheet_write_string(worksheet, CELL("D4"), "List data", NULL);
worksheet_write_string(worksheet, CELL("E4"), "open", NULL); worksheet_write_string(worksheet, CELL("E4"), "open", NULL);
worksheet_write_string(worksheet, CELL("F4"), "high", NULL); worksheet_write_string(worksheet, CELL("F4"), "high", NULL);
worksheet_write_string(worksheet, CELL("G4"), "close", NULL); worksheet_write_string(worksheet, CELL("G4"), "close", NULL);
@ -45,7 +45,7 @@ void write_worksheet_data(lxw_worksheet *worksheet, lxw_format *format) {
*/ */
int main() { int main() {
lxw_workbook *workbook = workbook_new("data_validate1.xlsx"); lxw_workbook *workbook = workbook_new("data_validate.xlsx");
lxw_worksheet *worksheet = workbook_add_worksheet(workbook, NULL); lxw_worksheet *worksheet = workbook_add_worksheet(workbook, NULL);
lxw_data_validation *data_validation = lxw_data_validation *data_validation =
(lxw_data_validation *)calloc(1, sizeof(lxw_data_validation)); (lxw_data_validation *)calloc(1, sizeof(lxw_data_validation));
@ -90,10 +90,10 @@ int main() {
*/ */
worksheet_write_string(worksheet, worksheet_write_string(worksheet,
CELL("A5"), CELL("A5"),
"Enter an integer not between 1 and 10 (using cell references)", "Enter an integer that is not between 1 and 10 (using cell references)",
NULL); NULL);
data_validation->validate = LXW_VALIDATION_TYPE_INTEGER; data_validation->validate = LXW_VALIDATION_TYPE_INTEGER_FORMULA;
data_validation->criteria = LXW_VALIDATION_CRITERIA_NOT_BETWEEN; data_validation->criteria = LXW_VALIDATION_CRITERIA_NOT_BETWEEN;
data_validation->minimum_formula = "=E3"; data_validation->minimum_formula = "=E3";
data_validation->maximum_formula = "=F3"; data_validation->maximum_formula = "=F3";
@ -152,7 +152,7 @@ int main() {
*/ */
worksheet_write_string(worksheet, worksheet_write_string(worksheet,
CELL("A13"), CELL("A13"),
"Select a value from a drop down list", "Select a value from a dropdown list",
NULL); NULL);
const char *list[] = {"open", "high", "close", NULL}; const char *list[] = {"open", "high", "close", NULL};
@ -168,7 +168,7 @@ int main() {
*/ */
worksheet_write_string(worksheet, worksheet_write_string(worksheet,
CELL("A15"), CELL("A15"),
"Select a value from a drop down list (using a cell range)", "Select a value from a dropdown list (using a cell range)",
NULL); NULL);
data_validation->validate = LXW_VALIDATION_TYPE_LIST_FORMULA; data_validation->validate = LXW_VALIDATION_TYPE_LIST_FORMULA;
@ -182,11 +182,11 @@ int main() {
*/ */
worksheet_write_string(worksheet, worksheet_write_string(worksheet,
CELL("A17"), CELL("A17"),
"Enter a date between 1/1/2008 and 12/12/2008", "Enter a date between 1/1/2024 and 12/12/2024",
NULL); NULL);
lxw_datetime datetime1 = {2008, 1, 1, 0, 0, 0}; lxw_datetime datetime1 = {2024, 1, 1, 0, 0, 0};
lxw_datetime datetime2 = {2008, 12, 12, 0, 0, 0}; lxw_datetime datetime2 = {2024, 12, 12, 0, 0, 0};
data_validation->validate = LXW_VALIDATION_TYPE_DATE; data_validation->validate = LXW_VALIDATION_TYPE_DATE;
data_validation->criteria = LXW_VALIDATION_CRITERIA_BETWEEN; data_validation->criteria = LXW_VALIDATION_CRITERIA_BETWEEN;
@ -207,7 +207,7 @@ int main() {
lxw_datetime datetime3 = {0, 0, 0, 6, 0, 0}; lxw_datetime datetime3 = {0, 0, 0, 6, 0, 0};
lxw_datetime datetime4 = {0, 0, 0, 12, 0, 0}; lxw_datetime datetime4 = {0, 0, 0, 12, 0, 0};
data_validation->validate = LXW_VALIDATION_TYPE_DATE; data_validation->validate = LXW_VALIDATION_TYPE_TIME;
data_validation->criteria = LXW_VALIDATION_CRITERIA_BETWEEN; data_validation->criteria = LXW_VALIDATION_CRITERIA_BETWEEN;
data_validation->minimum_datetime = datetime3; data_validation->minimum_datetime = datetime3;
data_validation->maximum_datetime = datetime4; data_validation->maximum_datetime = datetime4;

View file

@ -983,7 +983,7 @@ typedef struct lxw_data_validation {
const char *value_formula; const char *value_formula;
/** /**
* This parameter is used to set a list of strings for a drop down list. * This parameter is used to set a list of strings for a dropdown list.
* The list should be a `NULL` terminated array of char* strings: * The list should be a `NULL` terminated array of char* strings:
* *
* @code * @code
@ -3996,7 +3996,7 @@ lxw_error worksheet_merge_range(lxw_worksheet *worksheet, lxw_row_t first_row,
* The `%worksheet_autofilter()` function allows an autofilter to be added to * The `%worksheet_autofilter()` function allows an autofilter to be added to
* a worksheet. * a worksheet.
* *
* An autofilter is a way of adding drop down lists to the headers of a 2D * An autofilter is a way of adding dropdown lists to the headers of a 2D
* range of worksheet data. This allows users to filter the data based on * range of worksheet data. This allows users to filter the data based on
* simple criteria so that some data is shown and some is hidden. * simple criteria so that some data is shown and some is hidden.
* *

View file

@ -16,7 +16,7 @@ Pod::Spec.new do |s|
* Defined names. * Defined names.
* Autofilters. * Autofilters.
* Charts. * Charts.
* Data validation and drop down lists. * Data validation and dropdown lists.
* Conditional formatting. * Conditional formatting.
* Worksheet PNG/JPEG/GIF images. * Worksheet PNG/JPEG/GIF images.
* Cell comments. * Cell comments.