### Start Local Development Server (English) Source: https://github.com/apache/fesod/blob/main/website/README.md Starts a local development server to preview the English version of the website. Changes are reflected live. ```bash pnpm start ``` -------------------------------- ### Start Local Development Server (Chinese) Source: https://github.com/apache/fesod/blob/main/website/README.md Starts a local development server to preview the Chinese version of the website. Changes are reflected live. ```bash pnpm start --locale zh-cn ``` -------------------------------- ### Start Local Development Server Source: https://github.com/apache/fesod/blob/main/website/community/contribution/contribute-doc.md Start the Docusaurus local development server. Specify the locale for different language versions. ```bash # English pnpm start # Simplified Chinese pnpm start --locale zh-cn ``` -------------------------------- ### Install Dependencies with PNPM Source: https://github.com/apache/fesod/blob/main/website/README.md Installs project dependencies using PNPM. Ensure Node.js v20.0 or above is installed. ```bash pnpm install ``` -------------------------------- ### GPG Key Generation Interactive Prompt Source: https://github.com/apache/fesod/blob/main/website/community/release/release-version.md This is an example of the interactive prompt when generating a GPG key. It guides the user through setting key type, size, validity period, and user ID. ```text gpg (GnuPG) 2.2.4; Copyright (C) 2017 Free Software Foundation, Inc. This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Please select what kind of key you want: (1) RSA and RSA (default) (2) DSA and Elgamal (3) DSA (sign only) (4) RSA (sign only) Your selection? 1 RSA keys may be between 1024 and 4096 bits long. What keysize do you want? (2048) 4096 Requested keysize is 4096 bits Please specify how long the key should be valid. 0 = key does not expire = key expires in n days w = key expires in n weeks m = key expires in n months y = key expires in n years Key is valid for? (0) Key does not expire at all Is this correct? (y/N) y GnuPG needs to construct a user ID to identify your key. Real name: (Set username) (Use Apache ID) Email address: (Set email address) (Use Apache email) Comment: (Fill in comments) You selected this USER-ID: "Username (Comment) " Change (N)ame, (C)omment, (E)mail or (O)kay/(Q)uit? O You need a Passphrase to protect your secret key. (Set password) (Set password) ``` -------------------------------- ### Image Path Example Source: https://github.com/apache/fesod/blob/main/website/community/contribution/contribute-doc.md Image files should be stored in the static/img directory and referenced using relative paths. ```markdown [img](/img/docs/fill/listFill_file.png) ``` -------------------------------- ### Write Data with Annotation Styles Source: https://github.com/apache/fesod/blob/main/website/docs/sheet/write/style.md This example demonstrates how to write data to an Excel file using the styles defined via annotations in the POJO class. ```java @Test public void annotationStyleWrite() { String fileName = "annotationStyleWrite" + System.currentTimeMillis() + ".xlsx"; FesodSheet.write(fileName, DemoStyleData.class) .sheet() .doWrite(data()); } ``` -------------------------------- ### Markdown Link Example Source: https://github.com/apache/fesod/blob/main/website/community/contribution/contribute-doc.md Use file paths with the .md extension for internal links. ```markdown [Example](docs/quickstart/example.md) ``` -------------------------------- ### Start Vote Email Template Source: https://github.com/apache/fesod/blob/main/website/community/pmc/nominate-committer.md Use this template to start the official voting process for a nominated committer. Include a link to the discussion thread and specify voting instructions. ```text [VOTE] Add candidate ${CANDIDATE_NAME} as a new committer ``` ```text Hi all, This is a VOTE to add candidate ${CANDIDATE_NAME} (GitHub id: ${CANDIDATE_GITHUB_ID}) as a new committer. This has been discussed here: [Link to DISCUSS thread on lists.apache.org] If you have more to add to the discussion, please do so there, rather than in this VOTE thread. Please vote accordingly: [ +1 ] Yes, add this committer [ 0 ] Abstain [ -1 ] No, do not add this committer Voting ends one week from today, i.e. midnight UTC on YYYY-MM-DD https://www.timeanddate.com/counters/customcounter.html?year=YYYY&month=MM&day=DD See voting guidelines at https://community.apache.org/pmc/adding-committers.html ``` -------------------------------- ### Write Excel with Custom Merge Strategy Source: https://github.com/apache/fesod/blob/main/website/docs/sheet/write/merge.md This example shows how to register and use a `CustomMergeStrategy` when writing an Excel file. This allows for complex, data-driven cell merging. ```java import com.fesod.FesodSheet; import org.junit.jupiter.api.Test; import java.util.ArrayList; import java.util.Date; import java.util.List; public class CustomMergeTest { @Test public void customMergeWrite() { String fileName = "customMergeWrite" + System.currentTimeMillis() + ".xlsx"; FesodSheet.write(fileName, DemoData.class) .registerWriteHandler(new CustomMergeStrategy()) .sheet() .doWrite(data()); } // Assuming DemoData is a placeholder class for demonstration public static class DemoData { // ... fields ... } private List data() { List list = new ArrayList<>(); // ... populate data ... return list; } } ``` -------------------------------- ### Write Spreadsheet Data with Fesod Source: https://github.com/apache/fesod/blob/main/website/docs/quickstart/example.md Prepare data using a sample data class and write it to a spreadsheet file. This example demonstrates creating a 'Template' sheet and performing the write operation. ```java // Sample data class public class DemoData { @ExcelProperty("String Title") private String string; @ExcelProperty("Date Title") private Date date; @ExcelProperty("Number Title") private Double doubleData; @ExcelIgnore private String ignore; } // Prepare data to write private static List data() { List list = new ArrayList<>(); for (int i = 0; i < 10; i++) { DemoData data = new DemoData(); data.setString("String" + i); data.setDate(new Date()); data.setDoubleData(0.56); list.add(data); } return list; } public static void main(String[] args) { String fileName = "demo.xlsx"; // Create a "Template" sheet and write data FesodSheet.write(fileName, DemoData.class).sheet("Template").doWrite(data()); } ``` -------------------------------- ### Write Excel with Strategy-Based Merging Source: https://github.com/apache/fesod/blob/main/website/docs/sheet/write/merge.md This example demonstrates writing to an Excel file using a `LoopMergeStrategy` to merge every 2 rows in column 0. This strategy is flexible and can be configured at runtime. ```java import com.fesod.FesodSheet; import com.fesod.write.handler.impl.LoopMergeStrategy; import org.junit.jupiter.api.Test; import java.util.ArrayList; import java.util.Date; import java.util.List; public class StrategyMergeTest { @Test public void strategyMergeWrite() { String fileName = "strategyMergeWrite" + System.currentTimeMillis() + ".xlsx"; // Merge every 2 rows in column 0 LoopMergeStrategy strategy = new LoopMergeStrategy(2, 0); FesodSheet.write(fileName, DemoData.class) .registerWriteHandler(strategy) .sheet() .doWrite(data()); } // Assuming DemoData is a placeholder class for demonstration public static class DemoData { // ... fields ... } private List data() { List list = new ArrayList<>(); // ... populate data ... return list; } } ``` -------------------------------- ### Write Complex Headers to Excel Source: https://github.com/apache/fesod/blob/main/website/docs/sheet/write/head.md This example demonstrates how to write data with complex headers defined in a POJO class to an Excel file using Fesod. ```java @Test public void complexHeadWrite() { String fileName = "complexHeadWrite" + System.currentTimeMillis() + ".xlsx"; FesodSheet.write(fileName, ComplexHeadData.class) .sheet() .doWrite(data()); } ``` -------------------------------- ### Write Spreadsheet Data with Apache Fesod Source: https://github.com/apache/fesod/blob/main/README.md Example of creating a spreadsheet and writing data using FesodSheet. The DemoData class should be defined with @ExcelProperty and @ExcelIgnore annotations as needed. ```java // Sample data class public class DemoData { @ExcelProperty("String Title") private String string; @ExcelProperty("Date Title") private Date date; @ExcelProperty("Number Title") private Double doubleData; @ExcelIgnore private String ignore; } // Prepare data to write private static List data() { List list = new ArrayList<>(); for (int i = 0; i < 10; i++) { DemoData data = new DemoData(); data.setString("String" + i); data.setDate(new Date()); data.setDoubleData(0.56); list.add(data); } return list; } public static void main(String[] args) { String fileName = "demo.xlsx"; // Create a "Template" sheet and write data FesodSheet.write(fileName, DemoData.class).sheet("Template").doWrite(data()); } ``` -------------------------------- ### Example Commit Messages Source: https://github.com/apache/fesod/blob/main/website/community/contribution/commit-format.md Illustrates the correct format for various types of commit messages, such as documentation updates, new features, bug fixes, refactoring, style changes, tests, chores, and dependency updates. ```git docs: update README.md ``` ```git feature: support for xxx ``` ```git fix: fix NPE in the A class ``` ```git refactor: optimise data processing logic ``` ```git style: update code style ``` ```git test: add new test cases ``` ```git chore: improve issue template ``` ```git dependency: upgrade poi version to 5.4.1 ``` -------------------------------- ### Custom Cell Styles with WriteHandler Source: https://github.com/apache/fesod/blob/main/website/docs/sheet/help/faq.md Customize cell styles during writing by implementing the WriteHandler interface. This example shows how to set a red background for content cells. ```java public class CustomCellStyleWriteHandler extends AbstractCellStyleStrategy { @Override public int order() { // Customize the execution order return OrderConstant.SHEET_ORDER; } @Override protected void setHeadCellStyle(CellWriteHandlerContext context) { // Customize the head cell style } @Override protected void setContentCellStyle(Cell cell, Head head, Integer relativeRowIndex) { CellStyle style = cell.getSheet().getWorkbook().createCellStyle(); style.setFillForegroundColor(IndexedColors.RED.getIndex()); style.setFillPattern(FillPatternType.SOLID_FOREGROUND); cell.setCellStyle(style); } } ``` -------------------------------- ### Set Custom Cell Style Source: https://github.com/apache/fesod/blob/main/website/docs/sheet/help/core-class.md Implement CellWriteHandler to customize cell styles. This example sets the background to yellow and font to blue for content cells. ```java import org.apache.commons.lang3.BooleanUtils; import com.fesod.sheet.handler.CellWriteHandler; import com.fesod.sheet.handler.CellWriteHandlerContext; import com.fesod.sheet.write.WriteCellData; import com.fesod.sheet.write.WriteCellStyle; import com.fesod.sheet.write.WriteFont; import com.fesod.sheet.write.style.FillPatternType; import com.fesod.sheet.write.style.IndexedColors; import lombok.extern.slf4j.Slf4j; @Slf4j public class CustomCellStyleHandler implements CellWriteHandler { @Override public void afterCellDispose(CellWriteHandlerContext context) { // Ensure only content cells (not headers) are operated on if (BooleanUtils.isNotTrue(context.getHead())) { WriteCellData cellData = context.getFirstCellData(); WriteCellStyle style = cellData.getOrCreateStyle(); // Set background color to yellow style.setFillForegroundColor(IndexedColors.YELLOW.getIndex()); style.setFillPatternType(FillPatternType.SOLID_FOREGROUND); // Set font color to blue WriteFont font = new WriteFont(); font.setColor(IndexedColors.BLUE.getIndex()); style.setWriteFont(font); log.info("Style set: Row {}, Column {}", context.getRowIndex(), context.getColumnIndex()); } } } ``` ```java import org.junit.jupiter.api.Test; import com.fesod.sheet.FesodSheet; import com.fesod.sheet.demo.DemoData; public class ExcelWriteTest { @Test public void customCellStyleWrite() { String fileName = "customCellStyleWrite.xlsx"; FesodSheet.write(fileName, DemoData.class) .registerWriteHandler(new CustomCellStyleHandler()) .sheet("Custom Style") .doWrite(data()); } private Object[][] data() { return new Object[][]{ // Add your demo data here }; } } ``` -------------------------------- ### Import GPG KEYS Source: https://github.com/apache/fesod/blob/main/website/community/release/verify-release.md Download the KEYS file from the distribution directory and import it into your local GPG keyring. This is necessary for signature verification. ```shell # Download KEYS curl https://dist.apache.org/repos/dist/dev/incubator/fesod/KEYS > KEYS # Import KEYS locally gpg --import KEYS ``` -------------------------------- ### Import GPG Keys Source: https://github.com/apache/fesod/blob/main/website/docs/download.md Import the project release KEYS file to your GPG keyring to enable signature verification. ```bash gpg --import KEYS ``` -------------------------------- ### Prepare Release Branch and Tag Source: https://github.com/apache/fesod/blob/main/website/community/release/release-version.md Commands to checkout the main branch, pull updates, create a GPG signed tag, and push it to the remote repository. ```bash # 1. Switch to the main branch and update git checkout main git pull # 2. Create a GPG signed Tag # Note: Ensure the content in -m is accurate git tag -s 2.0.0-incubating-rc1 -m "release: release for 2.0.0-incubating RC1" # 3. Push the Tag to the remote repository git push git@github.com:apache/fesod.git 2.0.0-incubating-rc1 ``` -------------------------------- ### Apply Code Formatting with Spotless Source: https://github.com/apache/fesod/blob/main/website/community/contribution/contribute-code.md Automatically format your code before submitting changes by running the Spotless Maven plugin. ```bash mvn spotless:apply ``` -------------------------------- ### Upload Source Package to SVN Source: https://github.com/apache/fesod/blob/main/website/community/release/release-version.md Checkout the SVN dev repository, create a version directory, copy release artifacts, and commit to SVN. ```bash # 1. Checkout SVN dev repository svn co https://dist.apache.org/repos/dist/dev/incubator/fesod/ cd fesod-dev # 2. Create version directory mkdir 2.0.0-incubating-rc1 cd 2.0.0-incubating-rc1 # 3. Copy files (assuming files are in the parent directory) cp ../../apache-fesod-2.0.0-incubating-src.tar.gz . cp ../../apache-fesod-2.0.0-incubating-src.tar.gz.asc . cp ../../apache-fesod-2.0.0-incubating-src.tar.gz.sha512 . # 4. Commit to SVN cd .. svn add 2.0.0-incubating-rc1 svn commit -m "Add 2.0.0-incubating-rc1 source release" ``` -------------------------------- ### Configure CSV Null String Source: https://github.com/apache/fesod/blob/main/website/docs/sheet/read/csv.md Specify a string that should be interpreted as a null value during CSV parsing. This example maps the string 'N/A' to null. ```java @Test public void nullStringDemo() { String csvFile = "path/to/your.csv"; List dataList = FesodSheet.read(csvFile, DemoData.class, new DemoDataListener()) .csv() .nullString("N/A") .doReadSync(); } ``` -------------------------------- ### Build Static Website Source: https://github.com/apache/fesod/blob/main/website/README.md Generates static content into the `build` directory, ready for deployment on any static hosting service. ```bash pnpm build ``` -------------------------------- ### Insert Comment in Header Cell Source: https://github.com/apache/fesod/blob/main/website/docs/sheet/help/core-class.md Implement RowWriteHandler to insert comments. This example adds a comment to the first row, second column of the header. ```java import org.apache.commons.lang3.BooleanUtils; import com.fesod.sheet.handler.RowWriteHandler; import com.fesod.sheet.handler.RowWriteHandlerContext; import org.apache.poi.ss.usermodel.Comment; import org.apache.poi.ss.usermodel.Drawing; import org.apache.poi.ss.usermodel.Sheet; import org.apache.poi.xssf.usermodel.XSSFClientAnchor; import org.apache.poi.xssf.usermodel.XSSFRichTextString; import lombok.extern.slf4j.Slf4j; @Slf4j public class CommentRowWriteHandler implements RowWriteHandler { @Override public void afterRowDispose(RowWriteHandlerContext context) { if (BooleanUtils.isTrue(context.getHead())) { Sheet sheet = context.getWriteSheetHolder().getSheet(); Drawing drawing = sheet.createDrawingPatriarch(); // Create a comment Comment comment = drawing.createCellComment(new XSSFClientAnchor(0, 0, 0, 0, (short) 1, 0, (short) 2, 1)); comment.setString(new XSSFRichTextString("This is a comment")); sheet.getRow(0).getCell(1).setCellComment(comment); log.info("Comment inserted at first row, second column"); } } } ``` ```java import org.junit.jupiter.api.Test; import com.fesod.sheet.FesodSheet; import com.fesod.sheet.demo.DemoData; public class ExcelWriteTest { @Test public void commentWrite() { String fileName = "commentWrite.xlsx"; FesodSheet.write(fileName, DemoData.class) .registerWriteHandler(new CommentRowWriteHandler()) .sheet("Insert Comment") .doWrite(data()); } private Object[][] data() { return new Object[][]{ // Add your demo data here }; } } ``` -------------------------------- ### Configure CSV Delimiter Source: https://github.com/apache/fesod/blob/main/website/docs/sheet/read/csv.md Set a custom delimiter for CSV files when the default comma is not used. This example uses a Unicode empty character as the delimiter. ```java @Test public void delimiterDemo() { String csvFile = "path/to/your.csv"; List dataList = FesodSheet.read(csvFile, DemoData.class, new DemoDataListener()) .csv() .delimiter(CsvConstant.UNICODE_EMPTY) .doReadSync(); } ``` -------------------------------- ### Compile Project with Maven Source: https://github.com/apache/fesod/blob/main/website/community/contribution/contribute-code.md Compile the project using Maven. Use '-DskipTests' to skip unit tests and '-T 1C' for parallel build to speed up the process. ```bash mvn clean install -DskipTests ``` -------------------------------- ### Deploy Maven Artifacts for Release Source: https://github.com/apache/fesod/blob/main/website/community/release/release-version.md Use this Maven command to clean, deploy, and skip tests for the release. Ensure GPG signing is enabled. ```bash mvn clean deploy -Papache-release -DskipTests -Dgpg.skip=false ``` -------------------------------- ### Configure Maven Settings for Release Source: https://github.com/apache/fesod/blob/main/website/community/release/release-version.md Add key information to your Maven settings.xml file for signed releases, including GPG key details and repository URLs. ```xml signed_release forked-path yourKeyName https://dist.apache.org/repos/dist/dev/incubator/fesod/ apache.snapshots.https yourApacheID yourApachePassword apache.releases.https yourApacheID yourApachePassword gpg.passphrase yourKeyPassword ``` -------------------------------- ### Download Release Artifacts Source: https://github.com/apache/fesod/blob/main/website/community/release/verify-release.md Download the release candidate artifacts. The SVN checkout method is recommended as it includes the KEYS file. ```shell # Option 1: SVN checkout (Recommended, includes KEYS file) svn co https://dist.apache.org/repos/dist/dev/incubator/fesod/${RELEASE_VERSION}-${RC_VERSION}/ fesod-dist-dev ``` ```shell # Option 2: Wget individual files wget https://dist.apache.org/repos/dist/dev/incubator/fesod/${RELEASE_VERSION}-${RC_VERSION}/apache-fesod-${RELEASE_VERSION}-src.tar.gz ``` -------------------------------- ### Add Dropdown List to Cells Source: https://github.com/apache/fesod/blob/main/website/docs/sheet/help/core-class.md Implement SheetWriteHandler to add data validation dropdown lists. This example creates a dropdown for the first column of the first two rows. ```java import com.fesod.sheet.handler.SheetWriteHandler; import com.fesod.sheet.handler.SheetWriteHandlerContext; import org.apache.poi.ss.usermodel.DataValidation; import org.apache.poi.ss.usermodel.DataValidationConstraint; import org.apache.poi.ss.usermodel.DataValidationHelper; import org.apache.poi.ss.usermodel.Sheet; import org.apache.poi.ss.util.CellRangeAddressList; import lombok.extern.slf4j.Slf4j; @Slf4j public class DropdownSheetWriteHandler implements SheetWriteHandler { @Override public void afterSheetCreate(SheetWriteHandlerContext context) { Sheet sheet = context.getWriteSheetHolder().getSheet(); // Create dropdown list range CellRangeAddressList range = new CellRangeAddressList(1, 2, 0, 0); DataValidationHelper helper = sheet.getDataValidationHelper(); DataValidationConstraint constraint = helper.createExplicitListConstraint(new String[]{"Option 1", "Option 2"}); DataValidation validation = helper.createValidation(constraint, range); sheet.addValidationData(validation); log.info("Dropdown list added to the first column of the first two rows"); } } ``` ```java import org.junit.jupiter.api.Test; import com.fesod.sheet.FesodSheet; import com.fesod.sheet.demo.DemoData; public class ExcelWriteTest { @Test public void dropdownWrite() { String fileName = "dropdownWrite.xlsx"; FesodSheet.write(fileName, DemoData.class) .registerWriteHandler(new DropdownSheetWriteHandler()) .sheet("Add Dropdown") .doWrite(data()); } private Object[][] data() { return new Object[][]{ // Add your demo data here }; } } ``` -------------------------------- ### Getting Approximate Total Rows Source: https://github.com/apache/fesod/blob/main/website/docs/sheet/help/faq.md Obtain an approximate total row count for a sheet within a listener using `context.readSheetHolder().getApproximateTotalRowNumber()`. This is useful for progress tracking or estimations. ```java @Override public void doAfterAllAnalysed(AnalysisContext context) { int totalRows = context.readSheetHolder().getApproximateTotalRowNumber(); System.out.println("Total rows: " + totalRows); } ``` -------------------------------- ### Read Spreadsheet Data with Fesod Source: https://github.com/apache/fesod/blob/main/website/docs/quickstart/example.md Implement the ReadListener interface to process data row by row during spreadsheet reading. This example shows how to define a listener and initiate the read operation. ```java // Implement the ReadListener interface to set up operations for reading data public class DemoDataListener implements ReadListener { @Override public void invoke(DemoData data, AnalysisContext context) { System.out.println("Parsed a data entry" + JSON.toJSONString(data)); } @Override public void doAfterAllAnalysed(AnalysisContext context) { System.out.println("All data parsed!"); } } public static void main(String[] args) { String fileName = "demo.xlsx"; // Read file FesodSheet.read(fileName, DemoData.class, new DemoDataListener()).sheet().doRead(); } ``` -------------------------------- ### Run Markdown Lint Check Source: https://github.com/apache/fesod/blob/main/website/community/contribution/contribute-doc.md Check document formatting using markdownlint-cli2. Navigate to the website directory first. ```bash cd website pnpm md-lint ``` -------------------------------- ### Build Fesod from Source Source: https://github.com/apache/fesod/blob/main/website/community/release/release-version.md Command to build the Apache Fesod project from source using Maven wrapper, skipping tests. Requires JDK 8+ and Apache Maven 3.6.0+. ```bash ./mvnw clean package -DskipTests ``` -------------------------------- ### Configure CSV Record Separator Source: https://github.com/apache/fesod/blob/main/website/docs/sheet/read/csv.md Define the record separator for CSV files, which can vary by operating system. This example sets the record separator to LF, commonly used in Unix/Linux systems. ```java @Test public void recordSeparatorDemo() { String csvFile = "path/to/your.csv"; List dataList = FesodSheet.read(csvFile, DemoData.class, new DemoDataListener()) .csv() .recordSeparator(CsvConstant.LF) .doReadSync(); } ``` -------------------------------- ### Override onException Method in Listener Source: https://github.com/apache/fesod/blob/main/website/docs/sheet/read/exception.md Override the onException method to handle exceptions during data reading. This example shows how to log general exceptions and specifically catch ExcelDataConvertException for detailed error information. ```java import com.alibaba.excel.context.AnalysisContext; import com.alibaba.excel.event.AnalysisEventListener; import com.alibaba.excel.exception.ExcelDataConvertException; import lombok.extern.slf4j.Slf4j; @Slf4j public class DemoExceptionListener extends AnalysisEventListener { @Override public void onException(Exception exception, AnalysisContext context) { log.error("Failed: {}", exception.getMessage()); if (exception instanceof ExcelDataConvertException) { ExcelDataConvertException ex = (ExcelDataConvertException) exception; log.error("Row {}, Column {} exception, data: {}", ex.getRowIndex(), ex.getColumnIndex(), ex.getCellData()); } } @Override public void invoke(ExceptionDemoData data, AnalysisContext context) {} @Override public void doAfterAllAnalysed(AnalysisContext context) {} } ``` -------------------------------- ### Read Spreadsheet Data with Apache Fesod Source: https://github.com/apache/fesod/blob/main/README.md Example of reading spreadsheet data using FesodSheet. Implement the ReadListener interface to process each row. Ensure DemoData class is defined with appropriate annotations. ```java // Implement the ReadListener interface to set up operations for reading data public class DemoDataListener implements ReadListener { @Override public void invoke(DemoData data, AnalysisContext context) { System.out.println("Parsed a data entry" + JSON.toJSONString(data)); } @Override public void doAfterAllAnalysed(AnalysisContext context) { System.out.println("All data parsed!"); } } public static void main(String[] args) { String fileName = "demo.xlsx"; // Read spreadsheet file FesodSheet.read(fileName, DemoData.class, new DemoDataListener()).sheet().doRead(); } ``` -------------------------------- ### Writing Excel with Merging Source: https://github.com/apache/fesod/blob/main/website/docs/sheet/write/extra.md Demonstrates how to write Excel files using both annotation-based and custom merge strategies. Ensure data is provided to the doWrite method. ```java @Test public void mergeWrite() { String fileName = "mergeWrite" + System.currentTimeMillis() + ".xlsx"; // Annotation approach FesodSheet.write(fileName, DemoMergeData.class) .sheet("合并示例") .doWrite(data()); // Custom merge strategy FesodSheet.write(fileName, DemoData.class) .registerWriteHandler(new CustomMergeStrategy()) .sheet("自定义合并") .doWrite(data()); } ``` -------------------------------- ### Verify Release Artifacts Source: https://github.com/apache/fesod/blob/main/website/community/release/release-version.md Verify the integrity and authenticity of the downloaded source package using GPG and SHA512 checksums. ```bash gpg --verify apache-fesod-2.0.0-incubating-src.tar.gz.asc apache-fesod-2.0.0-incubating-src.tar.gz sha512sum -c apache-fesod-2.0.0-incubating-src.tar.gz.sha512 ``` -------------------------------- ### Read Merged Cells with Listener - Java Source: https://github.com/apache/fesod/blob/main/website/docs/sheet/read/extra.md Implement a ReadListener to process merged cell range information. The `extra` method checks for `CellExtraTypeEnum.MERGE` and logs the start and end row indices of the merged area. ```java @Slf4j public class DemoMergeExtraListener implements ReadListener { @Override public void invoke(DemoData data, AnalysisContext context) {} @Override public void doAfterAllAnalysed(AnalysisContext context) {} @Override public void extra(CellExtra extra, AnalysisContext context) { log.info("Read extra information: {}", JSON.toJSONString(extra)); if(CellExtraTypeEnum.MERGE == extra.getType()) { log.info("Merged cell range: {} - {}", extra.getFirstRowIndex(), extra.getLastRowIndex()); } } } ``` -------------------------------- ### Custom Merge Strategy Implementation Source: https://github.com/apache/fesod/blob/main/website/docs/sheet/write/merge.md Implement `AbstractMergeStrategy` to define complex merging logic based on data content or custom rules. This example merges cells in column 0 every two rows. ```java import com.fesod.write.handler.AbstractMergeStrategy; import com.fesod.write.handler.Head; import org.apache.poi.ss.usermodel.Cell; import org.apache.poi.ss.usermodel.Sheet; import org.apache.poi.ss.util.CellRangeAddress; public class CustomMergeStrategy extends AbstractMergeStrategy { @Override protected void merge(Sheet sheet, Cell cell, Head head, Integer relativeRowIndex) { if (relativeRowIndex != null && relativeRowIndex % 2 == 0 && head.getColumnIndex() == 0) { // Note: +1 assumes a single header row. For multi-row headers, use cell.getRowIndex() instead. int startRow = relativeRowIndex + 1; int endRow = startRow + 1; sheet.addMergedRegion(new CellRangeAddress(startRow, endRow, 0, 0)); } } } ``` -------------------------------- ### Compile Source Code Source: https://github.com/apache/fesod/blob/main/website/community/release/verify-release.md Compile the source code using Maven, skipping tests. This verifies that the code compiles successfully and downloads necessary dependencies. ```shell # This may take time depending on network to download dependencies ./mvnw clean install -DskipTests ``` -------------------------------- ### POJO with Per-Field Converter Annotation Source: https://github.com/apache/fesod/blob/main/website/docs/sheet/write/converter.md Annotate a POJO field with `@ExcelProperty` and specify a custom converter class to apply specific data transformations for that field during Excel writing. This example applies `CustomStringStringConverter` to the 'string' field. ```java @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; } ``` -------------------------------- ### Verify GPG Signature Source: https://github.com/apache/fesod/blob/main/website/docs/download.md Verify the GPG signature of the downloaded source release using the .asc signature file. ```bash gpg --verify apache-fesod-X.X.X-incubating-src.tar.gz.asc apache-fesod-X.X.X-incubating-src.tar.gz ``` -------------------------------- ### Complex Fill with Large Data and WriteTable Source: https://github.com/apache/fesod/blob/main/website/docs/sheet/fill/fill.md Optimizes performance for large datasets by placing the template list at the last row and using `WriteTable` for subsequent data. This example fills list data, variables, and statistical information. ```java @Test public void complexFillWithTable() { String templateFileName = "path/to/complexFillWithTable.xlsx"; try (ExcelWriter writer = FesodSheet.write("complexFillWithTable.xlsx").withTemplate(templateFileName).build()) { WriteSheet writeSheet = FesodSheet.writerSheet().build(); // Fill list data writer.fill(data(), writeSheet); // Fill list data Map map = new HashMap<>(); map.put("date", "2024年11月20日"); writer.fill(map, writeSheet); // Fill statistical information List> totalList = new ArrayList<>(); totalList.add(Arrays.asList(null, null, null, "统计: 1000")); writer.write(totalList, writeSheet); } } ``` -------------------------------- ### Upload Public Key to Server Source: https://github.com/apache/fesod/blob/main/website/community/release/release-version.md Uploads your public GPG key to the specified public key server. This makes your key available for others to retrieve and verify signatures. ```bash [root@localhost gpgtest]# gpg --keyserver keys.openpgp.org --send-key XXXXXXXX gpg: sending key XXXXXXXX to hkp server keys.openpgp.org ``` -------------------------------- ### Simple Fill with Object or Map Source: https://github.com/apache/fesod/blob/main/website/docs/sheet/fill/fill.md Demonstrates filling data into an Excel template using either a POJO or a Map. Specify the output file and the template file path. ```java @Test public void simpleFill() { String templateFileName = "path/to/simple.xlsx"; // Approach 1: Fill based on object FillData fillData = new FillData(); fillData.setName("张三"); fillData.setNumber(5.2); FesodSheet.write("simpleFill.xlsx") .withTemplate(templateFileName) .sheet() .doFill(fillData); // Approach 2: Fill based on Map Map map = new HashMap<>(); map.put("name", "张三"); map.put("number", 5.2); FesodSheet.write("simpleFillMap.xlsx") .withTemplate(templateFileName) .sheet() .doFill(map); } ``` -------------------------------- ### Register Custom Converter for Global Write Operation in Java Source: https://github.com/apache/fesod/blob/main/website/docs/sheet/advanced/custom-converter.md Register a custom converter globally using the Fesod builder to apply it to all fields of the supported type during write operations. This example demonstrates registering `CustomStringStringConverter` before writing data. ```java @Test public void customConverterWrite() { String fileName = "customConverterWrite" + System.currentTimeMillis() + ".xlsx"; FesodSheet.write(fileName, DemoData.class) .registerConverter(new CustomStringStringConverter()) .sheet() .doWrite(data()); } ``` -------------------------------- ### Verify SHA-512 Checksum (Linux) Source: https://github.com/apache/fesod/blob/main/website/docs/download.md Verify the SHA-512 checksum of the downloaded source release using the .sha512 checksum file on Linux. ```bash sha512sum -c apache-fesod-X.X.X-incubating-src.tar.gz.sha512 ``` -------------------------------- ### Register Custom Converter for Global Read Operation in Java Source: https://github.com/apache/fesod/blob/main/website/docs/sheet/advanced/custom-converter.md Register a custom converter globally using the Fesod builder to apply it to all fields of the supported type during read operations. This example shows how to register `CustomStringStringConverter` before reading data from an Excel file. ```java @Test public void customConverterRead() { String fileName = "path/to/demo.xlsx"; FesodSheet.read(fileName, DemoData.class, new DemoDataListener()) .registerConverter(new CustomStringStringConverter()) .sheet() .doRead(); } ``` -------------------------------- ### Implement Custom String Converter in Java Source: https://github.com/apache/fesod/blob/main/website/docs/sheet/advanced/custom-converter.md Implement the `Converter` interface to define custom logic for transforming String data between Java and Excel formats. This example shows how to support String type for both Java and Excel and provides custom conversion logic. ```java public class CustomStringStringConverter implements Converter { @Override public Class supportJavaTypeKey() { return String.class; } @Override public CellDataTypeEnum supportExcelTypeKey() { return CellDataTypeEnum.STRING; } @Override public String convertToJavaData(ReadConverterContext context) { return "Custom: " + context.getReadCellData().getStringValue(); } @Override public WriteCellData convertToExcelData(WriteConverterContext context) { return new WriteCellData<>("Custom: " + context.getValue()); } } ``` -------------------------------- ### Read Excel with Exception Handling Source: https://github.com/apache/fesod/blob/main/website/docs/sheet/read/exception.md Demonstrates how to initiate an Excel read operation using Fesod, specifying the file, data class, and a custom exception listener to handle potential errors. ```java import org.junit.Test; public class DemoTest { @Test public void exceptionRead() { String fileName = "path/to/demo.xlsx"; FesodSheet.read(fileName, ExceptionDemoData.class, new DemoExceptionListener()) .sheet() .doRead(); } } ``` -------------------------------- ### Batch Writing Large Excel Files with Compressed Temp Files Source: https://github.com/apache/fesod/blob/main/website/docs/sheet/advanced/large-file.md Write large Excel files in batches using Fesod's ExcelWriter. This example demonstrates enabling compressed temporary files for memory optimization, which is useful in disk-constrained environments. Tune the batch size based on your row width and available memory. ```java import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.xssf.streaming.SXSSFWorkbook; import org.junit.jupiter.api.Test; import com.esotericsoftware.kryo.util.Util; import com.esotericsoftware.minlog.Log; import com.fesod.sheet.ExcelWriter; import com.fesod.sheet.FesodSheet; import com.fesod.sheet.WriteSheet; import com.fesod.sheet.handler.WorkbookWriteHandler; import com.fesod.sheet.handler.WorkbookWriteHandlerContext; public class LargeFileTest { @Test public void largeFileWrite() { String fileName = "largeFile" + System.currentTimeMillis() + ".xlsx"; try (ExcelWriter excelWriter = FesodSheet.write(fileName, DemoData.class) .registerWriteHandler(new WorkbookWriteHandler() { @Override public void afterWorkbookCreate(WorkbookWriteHandlerContext context) { Workbook workbook = context.getWriteWorkbookHolder().getWorkbook(); if (workbook instanceof SXSSFWorkbook) { ((SXSSFWorkbook) workbook).setCompressTempFiles(true); } } }) .build()) { WriteSheet writeSheet = FesodSheet.writerSheet("Template").build(); // Write data in batches — each data() call returns one batch for (int i = 0; i < 1000; i++) { excelWriter.write(data(), writeSheet); } } } // Dummy methods for compilation private Object data() { return new Object(); } private static class DemoData { // Dummy class } } ``` -------------------------------- ### Verify SHA512 Checksum (Windows) Source: https://github.com/apache/fesod/blob/main/website/community/release/verify-release.md Verify the SHA512 checksum of the source package on Windows using the certUtil command. ```shell certUtil -hashfile apache-fesod-${RELEASE_VERSION}-src.tar.gz SHA512 ```