feat: support freeze pane via @FreezePane or register WriteHandler on write#916
feat: support freeze pane via @FreezePane or register WriteHandler on write#916bengbengbalabalabeng wants to merge 4 commits into
Conversation
There was a problem hiding this comment.
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
@FreezePaneplusSheetFreezePanePropertyto model freeze pane configuration derived from the head class. - Adds
SheetFreezePaneStrategy(aSheetWriteHandler) 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
.xlsxand.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)); |
| @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); | ||
|
|
| int colSplit(); | ||
|
|
||
| /** | ||
| * Vertical position of split. | ||
| */ | ||
| int rowSplit(); |
- add default value for annotation fields - delete redundant references
|
PTAL @psxjoy |
| } | ||
|
|
||
| @Test | ||
| void constructor_fromProperty_copiesAllFields() { |
There was a problem hiding this comment.
where is the copiesAllFields ?
| | Name | Default Value | Description | | ||
| |----------------|---------------|--------------------------------------------------------------------------| | ||
| | colSplit | 0 | Horizontal position of split. | | ||
| | rowSplit | 0 | Vertical position of split. | |
There was a problem hiding this comment.
Please correct me if misunderstanding:
colSplit is vertical splitting
rowSplit is the horizontal splitting ?
| | 名称 | 默认值 | 描述 | | ||
| |----------------|-----|------------------------------------| | ||
| | colSplit | 0 | 水平拆分位置(即需要冻结的列数) | | ||
| | rowSplit | 0 | 垂直拆分位置(即需要冻结的行数) | |
There was a problem hiding this comment.
same question with English parts
Purpose of the pull request
Closed: #913
Closed: #395
What's changed?
Use Case:
Checklist