Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import java.util.List;
import java.util.Map;
import org.apache.fesod.sheet.ExcelWriter;
import org.apache.fesod.sheet.FastExcel;
import org.apache.fesod.sheet.FesodSheet;
import org.apache.fesod.sheet.enums.WriteDirectionEnum;
import org.apache.fesod.sheet.util.ListUtils;
import org.apache.fesod.sheet.util.MapUtils;
Expand Down Expand Up @@ -63,15 +63,15 @@ public void simpleFill() {
FillData fillData = new FillData();
fillData.setName("Zhang San");
fillData.setNumber(5.2);
FastExcel.write(fileName).withTemplate(templateFileName).sheet().doFill(fillData);
FesodSheet.write(fileName).withTemplate(templateFileName).sheet().doFill(fillData);

// Option 2: Fill based on a Map
fileName = TestFileUtil.getPath() + "simpleFill" + System.currentTimeMillis() + ".xlsx";
// This will fill the first sheet, and the file stream will be automatically closed.
Map<String, Object> map = MapUtils.newHashMap();
map.put("name", "Zhang San");
map.put("number", 5.2);
FastExcel.write(fileName).withTemplate(templateFileName).sheet().doFill(map);
FesodSheet.write(fileName).withTemplate(templateFileName).sheet().doFill(map);
}

/**
Expand All @@ -92,13 +92,13 @@ public void listFill() {
// Option 1: Load all data into memory at once and fill
String fileName = TestFileUtil.getPath() + "listFill" + System.currentTimeMillis() + ".xlsx";
// This will fill the first sheet, and the file stream will be automatically closed.
FastExcel.write(fileName).withTemplate(templateFileName).sheet().doFill(data());
FesodSheet.write(fileName).withTemplate(templateFileName).sheet().doFill(data());

// Option 2: Fill in multiple passes, using file caching (saves memory)
fileName = TestFileUtil.getPath() + "listFill" + System.currentTimeMillis() + ".xlsx";
try (ExcelWriter excelWriter =
FastExcel.write(fileName).withTemplate(templateFileName).build()) {
WriteSheet writeSheet = FastExcel.writerSheet().build();
FesodSheet.write(fileName).withTemplate(templateFileName).build()) {
WriteSheet writeSheet = FesodSheet.writerSheet().build();
excelWriter.fill(data(), writeSheet);
excelWriter.fill(data(), writeSheet);
}
Expand All @@ -120,8 +120,8 @@ public void complexFill() {
String fileName = TestFileUtil.getPath() + "complexFill" + System.currentTimeMillis() + ".xlsx";
// Option 1
try (ExcelWriter excelWriter =
FastExcel.write(fileName).withTemplate(templateFileName).build()) {
WriteSheet writeSheet = FastExcel.writerSheet().build();
FesodSheet.write(fileName).withTemplate(templateFileName).build()) {
WriteSheet writeSheet = FesodSheet.writerSheet().build();
// Note: The forceNewRow parameter is used here. When writing a list, it will always create a new row, and
// the data below will be shifted down. Default is false, which will use the next row if available,
// otherwise create a new one.
Expand Down Expand Up @@ -160,8 +160,8 @@ public void complexFillWithTable() {

// Option 1
try (ExcelWriter excelWriter =
FastExcel.write(fileName).withTemplate(templateFileName).build()) {
WriteSheet writeSheet = FastExcel.writerSheet().build();
FesodSheet.write(fileName).withTemplate(templateFileName).build()) {
WriteSheet writeSheet = FesodSheet.writerSheet().build();
// Directly write data
excelWriter.fill(data(), writeSheet);
excelWriter.fill(data(), writeSheet);
Expand Down Expand Up @@ -206,8 +206,8 @@ public void horizontalFill() {
String fileName = TestFileUtil.getPath() + "horizontalFill" + System.currentTimeMillis() + ".xlsx";
// Option 1
try (ExcelWriter excelWriter =
FastExcel.write(fileName).withTemplate(templateFileName).build()) {
WriteSheet writeSheet = FastExcel.writerSheet().build();
FesodSheet.write(fileName).withTemplate(templateFileName).build()) {
WriteSheet writeSheet = FesodSheet.writerSheet().build();
FillConfig fillConfig = FillConfig.builder()
.direction(WriteDirectionEnum.HORIZONTAL)
.build();
Expand Down Expand Up @@ -238,8 +238,8 @@ public void compositeFill() {

// Option 1
try (ExcelWriter excelWriter =
FastExcel.write(fileName).withTemplate(templateFileName).build()) {
WriteSheet writeSheet = FastExcel.writerSheet().build();
FesodSheet.write(fileName).withTemplate(templateFileName).build()) {
WriteSheet writeSheet = FesodSheet.writerSheet().build();
FillConfig fillConfig = FillConfig.builder()
.direction(WriteDirectionEnum.HORIZONTAL)
.build();
Expand Down Expand Up @@ -278,7 +278,7 @@ public void dateFormatFill() {

// Fill the template with data.
// The dates in the data will be formatted according to the template's settings.
FastExcel.write(fileName).withTemplate(templateFileName).sheet().doFill(data());
FesodSheet.write(fileName).withTemplate(templateFileName).sheet().doFill(data());
}

@Test
Expand All @@ -289,7 +289,7 @@ public void testFillSheetDispose() {
FillData fillData = new FillData();
fillData.setName("Zhang San");
fillData.setNumber(5.2);
FastExcel.write(fileName)
FesodSheet.write(fileName)
.withTemplate(templateFileName)
.sheet()
.registerWriteHandler(new SheetWriteHandler() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import java.util.List;
import lombok.extern.slf4j.Slf4j;
import org.apache.fesod.sheet.ExcelWriter;
import org.apache.fesod.sheet.FastExcel;
import org.apache.fesod.sheet.FesodSheet;
import org.apache.fesod.sheet.demo.read.DemoData;
import org.apache.fesod.sheet.util.FileUtils;
import org.apache.fesod.sheet.util.ListUtils;
Expand Down Expand Up @@ -61,7 +61,7 @@ public void compressedTemporaryFile() {
File file = TestFileUtil.createNewFile("rare/compressedTemporaryFile" + System.currentTimeMillis() + ".xlsx");

// Specify which class to use for writing here
try (ExcelWriter excelWriter = FastExcel.write(file, DemoData.class)
try (ExcelWriter excelWriter = FesodSheet.write(file, DemoData.class)
.registerWriteHandler(new WorkbookWriteHandler() {

/**
Expand All @@ -83,7 +83,7 @@ public void afterWorkbookCreate(WorkbookWriteHandlerContext context) {
})
.build()) {
// Note that the same sheet should only be created once
WriteSheet writeSheet = FastExcel.writerSheet("Template").build();
WriteSheet writeSheet = FesodSheet.writerSheet("Template").build();
// 100,000 data entries to ensure sufficient space
for (int i = 0; i < 10000; i++) {
// Query data from the database page by page. Here you can query data for each page from the database
Expand All @@ -107,7 +107,7 @@ public void specifiedCellWrite() {
// event
// If it is after the last row, since there will be no more data afterwards, just intercept the
// afterWorkbookDispose event and write the data when the Excel file is almost done
FastExcel.write(file, DemoData.class)
FesodSheet.write(file, DemoData.class)
// Writing value before the last row
.registerWriteHandler(new RowWriteHandler() {
@Override
Expand Down
Loading
Loading