Code Monkey home page Code Monkey logo

Comments (9)

jmcnamara avatar jmcnamara commented on August 16, 2024 1

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

from libxlsxwriter.

evanmiller avatar evanmiller commented on August 16, 2024

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

from libxlsxwriter.

jmcnamara avatar jmcnamara commented on August 16, 2024

@evanmiller Noted.

from libxlsxwriter.

jmcnamara avatar jmcnamara commented on August 16, 2024

@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.

from libxlsxwriter.

evanmiller avatar evanmiller commented on August 16, 2024

@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);

from libxlsxwriter.

jmcnamara avatar jmcnamara commented on August 16, 2024

This type of validation?

screen shot 2017-09-20 at 23 42 27

from libxlsxwriter.

evanmiller avatar evanmiller commented on August 16, 2024

@jmcnamara Yes.

from libxlsxwriter.

jmcnamara avatar jmcnamara commented on August 16, 2024

@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.

from libxlsxwriter.

evanmiller avatar evanmiller commented on August 16, 2024

@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.

from libxlsxwriter.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.