Skip to content

feat: support freeze pane via @FreezePane or register WriteHandler on write#916

Open
bengbengbalabalabeng wants to merge 1 commit into
apache:mainfrom
bengbengbalabalabeng:feat-freezepane-913
Open

feat: support freeze pane via @FreezePane or register WriteHandler on write#916
bengbengbalabalabeng wants to merge 1 commit into
apache:mainfrom
bengbengbalabalabeng:feat-freezepane-913

Conversation

@bengbengbalabalabeng
Copy link
Copy Markdown
Contributor

Purpose of the pull request

Closed: #913

What's changed?

Added excel sheet freeze pane support.

Use Case:

  • Freeze columns 1-2 (A-B) and row 1 in the sheet.
// for bean annotation
@FreezePane(colSplit = 2, rowSplit = 1)
public class Model { ... }

FesodSheet.write(file, Model.class)
      .sheet()
      .doWrite(data);

// for write-handler
FesodSheet.write(file)
      .registerWriteHandler(new SheetFreezePaneStrategy(2, 1, 2, 1))
      .sheet()
      .doWrite(data);
  • Freeze rows 1–3 and columns 1–2 (A-B) in the sheet. The right pane starts displaying from column 6 (F) by default, and the bottom pane starts displaying from row 11 by default.
// for bean annotation
@FreezePane(colSplit = 2, rowSplit = 3, leftmostColumn = 5, topRow = 10)
public class Model { ... }

FesodSheet.write(file, Model.class)
      .sheet()
      .doWrite(data);

// for write-handler
FesodSheet.write(file)
      .registerWriteHandler(new SheetFreezePaneStrategy(2, 3, 5, 10))
      .sheet()
      .doWrite(data);

Checklist

  • I have read the Contributor Guide.
  • I have written the necessary doc or comment.
  • I have added the necessary unit tests and all cases have passed.

@psxjoy psxjoy requested review from Copilot and psxjoy May 13, 2026 05:44
@psxjoy psxjoy added the PR: reviewing Currently under active review. label May 13, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds Excel sheet freeze pane support to Fesod’s write pipeline, enabling freeze panes to be configured either declaratively via a new @FreezePane class annotation or imperatively via a new SheetFreezePaneStrategy write handler (Closes #913).

Changes:

  • Introduces @FreezePane plus SheetFreezePaneProperty to model freeze pane configuration derived from the head class.
  • Adds SheetFreezePaneStrategy (a SheetWriteHandler) and wires it into annotation-driven handler initialization.
  • Adds unit/integration tests to validate property building and end-to-end freeze pane behavior for both .xlsx and .xls.

Reviewed changes

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

Show a summary per file
File Description
fesod-sheet/src/main/java/org/apache/fesod/sheet/annotation/write/style/FreezePane.java New annotation to declare freeze pane configuration on the head model class.
fesod-sheet/src/main/java/org/apache/fesod/sheet/metadata/property/SheetFreezePaneProperty.java New property object to map @FreezePane values into a runtime configuration.
fesod-sheet/src/main/java/org/apache/fesod/sheet/write/style/SheetFreezePaneStrategy.java New SheetWriteHandler that applies Sheet#createFreezePane(...) after sheet creation.
fesod-sheet/src/main/java/org/apache/fesod/sheet/write/property/ExcelWriteHeadProperty.java Captures @FreezePane into ExcelWriteHeadProperty for downstream handler setup.
fesod-sheet/src/main/java/org/apache/fesod/sheet/write/metadata/holder/AbstractWriteHolder.java Registers SheetFreezePaneStrategy when @FreezePane is present on the head class.
fesod-sheet/src/test/java/org/apache/fesod/sheet/metadata/property/SheetFreezePanePropertyTest.java Tests annotation-to-property mapping and defaulting behavior.
fesod-sheet/src/test/java/org/apache/fesod/sheet/write/style/SheetFreezePaneStrategyTest.java Tests strategy validation and that it delegates to Sheet#createFreezePane(...).
fesod-sheet/src/test/java/org/apache/fesod/sheet/write/freezepane/SheetFreezePaneTest.java End-to-end tests that confirm freeze panes are present/absent in generated workbooks.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

property.setLeftmostColumn(3);
property.setTopRow(4);

Assertions.assertDoesNotThrow(() -> new SheetFreezePaneStrategy(property));
Comment on lines +87 to +95
@Test
void afterSheetCreate_withZeroValues() {
SheetFreezePaneStrategy strategy = new SheetFreezePaneStrategy(0, 0, 0, 0);

WriteWorkbookHolder workbookHolder = Mockito.mock(WriteWorkbookHolder.class);
WriteSheetHolder sheetHolder = Mockito.mock(WriteSheetHolder.class);
Sheet sheet = Mockito.mock(Sheet.class);
org.mockito.Mockito.when(sheetHolder.getSheet()).thenReturn(sheet);

Comment on lines +39 to +44
int colSplit();

/**
* Vertical position of split.
*/
int rowSplit();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

PR: reviewing Currently under active review.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Enhancement] FastExcel 导出增加 表头冻结注解(冻结首行 / 首列)

3 participants