Skip to content

ext: save-as-xlsx 1.1.0 - #253

Merged
vbilopav merged 1 commit into
hercstack:mainfrom
ibelic:ext/save-as-xlsx-1.1
Dec 1, 2026
Merged

vbilopav merged 1 commit into
hercstack:mainfrom
ibelic:ext/save-as-xlsx-1.1

Conversation

@ibelic

@ibelic ibelic commented Nov 30, 2026

Copy link
Copy Markdown
Contributor

What this adds or changes

save-as-xlsx 1.1.0, the two ideas from the review of #251:

  • Real Excel dates. In a date, timestamp or time column, values in PostgreSQL's ISO output (the default DateStyle) are written as Excel date numbers, so they sort and filter as dates.
    • Formats: they show as yyyy-mm-dd, yyyy-mm-dd hh:mm:ss or hh:mm:ss, with .000 when the value has a fraction of a second.
    • Column width: such a column gets a width that shows its dates, since Excel fills a date that does not fit with ####.
    • Time zones: a timestamp with time zone keeps the wall clock the grid shows and drops its offset, since an Excel date has no zone.
    • What stays text, as written: dates before 1 March 1900 (Excel counts a 29 February 1900), infinity, BC dates, years past 9999, another DateStyle's output, time with time zone (its offset is data), 24:00:00 and a date a formatting extension has reformatted.
  • Cut values are reported. A value cut at Excel's 32,767 characters now writes one Log line through ctx.log, with how many values were cut and where the first one is. For example: 2 values were longer than the 32,767 characters an Excel cell holds and were cut to that length; the first is in column notes, row 2.
  • README: documents both, and no longer mentions Query to XLSX, which is not in the marketplace.

Type modifiers are now dropped before a column's type is matched, so timestamp(3) with time zone and numeric(12,2) are read as their base types.

Tested by calling the format the way PlumeSQL does and writing its string as UTF-8:

  • every file passes unzip -t and xmllint, and opens in openpyxl and macOS Quick Look;
  • openpyxl reads each converted value back as the expected datetime, date or time with its number format;
  • the edge cases behave as listed above, including 1900-03-01, 2024-02-29, 2023-02-29, 9999-12-31 23:59:59 and microsecond fractions;
  • cut values: 32,767 characters is not cut, 32,768 and 40,000 are, and the Log line counts them;
  • a 10,000 row result with dates, timestamps, Croatian and Japanese text and emoji saves in about 40 ms;
  • tsc --strict --checkJs passes against docs/plumesql-extension.d.ts.

Checklist

  • One extension in this pull request, under extensions/<Category>/<id>/, the main file named after the id
  • manifest.json complete, version bumped if any installed file changed (1.0.0 to 1.1.0)
  • README.md follows the template in extensions/README.md, with a screenshot or clip under media/
  • A discussion thread exists under the Extensions category, titled with the id, and its number is in the manifest (save-as-xlsx #250)
  • node extensions/tools/catalog.mjs --check passes locally
  • Nothing changes or deletes data without a @confirm; every reference is schema-qualified; the password never leaves @env (no SQL and no database access)
  • Every external library the code loads is listed in externals, every referenced extension in dependencies (none of either)

🤖 Generated with Claude Code

Dates, timestamps and times become Excel dates: a date, timestamp or time
column's values in PostgreSQL's ISO output are written as Excel date
numbers with yyyy-mm-dd, yyyy-mm-dd hh:mm:ss or hh:mm:ss (milliseconds
when the value has a fraction), and such a column gets a width that shows
them rather than ####. A timestamp with time zone keeps the wall clock the
grid shows; what Excel has no date for (before 1 March 1900, infinity, BC,
another DateStyle, time with time zone) stays text as written.

A value cut at Excel's 32,767 characters is no longer cut in silence: the
Log says how many were cut and where the first one is.

The README no longer points at an extension the marketplace does not have.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@vbilopav
vbilopav merged commit c778271 into hercstack:main Dec 1, 2026
2 checks passed
@vbilopav

vbilopav commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

Thank you again, @ibelic, and for taking both ideas from the review so carefully! 1.1.0 is merged and reaches the Marketplace with the next catalog build.

We tried it before merging: the format called as PlumeSQL calls it, on dates, timestamps (with microseconds and with offsets), times, 1900-02-28 and 1900-03-01, 2023-02-29, 9999-12-31, infinity, a BC timestamp, 24:00:00, time with time zone, numeric(12,2), a 16 digit bigint, emoji and two 40,000 character values. The file is plain ASCII, passes unzip -t, and Microsoft Excel opened it without a repair prompt: the dates and times showed in their formats (milliseconds where the value has them), the date columns wide enough, 1900-02-28, infinity and =1+1 kept as text, and the Log said that two values were cut, naming the first. The catalog check and our own deep check of the extension pass too.

The wall clock kept for a timestamp with time zone is the right call, and the README says it plainly. Thanks for the contribution!

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.

2 participants