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
20 changes: 11 additions & 9 deletions website/docs/quickstart/example.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Below is an example of reading a spreadsheet document:

```java
// Implement the ReadListener interface to set up operations for reading data
public class DemoDataListener implements ReadListener<DemoData> {
class DemoDataListener implements ReadListener<DemoData> {
@Override
public void invoke(DemoData data, AnalysisContext context) {
System.out.println("Parsed a data entry" + JSON.toJSONString(data));
Expand All @@ -40,10 +40,11 @@ public class DemoDataListener implements ReadListener<DemoData> {
}
}

public static void main(String[] args) {
String fileName = "demo.xlsx";
void main() {
String pathname = "path/to/demo.xlsx";

// Read file
FesodSheet.read(fileName, DemoData.class, new DemoDataListener()).sheet().doRead();
FesodSheet.read(pathname, DemoData.class, new DemoDataListener()).sheet().doRead();
}
```

Expand All @@ -53,7 +54,7 @@ Below is a simple example of creating a spreadsheet document:

```java
// Sample data class
public class DemoData {
class DemoData {
@ExcelProperty("String Title")
private String string;
@ExcelProperty("Date Title")
Expand All @@ -65,7 +66,7 @@ public class DemoData {
}

// Prepare data to write
private static List<DemoData> data() {
List<DemoData> data() {
List<DemoData> list = new ArrayList<>();
for (int i = 0; i < 10; i++) {
DemoData data = new DemoData();
Expand All @@ -77,9 +78,10 @@ private static List<DemoData> data() {
return list;
}

public static void main(String[] args) {
String fileName = "demo.xlsx";
void main() {
String pathname = "path/to/demo.xlsx";

// Create a "Template" sheet and write data
FesodSheet.write(fileName, DemoData.class).sheet("Template").doWrite(data());
FesodSheet.write(pathname, DemoData.class).sheet("Template").doWrite(data());
}
```
14 changes: 6 additions & 8 deletions website/docs/sheet/advanced/custom-converter.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,10 @@ public class CustomStringStringConverter implements Converter<String> {
### Write with Global Converter

```java
@Test
public void customConverterWrite() {
String fileName = "customConverterWrite" + System.currentTimeMillis() + ".xlsx";
void main() {
String pathname = "path/to/demo.xlsx";

FesodSheet.write(fileName, DemoData.class)
FesodSheet.write(pathname, DemoData.class)
.registerConverter(new CustomStringStringConverter())
.sheet()
.doWrite(data());
Expand All @@ -92,11 +91,10 @@ public void customConverterWrite() {
### Read with Global Converter

```java
@Test
public void customConverterRead() {
String fileName = "path/to/demo.xlsx";
void main() {
String pathname = "path/to/demo.xlsx";

FesodSheet.read(fileName, DemoData.class, new DemoDataListener())
FesodSheet.read(pathname, DemoData.class, new DemoDataListener())
.registerConverter(new CustomStringStringConverter())
.sheet()
.doRead();
Expand Down
7 changes: 3 additions & 4 deletions website/docs/sheet/advanced/large-file.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,10 @@ When exporting large datasets (e.g., database dumps, log analysis), loading all
### Code Example

```java
@Test
public void largeFileWrite() {
String fileName = "largeFile" + System.currentTimeMillis() + ".xlsx";
void main() {
String pathname = "path/to/demo.xlsx";

try (ExcelWriter excelWriter = FesodSheet.write(fileName, DemoData.class)
try (ExcelWriter excelWriter = FesodSheet.write(pathname, DemoData.class)
.registerWriteHandler(new WorkbookWriteHandler() {
@Override
public void afterWorkbookCreate(WorkbookWriteHandlerContext context) {
Expand Down
14 changes: 6 additions & 8 deletions website/docs/sheet/advanced/password.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,10 @@ Fesod supports Excel's built-in password protection for both reading and writing
### Code Example

```java
@Test
public void passwordWrite() {
String fileName = "passwordWrite" + System.currentTimeMillis() + ".xlsx";
void main() {
String pathname = "path/to/demo.xlsx";

FesodSheet.write(fileName)
FesodSheet.write(pathname)
.password("your_password")
.head(DemoData.class)
.sheet("PasswordSheet")
Expand All @@ -52,11 +51,10 @@ public void passwordWrite() {
### Code Example

```java
@Test
public void passwordRead() {
String fileName = "path/to/encrypted.xlsx";
void main() {
String pathname = "path/to/demo.xlsx";

FesodSheet.read(fileName, DemoData.class, new DemoDataListener())
FesodSheet.read(pathname, DemoData.class, new DemoDataListener())
.password("your_password")
.sheet()
.doRead();
Expand Down
60 changes: 31 additions & 29 deletions website/docs/sheet/fill/fill.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,25 +87,26 @@ private List<FillData> data() {
### Code Example

```java
@Test
public void simpleFill() {
String templateFileName = "path/to/simple.xlsx";
void main() {
String template = "path/from/demo.xlsx";
String pathname0 = "path/to/demo0.xlsx";
String pathname1 = "path/to/demo1.xlsx";

// Approach 1: Fill based on object
FillData fillData = new FillData();
fillData.setName("John Doe");
fillData.setNumber(5.2);
FesodSheet.write("simpleFill.xlsx")
.withTemplate(templateFileName)
FesodSheet.write(pathname0)
.withTemplate(template)
.sheet()
.doFill(fillData);

// Approach 2: Fill based on Map
Map<String, Object> map = new HashMap<>();
map.put("name", "John Doe");
map.put("number", 5.2);
FesodSheet.write("simpleFillMap.xlsx")
.withTemplate(templateFileName)
FesodSheet.write(pathname1)
.withTemplate(template)
.sheet()
.doFill(map);
}
Expand Down Expand Up @@ -146,18 +147,19 @@ Fill multiple data items into a template list, supporting in-memory batch operat
### Code Example

```java
@Test
public void listFill() {
String templateFileName = "path/to/list.xlsx";
void main() {
String template = "path/from/demo.xlsx";
String pathname0 = "path/to/demo0.xlsx";
String pathname1 = "path/to/demo1.xlsx";

// Approach 1: Fill all data at once
FesodSheet.write("listFill.xlsx")
.withTemplate(templateFileName)
FesodSheet.write(pathname0)
.withTemplate(template)
.sheet()
.doFill(data());

// Approach 2: Batch filling
try (ExcelWriter writer = FesodSheet.write("listFillBatch.xlsx").withTemplate(templateFileName).build()) {
try (ExcelWriter writer = FesodSheet.write(pathname1).withTemplate(template).build()) {
WriteSheet writeSheet = FesodSheet.writerSheet().build();
writer.fill(data(), writeSheet);
writer.fill(data(), writeSheet);
Expand Down Expand Up @@ -223,11 +225,11 @@ Fill various data types in a template, including lists and regular variables.
### Code Example

```java
@Test
public void complexFill() {
String templateFileName = "path/to/complex.xlsx";
void main() {
String template = "path/from/demo.xlsx";
String pathname = "path/to/demo.xlsx";

try (ExcelWriter writer = FesodSheet.write("complexFill.xlsx").withTemplate(templateFileName).build()) {
try (ExcelWriter writer = FesodSheet.write(pathname).withTemplate(template).build()) {
WriteSheet writeSheet = FesodSheet.writerSheet().build();

// Fill list data, with forceNewRow enabled
Expand Down Expand Up @@ -289,11 +291,11 @@ filled using `WriteTable`.
### Code Example

```java
@Test
public void complexFillWithTable() {
String templateFileName = "path/to/complexFillWithTable.xlsx";
void main() {
String template = "path/from/demo.xlsx";
String pathname = "path/to/demo.xlsx";

try (ExcelWriter writer = FesodSheet.write("complexFillWithTable.xlsx").withTemplate(templateFileName).build()) {
try (ExcelWriter writer = FesodSheet.write(pathname).withTemplate(template).build()) {
WriteSheet writeSheet = FesodSheet.writerSheet().build();

// Fill list data
Expand Down Expand Up @@ -360,11 +362,11 @@ Fill list data horizontally, suitable for scenarios with dynamic column numbers.
### Code Example

```java
@Test
public void horizontalFill() {
String templateFileName = "path/to/horizontal.xlsx";
void main() {
String template = "path/from/demo.xlsx";
String pathname = "path/to/demo.xlsx";

try (ExcelWriter writer = FesodSheet.write("horizontalFill.xlsx").withTemplate(templateFileName).build()) {
try (ExcelWriter writer = FesodSheet.write(pathname).withTemplate(template).build()) {
WriteSheet writeSheet = FesodSheet.writerSheet().build();

FillConfig config = FillConfig.builder().direction(WriteDirectionEnum.HORIZONTAL).build();
Expand Down Expand Up @@ -418,11 +420,11 @@ Support filling multiple lists simultaneously, with prefixes to differentiate be
### Code Example

```java
@Test
public void compositeFill() {
String templateFileName = "path/to/composite.xlsx";
void main() {
String template = "path/from/demo.xlsx";
String pathname = "path/to/demo.xlsx";

try (ExcelWriter writer = FesodSheet.write("compositeFill.xlsx").withTemplate(templateFileName).build()) {
try (ExcelWriter writer = FesodSheet.write(pathname).withTemplate(template).build()) {
WriteSheet writeSheet = FesodSheet.writerSheet().build();

// Use FillWrapper for filling multiple lists
Expand Down
Loading
Loading