Nodes/ComfyDL/Dataset → Write XLSX
ComfyUI Node

Dataset → Write XLSX

The one writer that checks its dependency and tells you what to install

By Cynthia-lxx·Created 3 months ago·Updated 12 days ago· 7
Dataset → Write XLSX
  • dataset
  • file
◄filedataset_out.xlsx►
◄sheetSheet1►

What it is

ComfyDL is Cynthia-lxx's pack for running d2l-style deep learning as ComfyUI graphs; its data side hands one universal DATASET type between readers, adapters, trainers and writers. Dataset → Write XLSX takes a dataset and writes a real Excel workbook.

Nobody trains on spreadsheets, but plenty of people report to them. This is the node you end a pipeline with when the output is going to a colleague who lives in Excel, or when you want to eyeball results in a tool with filters before committing to a training run. It also makes a decent converter: read a DB or a CSV, write the workbook once, and you've got something a human can open and argue with.

How it works

The dataset goes through to_dataframe() - features from the tensor plus feature_names as columns, and the label column under the dataset's target name (or label if there isn't one) - and then df.to_excel(file, sheet_name=sheet, index=False). Note that index=False is hard-coded here, unlike Write CSV which exposes an index toggle: there's no way to get pandas' row numbers into the sheet.

The one piece of code here worth reading is the dependency check, because it's the only place in the pack's data-io that does one properly:

try:
    import openpyxl
except ImportError as exc:
    raise ImportError("CdlWriteXLSX requires openpyxl. Install it with `pip install openpyxl`.") from exc

So you get a message telling you exactly what to type instead of a stack trace five frames deep in pandas. Nice touch, and a reminder that the readers, which don't do this, will hand you pandas' own (still readable) missing-dependency errors.

Inputs and outputs

Required: dataset (forced input socket) and file (STRING, default dataset_out.xlsx). Optional: sheet (STRING, default Sheet1) - the worksheet name, used as-is.

Output: file, the path as a STRING, ready to wire into another node's path field.

Install

Manager → search ComfyDL, or:

cd ComfyUI/custom_nodes
git clone https://github.com/Cynthia-lxx/ComfyDL
pip install -r ./ComfyDL/requirements.txt
pip install openpyxl

Restart ComfyUI. That second install is the important one: the pack's own requirements file lists only matplotlib, IPython and matplotlib-inline, and openpyxl is deliberately not bundled - the node raises a readable hint instead. Reading .xlsx needs the same package, so if you installed it for Read XLSX you already have it.

Where people get burned

ModuleNotFoundError: No module named 'openpyxl' on the first run. If you're running ComfyUI in a venv (or a portable build with its own embedded Python), pip installing into your system Python doesn't help - install into that environment.

Sheet names are literal. No sanitising, no dedupe. Use a name Excel accepts, and remember you're creating a fresh file each run, not appending to a sheet.

It overwrites the workbook. Every run replaces the file. If two branches of your graph write the same path, the second wins.

Relative paths go to ComfyUI's working directory, not your Downloads folder. Use an absolute path.

Excel's ceiling. Around 1.05 million rows per sheet, and this writer isn't chunked, so a really large dataset will either fail or make you wait and eat RAM. That's a CSV or DB job.

The label column is named by the dataset, so a torch-built dataset writes a column called label. Correct, just not what you typed in your source spreadsheet.

Blanks stay blank. NaNs are written as empty cells, so a downstream reader hands the same NaNs back to you - and a NaN in a training feature tensor is a quick route to a lost cause.

Categoryd2l/Datasets

Inputs (3)

NameTypeDefaultDescription
datasetDATASET—
fileSTRINGdataset_out.xlsx—
sheetoptSTRINGSheet1—

Outputs (1)

NameTypeDescription
fileSTRING—