Skip to content

Correct header rendering for joined columns#202

Open
paodb wants to merge 3 commits into
masterfrom
issue-190
Open

Correct header rendering for joined columns#202
paodb wants to merge 3 commits into
masterfrom
issue-190

Conversation

@paodb
Copy link
Copy Markdown
Member

@paodb paodb commented May 26, 2026

Close #190

CSV/DOCX/PDF were always rendering the topmost header row, which for joined headers produced the joined-cell text instead of the actual column header. They now use the header row closest to the data, honoring setCustomHeader if set. In Excel, setCustomHeader was being applied to every header row (duplicating the value across joined rows); it now applies only to the row closest to the data. A new demo covers the issue's scenario.

Summary by CodeRabbit

  • New Features
    • Added support for multi-level header rows in grid exports, enabling grouped or hierarchical column headers.
    • Custom header text can now be configured on a per-column basis; these settings apply to the header row immediately adjacent to the exported data.
    • Multi-level header behavior varies across different export formats.

Review Change Stack

@sonarqubecloud
Copy link
Copy Markdown

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 26, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: faf6ad8a-d3e8-462e-a0da-fb104acee651

📥 Commits

Reviewing files that changed from the base of the PR and between cf9dd42 and 7ac9db7.

📒 Files selected for processing (4)
  • src/main/java/com/flowingcode/vaadin/addons/gridexporter/BaseStreamResourceWriter.java
  • src/main/java/com/flowingcode/vaadin/addons/gridexporter/GridHeader.java
  • src/test/java/com/flowingcode/vaadin/addons/gridexporter/GridExporterDemoView.java
  • src/test/java/com/flowingcode/vaadin/addons/gridexporter/GridExporterJoinedHeadersWithCustomHeaderDemo.java

Walkthrough

When grids contain joined header rows, the exporter now applies custom headers only to the final header row and uses component-derived text for earlier rows. GridHeader.getText() returns the last text element. A new demo illustrates joined-header grid export with per-column custom header mapping.

Changes

Joined Header Row Custom Header Handling

Layer / File(s) Summary
Header row iteration and custom header routing
src/main/java/com/flowingcode/vaadin/addons/gridexporter/BaseStreamResourceWriter.java
getGridHeader switches to index-based iteration and tracks the last header row, passing an isLastRow flag to renderHeaderCellTextContent. That method now applies GridExporter.COLUMN_HEADER custom headers only when processing the last row; other rows receive null to trigger fallback text extraction from grid cell components.
Header text element selection
src/main/java/com/flowingcode/vaadin/addons/gridexporter/GridHeader.java
getText() returns the final element of the texts list instead of the first, aligning with the last-row header preference established in the previous layer.
Demo: joined headers with custom headers
src/test/java/com/flowingcode/vaadin/addons/gridexporter/GridExporterDemoView.java, src/test/java/com/flowingcode/vaadin/addons/gridexporter/GridExporterJoinedHeadersWithCustomHeaderDemo.java
New demo class GridExporterJoinedHeadersWithCustomHeaderDemo constructs a grid with two columns (First Name, Last Name), prepends a joined header row spanning both, populates sample data via Faker, and configures per-column custom headers (Given name, Family name) that apply to the bottom row. Registration is added to GridExporterDemoView.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested reviewers

  • mlopezFC
  • javier-godoy
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Correct header rendering for joined columns' clearly and concisely summarizes the main change in the changeset: fixing how headers are rendered when grid columns are joined.
Linked Issues check ✅ Passed The pull request successfully addresses all objectives from issue #190: CSV/DOCX/PDF exports now use the last header row (closest to data) instead of the first, custom headers apply only to the last header row in all formats, and a demo for joined headers with custom headers was added.
Out of Scope Changes check ✅ Passed All changes are directly related to fixing header rendering for joined columns as specified in issue #190; no out-of-scope modifications were introduced.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch issue-190

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@paodb paodb marked this pull request as ready for review May 26, 2026 19:47
@paodb paodb requested review from javier-godoy and scardanzan May 26, 2026 19:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: To Do

Development

Successfully merging this pull request may close these issues.

Exporting a grid with joined columns in csv format / Excel doubles Custom Header

1 participant