Skip to content

Add Word table cell DSL support#70

Merged
PrzemyslawKlys merged 8 commits into
mainfrom
codex/pswriteoffice-word-table-cells
Apr 3, 2026
Merged

Add Word table cell DSL support#70
PrzemyslawKlys merged 8 commits into
mainfrom
codex/pswriteoffice-word-table-cells

Conversation

@PrzemyslawKlys
Copy link
Copy Markdown
Member

What changed

  • add Add-OfficeWordTableCell for cell-scoped authoring in the Word DSL
  • allow nested tables from inside a table cell
  • support paragraphs, lists, images, and nested tables inside cells
  • add docs and a dedicated table-cell example

Why

These changes cover the table-cell authoring gaps identified during the issue review so users can build richer Word tables without dropping down to raw objects.

Validation

  • dotnet build Sources/PSWriteOffice.sln
  • Invoke-Pester Tests/WordDsl.Tests.ps1 -Output Detailed
    • Passed: 8

Notes

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 17200ed7e9

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread Tests/WordDsl.Tests.ps1 Outdated
Comment on lines +72 to +73
Add-Type -AssemblyName System.Drawing
$bitmap = [System.Drawing.Bitmap]::new(8, 8)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Remove System.Drawing dependency from cross-platform test

This test now creates a bitmap via System.Drawing, which is not supported on PowerShell 7/.NET 8 Linux and macOS environments, so Bitmap construction can throw before the table-cell assertions run. Because the main test workflow runs the suite on Ubuntu and macOS (.github/workflows/test-powershell.yml), this introduces a likely CI break unrelated to the feature itself; use a cross-platform image fixture approach (for example embedded PNG bytes or ImageSharp) instead.

Useful? React with 👍 / 👎.

Comment on lines +142 to +144
if (CurrentTableCell != null)
{
return CurrentTableCell;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Resolve paragraph host to current table cell first

RequireParagraphHost() checks header/footer before CurrentTableCell, so when WordTableCell -Table ... is used inside an active header or footer scope, commands like WordParagraph, WordText, and WordImage inside the cell block target the header/footer instead of the selected cell. This silently writes content to the wrong container in mixed scopes; the cell scope should take precedence (or this combination should be rejected explicitly).

Useful? React with 👍 / 👎.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2afe26d883

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

protected override void ProcessRecord()
{
var context = WordDslContext.Require(this);
var table = Table ?? context.CurrentTable;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Resolve current table scope from innermost frame

When WordTableCell is called inside a nested WordTable block, var table = Table ?? context.CurrentTable; can bind to the outer table instead of the nested one, because scope lookup is based on the oldest matching frame in WordDslContext. In that scenario, row/column addressing is applied to the wrong table (or throws out-of-range), so nested-table cell authoring is unreliable unless users always pass -Table explicitly.

Useful? React with 👍 / 👎.

Comment on lines +17 to +18
Add-Type -AssemblyName System.Drawing
$bitmap = [System.Drawing.Bitmap]::new(48, 48)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Avoid System.Drawing dependency in table-cell example

This example now requires System.Drawing to generate an image fixture, but System.Drawing.Common is not supported for general use on Linux/macOS in PowerShell 7/.NET 8, so the script can fail before demonstrating the DSL behavior on non-Windows hosts. Because this is a user-facing example for a cross-platform module, the image fixture should come from a static PNG (or another cross-platform library) instead of runtime bitmap generation.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f80888a383

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +17 to +18
Add-Type -AssemblyName System.Drawing
$bitmap = [System.Drawing.Bitmap]::new(48, 48)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Replace System.Drawing in published table-cell example

The website-facing example still depends on System.Drawing (Add-Type + Bitmap), which is not supported for general cross-platform use in PowerShell 7/.NET 8 on Linux and macOS; users copying this snippet can fail before any WordTableCell logic runs. The source example was already switched to a fixture image, so this generated artifact should be updated/regenerated to match that cross-platform approach.

Useful? React with 👍 / 👎.

@chatgpt-codex-connector
Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@PrzemyslawKlys PrzemyslawKlys merged commit 1c80857 into main Apr 3, 2026
@PrzemyslawKlys PrzemyslawKlys deleted the codex/pswriteoffice-word-table-cells branch April 3, 2026 22:14
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