Example of adding data validations to a worksheet.
#include "xlsxwriter.h"
"Some examples of data validation in libxlsxwriter",
format);
}
int main() {
write_worksheet_data(worksheet, format);
"Enter an integer between 1 and 10",
NULL);
"Enter an integer that is not between 1 and 10 (using cell references)",
NULL);
"Enter an integer greater than 0",
NULL);
"Enter an integer less than 10",
NULL);
"Enter a decimal between 0.1 and 0.5",
NULL);
"Select a value from a dropdown list",
NULL);
const char *list[] = {"open", "high", "close", NULL};
"Select a value from a dropdown list (using a cell range)",
NULL);
"Enter a date between 1/1/2024 and 12/12/2024",
NULL);
"Enter a time between 6:00 and 12:00",
NULL);
"Enter a string longer than 3 characters",
NULL);
"Enter a value if the following is true \"=AND(F5=50,G5=60)\"",
NULL);
"Displays a message when you select the cell",
NULL);
"Display a custom error message when integer isn't between 1 and 100",
NULL);
data_validation->
error_title =
"Input value is not valid!";
data_validation->
error_message =
"It should be an integer between 1 and 100";
"Display a custom info message when integer isn't between 1 and 100",
NULL);
data_validation->
error_title =
"Input value is not valid!";
data_validation->
error_message =
"It should be an integer between 1 and 100";
free(data_validation);
}
Worksheet data validation options.
Definition: worksheet.h:923
const char * minimum_formula
Definition: worksheet.h:1022
const char * error_message
Definition: worksheet.h:1084
const char * maximum_formula
Definition: worksheet.h:1040
uint8_t validate
Definition: worksheet.h:928
const char * error_title
Definition: worksheet.h:1073
const char * input_message
Definition: worksheet.h:1065
uint8_t criteria
Definition: worksheet.h:934
const char ** value_list
Definition: worksheet.h:1004
lxw_datetime minimum_datetime
Definition: worksheet.h:1028
lxw_datetime maximum_datetime
Definition: worksheet.h:1046
const char * input_title
Definition: worksheet.h:1056
double maximum_number
Definition: worksheet.h:1034
double minimum_number
Definition: worksheet.h:1016
double value_number
Definition: worksheet.h:978
uint8_t error_type
Definition: worksheet.h:964
const char * value_formula
Definition: worksheet.h:985
Struct to represent a date and time in Excel.
Definition: common.h:159
Struct to represent an Excel workbook.
Definition: workbook.h:293
Struct to represent an Excel worksheet.
Definition: worksheet.h:2115
#define CELL(cell)
Convert an Excel A1 cell string into a (row, col) pair.
Definition: utility.h:46
lxw_workbook * workbook_new(const char *filename)
Create a new workbook object.
lxw_format * workbook_add_format(lxw_workbook *workbook)
Create a new Format object to formats cells in worksheets.
lxw_error workbook_close(lxw_workbook *workbook)
Close the Workbook object and write the XLSX file.
lxw_worksheet * workbook_add_worksheet(lxw_workbook *workbook, const char *sheetname)
Add a new worksheet to a workbook.
@ LXW_VALIDATION_TYPE_INTEGER
Definition: worksheet.h:117
@ LXW_VALIDATION_TYPE_LIST_FORMULA
Definition: worksheet.h:135
@ LXW_VALIDATION_TYPE_TIME
Definition: worksheet.h:148
@ LXW_VALIDATION_TYPE_DECIMAL
Definition: worksheet.h:124
@ LXW_VALIDATION_TYPE_LIST
Definition: worksheet.h:131
@ LXW_VALIDATION_TYPE_INTEGER_FORMULA
Definition: worksheet.h:121
@ LXW_VALIDATION_TYPE_DATE
Definition: worksheet.h:138
@ LXW_VALIDATION_TYPE_LENGTH
Definition: worksheet.h:159
@ LXW_VALIDATION_TYPE_CUSTOM_FORMULA
Definition: worksheet.h:167
lxw_error worksheet_data_validation_cell(lxw_worksheet *worksheet, lxw_row_t row, lxw_col_t col, lxw_data_validation *validation)
Add a data validation to a cell.
@ LXW_VALIDATION_ERROR_TYPE_INFORMATION
Definition: worksheet.h:211
@ LXW_VALIDATION_CRITERIA_BETWEEN
Definition: worksheet.h:178
@ LXW_VALIDATION_CRITERIA_GREATER_THAN
Definition: worksheet.h:190
@ LXW_VALIDATION_CRITERIA_NOT_BETWEEN
Definition: worksheet.h:181
@ LXW_VALIDATION_CRITERIA_LESS_THAN
Definition: worksheet.h:193
lxw_error worksheet_set_column(lxw_worksheet *worksheet, lxw_col_t first_col, lxw_col_t last_col, double width, lxw_format *format)
Set the properties for one or more columns of cells.
lxw_error worksheet_set_row(lxw_worksheet *worksheet, lxw_row_t row, double height, lxw_format *format)
Set the properties for a row of cells.
lxw_error worksheet_write_string(lxw_worksheet *worksheet, lxw_row_t row, lxw_col_t col, const char *string, lxw_format *format)
Write a string to a worksheet cell.
lxw_error worksheet_write_number(lxw_worksheet *worksheet, lxw_row_t row, lxw_col_t col, double number, lxw_format *format)
Write a number to a worksheet cell.
lxw_error worksheet_write_formula(lxw_worksheet *worksheet, lxw_row_t row, lxw_col_t col, const char *formula, lxw_format *format)
Write a formula to a worksheet cell.