Skip to main content

Formatting

This chapter introduces data formatting when writing data.

Custom Format Writing

Overview

Supports date, number, or other custom formats through annotations.

POJO Class

@Getter
@Setter
@EqualsAndHashCode
public class ConverterData {
@ExcelProperty(value = "String Title", converter = CustomStringStringConverter.class)
private String string;

@DateTimeFormat("yyyy/MM/dd HH:mm:ss")
@ExcelProperty("Date Title")
private Date date;

@NumberFormat("#.##%")
@ExcelProperty("Number Title")
private Double doubleData;
}

Code Example

@Test
public void converterWrite() {
String fileName = "converterWrite" + System.currentTimeMillis() + ".xlsx";
FesodSheet.write(fileName, ConverterData.class)
.sheet()
.doWrite(data());
}

Result

ABC
1String TitleDate TitleNumber Title
2Custom: String02024/12/03 20:50:2356.%
3Custom: String12024/12/03 20:50:2356.%
4Custom: String22024/12/03 20:50:2356.%
11Custom: String92024/12/03 20:50:2356.%