bengbengbalabalabeng commented on issue #164:
URL: https://github.com/apache/fesod/issues/164#issuecomment-3537996642
I'd like to propose a design for handling nested objects using a new
`@ExcelOneToOne` annotation to handle nested objects. This would allow
flattening the fields of a nested object directly into the columns of the
parent object.
Example:
```java
public class Item {
@ExcelProperty("item name")
private String name;
@ExcelProperty("item code")
private String code;
}
```
1. Without `@ExcelProperty`
```java
public class Demo {
@ExcelProperty("name")
private String name;
@ExcelProperty("value")
private String value;
@ExcelOneToOne
private Item item;
}
```
When a field is marked only with `@ExcelOneToOne`, its inner fields are
treated as top-level columns. like
[`demo1.xlsx`](https://github.com/user-attachments/files/22653752/demo1.xlsx)
2. With `@ExcelProperty`
```java
public class Demo {
@ExcelProperty("name")
private String name;
@ExcelProperty("value")
private String value;
@ExcelOneToOne
@ExcelProperty("item")
private Item item;
}
```
When the field is marked with both `@ExcelOneToOne` and `@ExcelProperty`,
the value of `@ExcelProperty` becomes a parent header, creating a multi-level
header. like
[`demo2.xlsx`](https://github.com/user-attachments/files/22653751/demo2.xlsx)
In the future, we can continue to extend annotations similar to
`@ExcelOneToMany` to handle one-to-many relationships.
---
What does everyone think of this approach?
--
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]