Skip to content

Write Excel output from compute - #95

Merged
buehlmaier merged 1 commit into
2.x.xfrom
fix-excel-output
Oct 20, 2026
Merged

buehlmaier merged 1 commit into
2.x.xfrom
fix-excel-output

Conversation

@buehlmaier

Copy link
Copy Markdown
Collaborator

compute to an .xlsx path crashed with Cannot invoke "clojure.lang.IFn.invoke(Object, Object)" because "this.out" is null: clojask-io's get-output-func returns nil for Excel formats, and the workers called it. With an Excel input (read-excel), the "same format as the input" branch picked the input's csv writer instead and would have written csv text into the .xlsx file. Either way the returned dataframe was built with (dataframe output-dir), which cannot read Excel.

Change

  • For an .xlsx output path (and no custom :output function), compute collects the rows in memory, as it does for a nil path, writes them with clojask-io.output/write-excel to sheet Sheet1, and returns a dataframe read back with read-excel. Excel workbooks are built in memory anyway, so the output has to fit in memory; the docs say so.
  • An .xls path throws a TypeException before init-file deletes the existing output file, since write-excel always writes the xlsx format.
  • docs/documentation.md: the compute output path and return value describe the formats.

Tests

regression-test gains compute-writes-xlsx (simple compute; group-by aggregate with :header false; an Excel input written back to .xlsx) and compute-rejects-xls-output (throws, leaves the existing file). Both fail on 2.x.x (2 errors, 1 failure) and pass here. Full suite: 62 tests, 312 assertions, 0 failures.

Found while updating clojask-examples' in_memory example, which works around this by computing in memory and calling write-excel itself.

compute to an .xlsx path failed with "this.out is null": clojask-io's
get-output-func has no Excel writer, so the workers called nil. With an
Excel input the same-format branch picked the input's csv writer
instead and would have written csv text into the .xlsx file, and the
returned dataframe could not read the file either way.

compute now collects the rows in memory for an .xlsx path (unless a
custom :output function is given), writes them with clojask-io's
write-excel to sheet Sheet1, and returns a dataframe read back with
read-excel. An .xls path is rejected before the output file is
deleted, since write-excel always writes the xlsx format.
@buehlmaier
buehlmaier merged commit 484dd1e into 2.x.x Oct 20, 2026
3 checks passed
@buehlmaier
buehlmaier deleted the fix-excel-output branch October 20, 2026 17:13
@buehlmaier buehlmaier mentioned this pull request Oct 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant