Nodes/ComfyUI-Apt_Preset/excel_search_data
ComfyUI Node

excel_search_data

Find a value's coordinates in a spreadsheet

By cardenluo·Created 2 years ago·Updated 17 days ago· 309
excel_search_data
    • debug
    • row
    • col
    excel_pathexcel_file_path.xlsx
    sheet_nameSheet1
    search_content
    search_modePrecise_search

    excel_read_easy needs you to already know the exact row and column you want. excel_search_data is for when you don't - you know the value you're looking for, not where it lives. Give it a search string and it scans the sheet and hands back the row and column where it found a match.

    How it works

    Set search_content to whatever you're looking for and pick a search_mode: Precise_search for an exact match, or Fuzzy_search for a looser, partial match. The node scans the sheet and returns the coordinates of what it finds, plus a debug string that's especially useful when the search comes up empty and you need to know why.

    The obvious pairing is with a known header or label: search for "Prompt" to find the header cell in a sheet whose exact layout you don't remember, then use the returned row/col (or an offset from them) to drive an excel_read_easy or excel_insert_image_easy call at a computed position, instead of hardcoding coordinates that break the moment someone inserts a row above your data. It's equally useful as a plain verification step - confirm a value you expected to be written actually landed in the sheet, without opening the file yourself.

    The inputs and outputs that matter

    • excel_path / sheet_name - the file and sheet to search.
    • search_content (STRING) - what you're looking for.
    • search_mode (Precise_search / Fuzzy_search) - exact match versus a looser partial match.
    • Outputs: debug (STRING, useful when nothing matches), row and col (INT) - the coordinates of the match.

    How to install it

    Bundled with the full pack. Via ComfyUI Manager: search "ComfyUI-Apt_Preset" → Install → restart. Manually:

    cd ComfyUI/custom_nodes
    git clone https://github.com/cardenluo/ComfyUI-Apt_Preset.git
    

    Windows: run install.bat from the cloned folder through ComfyUI's embedded Python. Linux/Mac: activate your ComfyUI venv and install requirements from that folder by hand. Restart ComfyUI. This node needs the same Python .xlsx library (most likely openpyxl) as the rest of the excel_* nodes here - if it specifically fails to import while other parts of the pack work, that's the dependency to check the console for.

    Common issues & troubleshooting

    Search finds nothing even though you can see the value in the sheet. Try Fuzzy_search instead of Precise_search first - trailing whitespace, a different case, or extra characters around the text you're searching for will all defeat an exact match but usually still hit under fuzzy matching. Check the debug output for detail on what actually happened.

    Fuzzy search matches the wrong cell. With a loose match mode and a short or common search string, you can hit an unintended cell before the one you meant - especially in a sheet with repeated words. Make search_content as specific as you reasonably can, or switch to Precise_search once you know the exact text.

    Row/col come back as 0 or some default rather than erroring. With no dedicated "not found" output separate from row/col themselves, lean on the debug string to distinguish a genuine no-match from a real result - don't assume a returned coordinate is valid without checking it.

    CategoryApt_Preset/prompt/excel

    Inputs (4)

    NameTypeDefaultDescription
    excel_pathSTRINGexcel_file_path.xlsx
    sheet_nameSTRINGSheet1
    search_contentSTRING
    search_modeCOMBOPrecise_search2 options: Precise_search, Fuzzy_search

    Outputs (3)

    NameTypeDescription
    debugSTRING
    rowINT
    colINT