[GH-ISSUE #31] Feature request: worksheet_data_validation() #26

Closed
opened 2026-05-05 11:25:44 -06:00 by gitea-mirror · 9 comments
Owner

Originally created by @jmcnamara on GitHub (Dec 10, 2015).
Original GitHub issue: https://github.com/jmcnamara/libxlsxwriter/issues/31

Originally assigned to: @jmcnamara on GitHub.

Add worksheet_data_validation() function like the Python XlsxWriter Worksheet method data_validation().
See https://xlsxwriter.readthedocs.io/working_with_data_validation.html

  • Difficulty: 4 (Easy 1 - 5 Hard)
  • Priority: 2 (High 1 - 5 Low)

Add +1 as a comment to vote for this feature and to get an update when it is implemented.

Originally created by @jmcnamara on GitHub (Dec 10, 2015). Original GitHub issue: https://github.com/jmcnamara/libxlsxwriter/issues/31 Originally assigned to: @jmcnamara on GitHub. Add `worksheet_data_validation()` function like the Python XlsxWriter Worksheet method `data_validation()`. See https://xlsxwriter.readthedocs.io/working_with_data_validation.html - Difficulty: 4 (Easy 1 - 5 Hard) - Priority: 2 (High 1 - 5 Low) Add +1 as a comment to vote for this feature and to get an update when it is implemented.
gitea-mirror 2026-05-05 11:25:44 -06:00
Author
Owner

@evanmiller commented on GitHub (Apr 26, 2017):

I'd like to put in a plug for this feature -- its absence is one of the few things keeping my code base dependent on xlsLib. Just so other users are aware, Excel's data validation is how drop-down menus are implemented for choosing among a discrete set of values.

Also @jmcnamara the correct link is: https://xlsxwriter.readthedocs.io/working_with_data_validation.html

<!-- gh-comment-id:297429291 --> @evanmiller commented on GitHub (Apr 26, 2017): I'd like to put in a plug for this feature -- its absence is one of the few things keeping my code base dependent on xlsLib. Just so other users are aware, Excel's data validation is how drop-down menus are implemented for choosing among a discrete set of values. Also @jmcnamara the correct link is: https://xlsxwriter.readthedocs.io/working_with_data_validation.html
Author
Owner

@jmcnamara commented on GitHub (Apr 26, 2017):

@evanmiller Noted.

<!-- gh-comment-id:297442256 --> @jmcnamara commented on GitHub (Apr 26, 2017): @evanmiller Noted.
Author
Owner

@jmcnamara commented on GitHub (Sep 20, 2017):

@evanmiller I've started work on data validation in libxlsxwriter. It isn't fully useable yet but you could try it out in a few days, when it is more functional. If you are interested.

If so let me know what type of data validation you want to do.

<!-- gh-comment-id:330994723 --> @jmcnamara commented on GitHub (Sep 20, 2017): @evanmiller I've started work on data validation in libxlsxwriter. It isn't fully useable yet but you could try it out in a few days, when it is more functional. If you are interested. If so let me know what type of data validation you want to do.
Author
Owner

@evanmiller commented on GitHub (Sep 20, 2017):

@jmcnamara Thanks. I'm interested in pop-up buttons -- in xlsLib I do something like

formula_t *cond1 = xlsWorksheetFormula(prediction_ws);
xlsFormulaPushCharacterArray(cond1, "FALSE\0TRUE", sizeof("FALSE\0TRUE")-1);
            
xlsWorksheetValidateCellArea(prediction_ws, first_cell, last_cell,
    DVAL_TYPE_LIST | DVAL_OP_EQUAL | DVAL_STRING_LIST_IN_FORMULA,
    cond1, NULL, NULL, NULL, NULL, NULL);
<!-- gh-comment-id:330998920 --> @evanmiller commented on GitHub (Sep 20, 2017): @jmcnamara Thanks. I'm interested in pop-up buttons -- in xlsLib I do something like ```{C} formula_t *cond1 = xlsWorksheetFormula(prediction_ws); xlsFormulaPushCharacterArray(cond1, "FALSE\0TRUE", sizeof("FALSE\0TRUE")-1); xlsWorksheetValidateCellArea(prediction_ws, first_cell, last_cell, DVAL_TYPE_LIST | DVAL_OP_EQUAL | DVAL_STRING_LIST_IN_FORMULA, cond1, NULL, NULL, NULL, NULL, NULL); ```
Author
Owner

@jmcnamara commented on GitHub (Sep 20, 2017):

This type of validation?

screen shot 2017-09-20 at 23 42 27

<!-- gh-comment-id:331002110 --> @jmcnamara commented on GitHub (Sep 20, 2017): This type of validation? ![screen shot 2017-09-20 at 23 42 27](https://user-images.githubusercontent.com/94267/30671270-e4be318c-9e5d-11e7-9b4c-f2bc6153d29f.png)
Author
Owner

@evanmiller commented on GitHub (Sep 20, 2017):

@jmcnamara Yes.

<!-- gh-comment-id:331003115 --> @evanmiller commented on GitHub (Sep 20, 2017): @jmcnamara Yes.
Author
Owner

@jmcnamara commented on GitHub (Sep 20, 2017):

@evanmiller That is currently doable with the code on the data_validation branch. The above was created using this program:

#include "xlsxwriter.h"

int main() {

    lxw_workbook  *workbook  = new_workbook("test_data_validation01.xlsx");
    lxw_worksheet *worksheet = workbook_add_worksheet(workbook, NULL);

    char *list[] = {"Foo", "Bar", "Baz", NULL};

    lxw_data_validation *data_validation = calloc(1, sizeof(lxw_data_validation));
    data_validation->validate = LXW_VALIDATION_TYPE_LIST;
    data_validation->source_list = list;

    worksheet_data_validation_cell(worksheet, CELL("C2"), data_validation);

    free(data_validation);

    return workbook_close(workbook);
}

Most of the guard rails are still missing but if you can figure it out based on the above program, you can try it out.

<!-- gh-comment-id:331003839 --> @jmcnamara commented on GitHub (Sep 20, 2017): @evanmiller That is currently doable with the code on the `data_validation` branch. The above was created using this program: ```C #include "xlsxwriter.h" int main() { lxw_workbook *workbook = new_workbook("test_data_validation01.xlsx"); lxw_worksheet *worksheet = workbook_add_worksheet(workbook, NULL); char *list[] = {"Foo", "Bar", "Baz", NULL}; lxw_data_validation *data_validation = calloc(1, sizeof(lxw_data_validation)); data_validation->validate = LXW_VALIDATION_TYPE_LIST; data_validation->source_list = list; worksheet_data_validation_cell(worksheet, CELL("C2"), data_validation); free(data_validation); return workbook_close(workbook); } ``` Most of the guard rails are still missing but if you can figure it out based on the above program, you can try it out.
Author
Owner

@evanmiller commented on GitHub (Sep 21, 2017):

@jmcnamara Thanks. I'll trust you that it works as advertised, and I'll keep it in mind when deciding to port the rest of my code.

<!-- gh-comment-id:331060838 --> @evanmiller commented on GitHub (Sep 21, 2017): @jmcnamara Thanks. I'll trust you that it works as advertised, and I'll keep it in mind when deciding to port the rest of my code.
Author
Owner

@jmcnamara commented on GitHub (Sep 25, 2017):

Added in version 0.75. See Working with Data Validation and data_validate.c.

<!-- gh-comment-id:331749174 --> @jmcnamara commented on GitHub (Sep 25, 2017): Added in version 0.75. See [Working with Data Validation](https://libxlsxwriter.github.io/working_with_data_validation.html) and [data_validate.c](https://libxlsxwriter.github.io/data_validate_8c-example.html).
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: github-starred/libxlsxwriter#26
No description provided.