Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
215 changes: 196 additions & 19 deletions website/docs/sheet/fill/fill.md

Large diffs are not rendered by default.

91 changes: 78 additions & 13 deletions website/docs/sheet/write/extra.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public class CommentWriteHandler implements RowWriteHandler {
// Create comment in first row, second column
Comment comment = drawingPatriarch.createCellComment(
new XSSFClientAnchor(0, 0, 0, 0, (short) 1, 0, (short) 2, 1));
comment.setString(new XSSFRichTextString("批注内容"));
comment.setString(new XSSFRichTextString("Comment content"));
sheet.getRow(0).getCell(1).setCellComment(comment);
}
}
Expand All @@ -63,14 +63,25 @@ public void commentWrite() {
FesodSheet.write(fileName, DemoData.class)
.inMemory(Boolean.TRUE) // Comments must enable in-memory mode
.registerWriteHandler(new CommentWriteHandler())
.sheet("批注示例")
.sheet("Comment Example")
.doWrite(data());
}
```

### Result

![img](/img/docs/write/commentWrite.png)
The comment is attached to `B1` and is only shown when that cell is hovered.

<table class="xl-sheet xl-sheet--overlay">
<tbody>
<tr><td class="xl-chrome"></td><td class="xl-chrome">A</td><td class="xl-chrome">B</td><td class="xl-chrome">C</td></tr>
<tr><td class="xl-chrome">1</td><td class="xl-head">String Title</td><td class="xl-head xl-comment-anchor">Date Title<b class="xl-comment">Comment content</b></td><td class="xl-head">Number Title</td></tr>
<tr><td class="xl-chrome">2</td><td>String0</td><td class="xl-num">2026-07-31 20:50:23</td><td class="xl-num">0.56</td></tr>
<tr><td class="xl-chrome">3</td><td>String1</td><td class="xl-num">2026-07-31 20:50:23</td><td class="xl-num">0.56</td></tr>
<tr><td class="xl-chrome">⋮</td><td class="xl-muted">…</td><td class="xl-muted">…</td><td class="xl-muted">…</td></tr>
<tr><td class="xl-chrome">11</td><td>String9</td><td class="xl-num">2026-07-31 20:50:23</td><td class="xl-num">0.56</td></tr>
</tbody>
</table>

---

Expand Down Expand Up @@ -112,7 +123,13 @@ public void writeHyperlinkDataWrite() {

### Result

![img](/img/docs/write/writeCellDataWrite.png)
<table class="xl-sheet">
<tbody>
<tr><td class="xl-chrome"></td><td class="xl-chrome">A</td></tr>
<tr><td class="xl-chrome">1</td><td class="xl-head">hyperlink</td></tr>
<tr><td class="xl-chrome">2</td><td><a href="https://example.com">Click to visit</a></td></tr>
</tbody>
</table>

---

Expand Down Expand Up @@ -155,7 +172,13 @@ public void writeFormulaDataWrite() {

### Result

![img](/img/docs/write/writeCellDataWrite.png)
<table class="xl-sheet">
<tbody>
<tr><td class="xl-chrome"></td><td class="xl-chrome">A</td></tr>
<tr><td class="xl-chrome">1</td><td class="xl-head">formulaData</td></tr>
<tr><td class="xl-chrome">2</td><td>=SUM(A1:A10)</td></tr>
</tbody>
</table>

---

Expand Down Expand Up @@ -198,13 +221,13 @@ Annotation approach
@EqualsAndHashCode
public class DemoMergeData {
@ContentLoopMerge(eachRow = 2) // Merge every 2 rows
@ExcelProperty("字符串标题")
@ExcelProperty("String Title")
private String string;

@ExcelProperty("日期标题")
@ExcelProperty("Date Title")
private Date date;

@ExcelProperty("数字标题")
@ExcelProperty("Number Title")
private Double doubleData;
}
```
Expand Down Expand Up @@ -234,20 +257,35 @@ public void mergeWrite() {

// Annotation approach
FesodSheet.write(fileName, DemoMergeData.class)
.sheet("合并示例")
.sheet("Merge Example")
.doWrite(data());

// Custom merge strategy
FesodSheet.write(fileName, DemoData.class)
.registerWriteHandler(new CustomMergeStrategy())
.sheet("自定义合并")
.sheet("Custom Merge")
.doWrite(data());
}
```

### Result

![img](/img/docs/write/mergeWrite.png)
<table class="xl-sheet">
<tbody>
<tr><td class="xl-chrome"></td><td class="xl-chrome">A</td><td class="xl-chrome">B</td><td class="xl-chrome">C</td></tr>
<tr><td class="xl-chrome">1</td><td class="xl-head">String Title</td><td class="xl-head">Date Title</td><td class="xl-head">Number Title</td></tr>
<tr><td class="xl-chrome">2</td><td rowspan="2">String0</td><td class="xl-num">2026-07-31 20:50:23</td><td class="xl-num">0.56</td></tr>
<tr><td class="xl-chrome">3</td><td class="xl-num">2026-07-31 20:50:23</td><td class="xl-num">0.56</td></tr>
<tr><td class="xl-chrome">4</td><td rowspan="2">String2</td><td class="xl-num">2026-07-31 20:50:23</td><td class="xl-num">0.56</td></tr>
<tr><td class="xl-chrome">5</td><td class="xl-num">2026-07-31 20:50:23</td><td class="xl-num">0.56</td></tr>
<tr><td class="xl-chrome">6</td><td rowspan="2">String4</td><td class="xl-num">2026-07-31 20:50:23</td><td class="xl-num">0.56</td></tr>
<tr><td class="xl-chrome">7</td><td class="xl-num">2026-07-31 20:50:23</td><td class="xl-num">0.56</td></tr>
<tr><td class="xl-chrome">8</td><td rowspan="2">String6</td><td class="xl-num">2026-07-31 20:50:23</td><td class="xl-num">0.56</td></tr>
<tr><td class="xl-chrome">9</td><td class="xl-num">2026-07-31 20:50:23</td><td class="xl-num">0.56</td></tr>
<tr><td class="xl-chrome">10</td><td rowspan="2">String8</td><td class="xl-num">2026-07-31 20:50:23</td><td class="xl-num">0.56</td></tr>
<tr><td class="xl-chrome">11</td><td class="xl-num">2026-07-31 20:50:23</td><td class="xl-num">0.56</td></tr>
</tbody>
</table>

---

Expand All @@ -267,13 +305,40 @@ public class DropdownWriteHandler implements SheetWriteHandler {
public void afterSheetCreate(SheetWriteHandlerContext context) {
DataValidationHelper helper = context.getWriteSheetHolder().getSheet().getDataValidationHelper();
CellRangeAddressList range = new CellRangeAddressList(1, 10, 0, 0); // Dropdown area
DataValidationConstraint constraint = helper.createExplicitListConstraint(new String[] {"选项1", "选项2"});
DataValidationConstraint constraint = helper.createExplicitListConstraint(new String[] {"Option1", "Option2"});
DataValidation validation = helper.createValidation(constraint, range);
context.getWriteSheetHolder().getSheet().addValidationData(validation);
}
}
```

Usage

```java
@Test
public void dropdownWrite() {
String fileName = "dropdownWrite" + System.currentTimeMillis() + ".xlsx";

FesodSheet.write(fileName, DemoData.class)
.registerWriteHandler(new DropdownWriteHandler())
.sheet("Dropdown Example")
.doWrite(data());
}
```

### Result

![img](/img/docs/write/customHandlerWrite.png)
The validation covers `A2:A11`, so every cell in that range offers the list. Selecting one shows the
dropdown button and its options - drawn open here on `A2`.

<table class="xl-sheet xl-sheet--overlay">
<tbody>
<tr><td class="xl-chrome"></td><td class="xl-chrome">A</td><td class="xl-chrome">B</td><td class="xl-chrome">C</td></tr>
<tr><td class="xl-chrome">1</td><td class="xl-head">String Title</td><td class="xl-head">Date Title</td><td class="xl-head">Number Title</td></tr>
<tr><td class="xl-chrome">2</td><td class="xl-dropdown">String0<b class="xl-dropdown-btn">▾</b><b class="xl-dropdown-list"><b>Option1</b><b>Option2</b></b></td><td class="xl-num">2026-07-31 20:50:23</td><td class="xl-num">0.56</td></tr>
<tr><td class="xl-chrome">3</td><td>String1</td><td class="xl-num">2026-07-31 20:50:23</td><td class="xl-num">0.56</td></tr>
<tr><td class="xl-chrome">4</td><td>String2</td><td class="xl-num">2026-07-31 20:50:23</td><td class="xl-num">0.56</td></tr>
<tr><td class="xl-chrome">⋮</td><td class="xl-muted">…</td><td class="xl-muted">…</td><td class="xl-muted">…</td></tr>
<tr><td class="xl-chrome">11</td><td>String9</td><td class="xl-num">2026-07-31 20:50:23</td><td class="xl-num">0.56</td></tr>
</tbody>
</table>
20 changes: 15 additions & 5 deletions website/docs/sheet/write/format.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,15 @@ Supports date, number, or other custom formats through annotations.
@Setter
@EqualsAndHashCode
public class ConverterData {
@ExcelProperty(value = "字符串标题", converter = CustomStringStringConverter.class)
@ExcelProperty(value = "String Title", converter = CustomStringStringConverter.class)
private String string;

@DateTimeFormat("yyyy年MM月dd日HH时mm分ss秒")
@ExcelProperty("日期标题")
@DateTimeFormat("yyyy/MM/dd HH:mm:ss")
@ExcelProperty("Date Title")
private Date date;

@NumberFormat("#.##%")
@ExcelProperty("数字标题")
@ExcelProperty("Number Title")
private Double doubleData;
}
```
Expand All @@ -64,4 +64,14 @@ public void converterWrite() {

### Result

![img](/img/docs/write/converterWrite.png)
<table class="xl-sheet">
<tbody>
<tr><td class="xl-chrome"></td><td class="xl-chrome">A</td><td class="xl-chrome">B</td><td class="xl-chrome">C</td></tr>
<tr><td class="xl-chrome">1</td><td class="xl-head">String Title</td><td class="xl-head">Date Title</td><td class="xl-head">Number Title</td></tr>
<tr><td class="xl-chrome">2</td><td>Custom: String0</td><td>2024/12/03 20:50:23</td><td class="xl-num">56.%</td></tr>
<tr><td class="xl-chrome">3</td><td>Custom: String1</td><td>2024/12/03 20:50:23</td><td class="xl-num">56.%</td></tr>
<tr><td class="xl-chrome">4</td><td>Custom: String2</td><td>2024/12/03 20:50:23</td><td class="xl-num">56.%</td></tr>
<tr><td class="xl-chrome">⋮</td><td class="xl-muted">…</td><td class="xl-muted">…</td><td class="xl-muted">…</td></tr>
<tr><td class="xl-chrome">11</td><td>Custom: String9</td><td>2024/12/03 20:50:23</td><td class="xl-num">56.%</td></tr>
</tbody>
</table>
Loading
Loading