Copilot commented on code in PR #810:
URL: https://github.com/apache/fesod/pull/810#discussion_r2835922354
##########
fesod-sheet/src/main/java/org/apache/fesod/sheet/write/executor/ExcelWriteAddExecutor.java:
##########
@@ -63,10 +64,15 @@ public void add(Collection<?> data) {
data = new ArrayList<>();
}
WriteSheetHolder writeSheetHolder = writeContext.writeSheetHolder();
+ WriteHolder currentWriteHolder = writeContext.currentWriteHolder();
int newRowIndex = writeSheetHolder.getNewRowIndexAndStartDoWrite();
- if (writeSheetHolder.isNew()
- && !writeSheetHolder.getExcelWriteHeadProperty().hasHead()) {
- newRowIndex +=
writeContext.currentWriteHolder().relativeHeadRowIndex();
+ if (currentWriteHolder.isNew()) {
+ if (currentWriteHolder instanceof AbstractWriteHolder) {
+ AbstractWriteHolder writeHolder = (AbstractWriteHolder)
currentWriteHolder;
+ if (!writeHolder.getExcelWriteHeadProperty().hasHead()) {
+ newRowIndex += currentWriteHolder.relativeHeadRowIndex();
+ }
Review Comment:
The instanceof check for AbstractWriteHolder is unnecessary. All
implementations of WriteHolder (WriteSheetHolder, WriteTableHolder,
WriteWorkbookHolder) extend AbstractWriteHolder. The rest of the codebase
directly casts currentWriteHolder() to AbstractWriteHolder without instanceof
checks (see WriteHandlerUtils.java lines 79, 124, 160, 168, 176, 184). For
consistency with the existing codebase patterns, the cast should be done
directly without the instanceof check.
```suggestion
AbstractWriteHolder writeHolder = (AbstractWriteHolder)
currentWriteHolder;
if (!writeHolder.getExcelWriteHeadProperty().hasHead()) {
newRowIndex += currentWriteHolder.relativeHeadRowIndex();
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]