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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ List<Product> products = Arrays.asList(
);

// 3. Export to Excel
ExcelExporter<Product> exporter = ExcelExporter.builder(Product.class, products)
DefaultExcelExporter<Product> exporter = DefaultExcelExporter.builder(Product.class, products)
.sheetStrategy(SheetStrategy.MULTI_SHEET) // Optional, MULTI_SHEET is default
.maxRows(100) // Optional, Max row of SpreadsheetVersion.EXCEL2007 is default
.sheetName("Products") // Optional, if not specified sheets will be named Sheet0, Sheet1, etc.
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ repositories {

java {
toolchain {
languageVersion = JavaLanguageVersion.of(23)
languageVersion = JavaLanguageVersion.of(21)
}
withSourcesJar() // 소스 코드도 포함
}
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
*
* // Usage example:
* List{@literal <}UserData{@literal >} users = getUserData();
* ExcelExporter{@literal <}UserData{@literal >} exporter = ExcelExporter.builder(UserData.class, users)
* DefaultExcelExporter{@literal <}UserData{@literal >} exporter = DefaultExcelExporter.builder(UserData.class, users)
* .sheetName("Users")
* .build();
* exporter.write(new FileOutputStream("users.xlsx"));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package io.github.hee9841.excel.annotation;

import io.github.hee9841.excel.format.CellFormats;
import io.github.hee9841.excel.meta.ColumnDataType;
import io.github.hee9841.excel.core.meta.ColumnDataType;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
package io.github.hee9841.excel.core;
package io.github.hee9841.excel.core.exporter;

import io.github.hee9841.excel.exception.ExcelException;
import io.github.hee9841.excel.strategy.SheetStrategy;
import java.text.MessageFormat;
import java.util.List;

/**
* ExcelExporter is a concrete implementation of {@link SXSSFExcelFile} that provides functionality
* DefaultExcelExporter is a concrete implementation of {@link SXSSFExporter} that provides functionality
* for exporting data to Excel files. This class uses the SXSSFWorkbook from Apache POI for
* efficient
* handling of large datasets by streaming data to disk.
*
* <p>The ExcelExporter supports two sheet management strategies:</p>
* <p>The DefaultExcelExporter supports two sheet management strategies:</p>
* <ul>
* <li>ONE_SHEET - All data is exported to a single sheet (limited by max rows per sheet)</li>
* <li>MULTI_SHEET - Data is split across multiple sheets when exceeding max rows per sheet</li>
* </ul>
*
* <p>Use the {@link ExcelExporterBuilder} to configure and instantiate this class.</p>
* <p>Use the {@link DefaultExcelExporterBuilder} to configure and instantiate this class.</p>
*
* @param <T> The type of data to be exported to Excel. The type must be annotated appropriately
* for Excel column mapping using the library's annotation system.
* @see SXSSFExcelFile
* @see ExcelExporterBuilder
* @see SXSSFExporter
* @see DefaultExcelExporterBuilder
* @see SheetStrategy
*/
public class ExcelExporter<T> extends SXSSFExcelFile<T> {
public class DefaultExcelExporter<T> extends SXSSFExporter<T> {

private static final String EXCEED_MAX_ROW_MSG_2ARGS =
"The data size exceeds the maximum number of rows allowed per sheet. "
Expand All @@ -44,18 +44,18 @@ public class ExcelExporter<T> extends SXSSFExcelFile<T> {


/**
* Constructs an ExcelExporter with the specified configuration.
* Constructs an DefaultExcelExporter with the specified configuration.
*
* <p>This constructor is not meant to be called directly. Use {@link ExcelExporterBuilder}
* to create instances of ExcelExporter.</p>
* <p>This constructor is not meant to be called directly. Use {@link DefaultExcelExporterBuilder}
* to create instances of DefaultExcelExporter.</p>
*
* @param type The class type of the data to be exported
* @param data The list of data objects to be exported
* @param sheetStrategy The strategy for sheet management (ONE_SHEET or MULTI_SHEET)
* @param sheetName Base name for sheets (null for default names)
* @param maxRowsPerSheet Maximum number of rows allowed per sheet
*/
ExcelExporter(
DefaultExcelExporter(
Class<T> type,
List<T> data,
SheetStrategy sheetStrategy,
Expand All @@ -74,15 +74,15 @@ public class ExcelExporter<T> extends SXSSFExcelFile<T> {


/**
* Creates a new builder for configuring and instantiating an ExcelExporter.
* Creates a new builder for configuring and instantiating an DefaultExcelExporter.
*
* @param <T> The type of data to be exported
* @param type The class of the data type
* @param data The list of data objects to be exported
* @return A new ExcelExporterBuilder instance
* @return A new DefaultExcelExporterBuilder instance
*/
public static <T> ExcelExporterBuilder<T> builder(Class<T> type, List<T> data) {
return new ExcelExporterBuilder<>(type, data, supplyExcelVersion.getMaxRows());
public static <T> DefaultExcelExporterBuilder<T> builder(Class<T> type, List<T> data) {
return new DefaultExcelExporterBuilder<>(type, data, supplyExcelVersion.getMaxRows());
}


Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package io.github.hee9841.excel.core;
package io.github.hee9841.excel.core.exporter;

import io.github.hee9841.excel.exception.ExcelException;
import io.github.hee9841.excel.strategy.SheetStrategy;
import java.util.List;

/**
* Builder class for creating and configuring {@link ExcelExporter} instances.
* Builder class for creating and configuring {@link DefaultExcelExporter} instances.
* This class implements the Builder pattern to provide a fluent interface for
* configuring Excel export settings.
*
Expand All @@ -18,7 +18,7 @@
*
* <p>Example usage:</p>
* <pre>
* ExcelExporter&lt;MyData&gt; exporter = ExcelExporter.builder(MyData.class, dataList)
* DefaultExcelExporter&lt;MyData&gt; exporter = DefaultExcelExporter.builder(MyData.class, dataList)
* .sheetStrategy(SheetStrategy.ONE_SHEET)
* .maxRows(10000)
* .sheetName("MySheet")
Expand All @@ -27,7 +27,7 @@
*
* @param <T> The type of data to be exported
*/
public class ExcelExporterBuilder<T> {
public class DefaultExcelExporterBuilder<T> {

private final Class<T> type;
private final List<T> data;
Expand All @@ -39,13 +39,13 @@ public class ExcelExporterBuilder<T> {
private String sheetName;

/**
* Constructs a new ExcelExporterBuilder with the specified type and data.
* Constructs a new DefaultExcelExporterBuilder with the specified type and data.
*
* @param type The class type of the data to be exported
* @param data The list of data objects to be exported
* @param supplyExcelMaxRows The maximum number of rows supported by the Excel version
*/
ExcelExporterBuilder(
DefaultExcelExporterBuilder(
Class<T> type,
List<T> data,
int supplyExcelMaxRows
Expand All @@ -64,7 +64,7 @@ public class ExcelExporterBuilder<T> {
* @param sheetStrategy The strategy to use for sheet management (ONE_SHEET or MULTI_SHEET)
* @return This builder instance for method chaining
*/
public ExcelExporterBuilder<T> sheetStrategy(SheetStrategy sheetStrategy) {
public DefaultExcelExporterBuilder<T> sheetStrategy(SheetStrategy sheetStrategy) {
this.sheetStrategy = sheetStrategy;
return this;
}
Expand All @@ -76,7 +76,7 @@ public ExcelExporterBuilder<T> sheetStrategy(SheetStrategy sheetStrategy) {
* @return This builder instance for method chaining
* @throws ExcelException if maxRowsPerSheet exceeds the Excel version's maximum row limit
*/
public ExcelExporterBuilder<T> maxRows(int maxRowsPerSheet) {
public DefaultExcelExporterBuilder<T> maxRows(int maxRowsPerSheet) {
if (maxRowsPerSheet > supplyExcelMaxRows) {
throw new ExcelException(String.format(
"The maximum rows per sheet(%d) cannot exceed the supplied Excel sheet version's maximum row limit(%d).",
Expand All @@ -99,18 +99,18 @@ public ExcelExporterBuilder<T> maxRows(int maxRowsPerSheet) {
* @param sheetName The base name for sheets
* @return This builder instance for method chaining
*/
public ExcelExporterBuilder<T> sheetName(String sheetName) {
public DefaultExcelExporterBuilder<T> sheetName(String sheetName) {
this.sheetName = sheetName;
return this;
}

/**
* Builds and returns a new ExcelExporter instance with the configured settings.
* Builds and returns a new DefaultExcelExporter instance with the configured settings.
*
* @return A new ExcelExporter instance
* @return A new DefaultExcelExporter instance
*/
public ExcelExporter<T> build() {
return new ExcelExporter<T>(
public DefaultExcelExporter<T> build() {
return new DefaultExcelExporter<T>(
this.type,
this.data,
this.sheetStrategy,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.github.hee9841.excel.core;
package io.github.hee9841.excel.core.exporter;

import java.io.IOException;
import java.io.OutputStream;
Expand All @@ -16,7 +16,7 @@
*
* @param <T> The type of data to be handled in the Excel file
*/
public interface ExcelFile<T> {
public interface ExcelExporter<T> {

/**
* Writes the Excel file content to the specified output stream.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package io.github.hee9841.excel.core;
package io.github.hee9841.excel.core.exporter;

import io.github.hee9841.excel.exception.ExcelException;
import io.github.hee9841.excel.meta.ColumnInfo;
import io.github.hee9841.excel.meta.ColumnInfoMapper;
import io.github.hee9841.excel.core.meta.ColumnInfo;
import io.github.hee9841.excel.core.meta.ColumnInfoMapper;
import java.io.IOException;
import java.io.OutputStream;
import java.lang.reflect.Field;
Expand Down Expand Up @@ -36,9 +36,9 @@
*
* @param <T> The type of data to be handled in the Excel file
*/
public abstract class SXSSFExcelFile<T> implements ExcelFile<T> {
public abstract class SXSSFExporter<T> implements ExcelExporter<T> {

protected static final Logger logger = LoggerFactory.getLogger(SXSSFExcelFile.class);
protected static final Logger logger = LoggerFactory.getLogger(SXSSFExporter.class);

protected static final SpreadsheetVersion supplyExcelVersion = SpreadsheetVersion.EXCEL2007;

Expand All @@ -49,9 +49,9 @@ public abstract class SXSSFExcelFile<T> implements ExcelFile<T> {
protected String dtoTypeName;

/**
* Constructs a new SXSSFExcelFile with a new SXSSFWorkbook instance.
* Constructs a new SXSSFExporter with a new SXSSFWorkbook instance.
*/
protected SXSSFExcelFile() {
protected SXSSFExporter() {
this.workbook = new SXSSFWorkbook();
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.github.hee9841.excel.meta;
package io.github.hee9841.excel.core.meta;

import io.github.hee9841.excel.annotation.ExcelColumnStyle;
import io.github.hee9841.excel.exception.ExcelException;
Expand Down Expand Up @@ -30,10 +30,12 @@ public enum ColumnDataType {
* Automatically determine the cell type based on the field type
*/
AUTO,

/**
* No specific cell type (default)
*/
_NONE,

/**
* Numeric cell type for various number formats
*/
Expand All @@ -50,6 +52,7 @@ public enum ColumnDataType {
CellFormats._NONE,
true
),

/**
* Boolean cell type
*/
Expand All @@ -61,6 +64,7 @@ public enum ColumnDataType {
CellFormats._NONE,
true
),

/**
* String cell type for text values
*/
Expand All @@ -72,6 +76,7 @@ public enum ColumnDataType {
CellFormats._NONE,
true
),

/**
* Enum cell type - uses toString() to get the value
*/
Expand All @@ -81,6 +86,7 @@ public enum ColumnDataType {
CellFormats._NONE,
true
),

/**
* Formula cell type - value is treated as an Excel formula
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.github.hee9841.excel.meta;
package io.github.hee9841.excel.core.meta;

import io.github.hee9841.excel.annotation.ExcelColumnStyle;
import org.apache.poi.ss.usermodel.CellStyle;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.github.hee9841.excel.meta;
package io.github.hee9841.excel.core.meta;

import static io.github.hee9841.excel.global.SystemValues.ALLOWED_FIELD_TYPES;
import static io.github.hee9841.excel.global.SystemValues.ALLOWED_FIELD_TYPES_STRING;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
package io.github.hee9841.excel.strategy;

import io.github.hee9841.excel.meta.ColumnDataType;

/**
* Strategy enum that determines how cell types are assigned in Excel sheets.
* <p>
* This enum defines strategies for determining the data type and format of cells
* when exporting data to Excel. It works in conjunction with the
* {@link ColumnDataType} enum to control how different Java types
* {@link io.github.hee9841.excel.core.meta.ColumnDataType} enum to control how different Java types
* are represented in Excel.
* </p>
* The available strategies are:
Expand All @@ -26,8 +25,8 @@
*
* @see io.github.hee9841.excel.annotation.Excel#cellTypeStrategy()
* @see io.github.hee9841.excel.annotation.ExcelColumn#columnCellType()
* @see ColumnDataType
* @see io.github.hee9841.excel.meta.ColumnInfoMapper
* @see io.github.hee9841.excel.core.meta.ColumnDataType
* @see io.github.hee9841.excel.core.meta.ColumnInfoMapper
* @see DataFormatStrategy
*/
public enum CellTypeStrategy {
Expand All @@ -36,7 +35,7 @@ public enum CellTypeStrategy {
* <p>
* With this strategy, you can explicitly specify the cell type for each column
* using the {@link io.github.hee9841.excel.annotation.ExcelColumn#columnCellType()} parameter
* or if not specified, cell type will be {@link ColumnDataType#_NONE}.
* or if not specified, cell type will be {@link io.github.hee9841.excel.core.meta.ColumnDataType#_NONE}.
* </p>
*/
NONE,
Expand All @@ -50,7 +49,7 @@ public enum CellTypeStrategy {
* </p>
* <p>
* The automatic cell type determination is performed by the
* {@link io.github.hee9841.excel.meta.ColumnInfoMapper} class.
* {@link io.github.hee9841.excel.core.meta.ColumnInfoMapper} class.
* If you want to specify the cell type for a specific column, you can use the
* {@link io.github.hee9841.excel.annotation.ExcelColumn#columnCellType()} parameter.
* </p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
*
* @see io.github.hee9841.excel.annotation.Excel#columnIndexStrategy()
* @see io.github.hee9841.excel.annotation.ExcelColumn#columnIndex()
* @see io.github.hee9841.excel.meta.ColumnInfoMapper
* @see io.github.hee9841.excel.core.meta.ColumnInfoMapper
*/
public enum ColumnIndexStrategy {
/**
Expand Down
Loading