Skip to content

docs: document setting column widths via configureOptionsUsing (#213) - #417

Open
elminson wants to merge 1 commit into
masterfrom
docs/column-widths
Open

docs: document setting column widths via configureOptionsUsing (#213)#417
elminson wants to merge 1 commit into
masterfrom
docs/column-widths

Conversation

@elminson

Copy link
Copy Markdown
Collaborator

Why

#213 ("Auto size Excel column width") has been open since 2021 with 7 comments, and the answer on the thread is that widths are not possible. That is only half true: explicit column widths already work through OpenSpout's writer options and configureOptionsUsing() — it was simply never documented. Several commenters were asking for exactly this.

Change

Docs only, no code. Adds an "Set column widths" section under Advanced usage covering:

  • setColumnWidth(width, ...$columns) and setColumnWidthForRange(width, $start, $end)
  • that column numbers are 1-based
  • that it works with streaming exports (cursor/generator), because widths are written when the file is finalized rather than per row
  • that xlsx/ods support widths and csv ignores them
  • an explicit note that automatic sizing to fit content is still unavailable

Verified

Every snippet was run before being documented:

Snippet Result
setColumnWidth(40, 1) + setColumnWidth(15, 2, 3) <col min="1" max="1" width="40"/><col min="2" max="3" width="15"/>
setColumnWidthForRange(20, 1, 4) <col min="1" max="4" width="20"/>
same, from a generator (streaming) <col min="1" max="1" width="33"/>
ods export writes successfully

Refs #213 — deliberately not "Closes", since auto-sizing is the actual request and remains open.

Column widths are already supported through OpenSpout's writer options, but
that was undocumented, so #213 reads as "not possible". Add an Advanced usage
section showing setColumnWidth() and setColumnWidthForRange(), noting that
column numbers are 1-based, that it works with streaming exports (widths are
written at finalization, not per row), and that csv ignores it.

Automatic sizing to fit content is still not available; this documents the
explicit-width path only.

Refs #213
@elminson elminson self-assigned this Jul 29, 2026
@elminson
elminson requested a review from dannyyol July 29, 2026 21:03
@elminson

Copy link
Copy Markdown
Collaborator Author

Hi @dannyyol 👋 — gentle nudge that this is waiting on your review.

It is docs-only, no code: it documents that explicit column widths already work through configureOptionsUsing() + setColumnWidth(), which is the part of #213 that is solvable today. Every snippet in it was run before being written down. Should be a quick read.

Thanks, and enjoy your weekend! 🙌

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