apache / apache/fesod

Supports obtaining current row data object during writing

Open
#598 4 comments 1 reaction 1 assignee Claimed by @hooj0 View on GitHub
enhancement suggest
Dominant language
Java
Stars
6.2k
Forks
532
Avg merge
1d 3h
Merged PRs (30d)
42

Description

### Search before asking

- [x] I searched in the [issues](https://github.com/fast-excel/fastexcel/issues) and found nothing similar.

### Motivation

在写入excel文件时,准备好数据后,写入文件对数据进行二次转换或者简单业务逻辑处理。不想再循环进行处理。可以在数据写入单元格的时候进行二次转换或者简单业务逻辑处理,此时,业务可能需要依赖行级完整对象数据。
示例:
```
class Data {
private int a;
private int b;
private int c;
private String text;
}
```

在生成text单元格内容,可能需要结合数据a、b、c进行逻辑判断。

### Solution

希望在converter(WriteConverterContext)或handler(CellWriteHandlerContext)中传入 oneRowData

```
Cell cell = WorkBookUtil.createCell(row, columnIndex);
cellWriteHandlerContext.setCell(cell);

WriteHandlerUtils.afterCellCreate(cellWriteHandlerContext);

cellWriteHandlerContext.setOriginalRecord(oneRowData); // 传入当前行级数据
cellWriteHandlerContext.setOriginalValue(beanMap.get(name));
cellWriteHandlerContext.setOriginalFieldClass(head.getField().getType());
converterAndSet(cellWriteHandlerContext);

WriteHandlerUtils.afterCellDispose(cellWriteHandlerContext);

beanMapHandledSet.add(name);
```

### Alternatives

_No response_

### Anything else?

_No response_

### Are you willing to submit a PR?

- [x] I'm willing to submit a PR!

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.