Skip to content

Restore default Excel table formatting in file connector - #1140

Open
ebhills with Copilot wants to merge 6 commits into
mainfrom
copilot/fix-default-table-formatting
Open

Restore default Excel table formatting in file connector#1140
ebhills with Copilot wants to merge 6 commits into
mainfrom
copilot/fix-default-table-formatting

Conversation

Copilot AI commented Aug 22, 2026

Copy link
Copy Markdown
Contributor

Linked issue

What changes

Excel files written without explicit formatting no longer received the file connector’s default table styling.

  • Restores Table Style Medium9 and top alignment using XlsxWriter.
  • Preserves pandas Excel options, mixed-type columns, indexes, and in-memory output.
  • Handles duplicate, nullable, and MultiIndex headers safely.
  • Keeps explicit advanced formatting on the existing Polars/XlsxWriter path.
write:
  - file:
      name: output.xlsx

This now produces a formatted Excel table without requiring a formatting block.

How it was verified

  • 74 focused file and Excel connector tests.
  • Full credential-safe suite: 1,481 passed, 3 skipped.
  • Manual workbook inspection of table style, range, alignment, sheet name, and values.
  • Secret scan and CodeQL completed with no findings.

Compatibility and risk

  • No migration required.
  • Explicit formatting behavior remains unchanged.
  • constant_memory=True now raises ValueError because it is incompatible with pandas column writes and Excel tables.
  • MultiIndex worksheets remain valid but omit the incompatible table overlay.
  • Safest rollback: revert the formatting commits.

Ready-for-review checklist

  • One human delivery owner is assigned
  • The linked issue and intended milestone are correct
  • The branch is current with main and has no merge conflicts
  • Focused tests pass
  • New or changed behavior has direct test coverage
  • Documentation/schema/configuration is updated where applicable
  • The PR contains no unrelated changes
  • The PR description reflects the branch's current scope and latest validation
  • One primary reviewer is requested only when this PR is ready

See the pull request workflow.

Copilot AI and others added 5 commits August 22, 2026 12:48
Co-authored-by: ebhills <53243273+ebhills@users.noreply.github.com>
Co-authored-by: ebhills <53243273+ebhills@users.noreply.github.com>
Co-authored-by: ebhills <53243273+ebhills@users.noreply.github.com>
Co-authored-by: ebhills <53243273+ebhills@users.noreply.github.com>
Co-authored-by: ebhills <53243273+ebhills@users.noreply.github.com>
Copilot AI changed the title [WIP] Re-implement default table formatting for file connector Restore default Excel table formatting in file connector Aug 22, 2026
Copilot AI requested a review from ebhills August 22, 2026 13:17
@ebhills
ebhills requested a balanced review from Copilot August 24, 2026 01:23
@ebhills
ebhills marked this pull request as ready for review August 24, 2026 01:23

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Restores default Excel table styling while retaining the advanced formatting path.

Changes:

  • Adds default XlsxWriter table formatting and top alignment.
  • Handles duplicate, nullable, indexed, and MultiIndex headers.
  • Expands Excel connector regression tests.

Recommended disposition: Request changes

Next steps

  1. PR assignee: Fix the three Excel compatibility and round-trip regressions, add focused tests, then re-request review.
  2. Reviewer: Verify fixes, resolve threads, and submit a fresh approval.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
wrangles/connectors/file.py Routes Excel exports through default or advanced formatting.
wrangles/connectors/_formatting.py Implements default table styling and header handling.
tests/connectors/test_file.py Adds Excel formatting and compatibility tests.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +247 to +248
if kwargs.get('index', False):
df = df.reset_index()
Comment on lines +1156 to +1157
from openpyxl.utils.escape import unescape
assert unescape(result['col'][0]) == 'a\tb\nc\rd'
# Default to not including index if user hasn't explicitly requested it
if 'index' not in kwargs.keys(): kwargs['index'] = False
sheet_name = kwargs.pop('sheet_name', 'Sheet1')
df = _remove_illegal_characters(df)
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.

Table format in File even when formatting not specified

3 participants