Spring Boot auto-configuration for Sheetz — inject a SheetzTemplate bean and read/write Excel and CSV files with zero boilerplate.
@Autowired
private SheetzTemplate sheetz;
// Read Excel → Java objects
List<Product> products = sheetz.read("products.xlsx", Product.class);
// Write Java objects → CSV
sheetz.write(products, "output.csv");No manual configuration required. Add the dependency, and it works.
Maven:
<dependency>
<groupId>io.github.chitralabs.sheetz</groupId>
<artifactId>sheetz-spring-boot-starter</artifactId>
<version>1.0.2</version>
</dependency>
<dependency>
<groupId>io.github.chitralabs.sheetz</groupId>
<artifactId>sheetz-core</artifactId>
<version>1.0.2</version>
</dependency>Gradle:
implementation 'io.github.chitralabs.sheetz:sheetz-spring-boot-starter:1.0.2'
implementation 'io.github.chitralabs.sheetz:sheetz-core:1.0.2'@Service
public class ReportService {
private final SheetzTemplate sheetz;
public ReportService(SheetzTemplate sheetz) {
this.sheetz = sheetz;
}
public List<Order> importOrders(String path) {
return sheetz.read(path, Order.class);
}
public void exportOrders(List<Order> orders, String path) {
sheetz.write(orders, path);
}
}That's it. The starter auto-configures SheetzTemplate with sensible defaults.
Customize behavior in application.properties or application.yml:
# Date/time formats
sheetz.date-format=dd/MM/yyyy
sheetz.date-time-format=dd/MM/yyyy HH:mm:ss
sheetz.time-format=HH:mm
# Reading behavior
sheetz.trim-values=true
sheetz.skip-empty-rows=true
sheetz.evaluate-formulas=true
sheetz.header-row=0
# Writing behavior
sheetz.default-sheet-name=Sheet1
sheetz.streaming-threshold=10000
# Processing
sheetz.batch-size=1000
sheetz.charset=UTF-8
# Disable auto-configuration
sheetz.enabled=false| Property | Type | Default | Description |
|---|---|---|---|
sheetz.enabled |
boolean |
true |
Enable/disable auto-configuration |
sheetz.date-format |
String |
yyyy-MM-dd |
Date format for LocalDate |
sheetz.date-time-format |
String |
yyyy-MM-dd HH:mm:ss |
Format for LocalDateTime |
sheetz.time-format |
String |
HH:mm:ss |
Format for LocalTime |
sheetz.trim-values |
boolean |
true |
Trim whitespace from strings |
sheetz.skip-empty-rows |
boolean |
true |
Skip empty rows when reading |
sheetz.default-sheet-name |
String |
Sheet1 |
Default sheet name for writing |
sheetz.header-row |
int |
0 |
Header row index (0-based) |
sheetz.batch-size |
int |
1000 |
Batch size for batch processing |
sheetz.evaluate-formulas |
boolean |
true |
Evaluate formulas when reading |
sheetz.streaming-threshold |
int |
10000 |
Auto-stream writes above this row count |
sheetz.charset |
Charset |
UTF-8 |
CSV character encoding |
SheetzTemplate wraps the entire Sheetz API as instance methods:
// Typed objects
List<Product> products = sheetz.read("products.xlsx", Product.class);
List<Product> products = sheetz.read(path, Product.class);
List<Product> products = sheetz.read(inputStream, Product.class, Format.XLSX);
// Schema-free maps
List<Map<String, Object>> maps = sheetz.readMaps("data.csv");
// Raw strings
List<String[]> raw = sheetz.readRaw("data.xlsx");
// Preview first N rows
List<Product> preview = sheetz.readFirst("huge.xlsx", Product.class, 100);sheetz.write(products, "output.xlsx");
sheetz.write(products, path);
sheetz.write(products, outputStream, Format.CSV);try (StreamingReader<Product> reader = sheetz.stream("huge.csv", Product.class)) {
for (Product p : reader) {
process(p);
}
}ValidationResult<Product> result = sheetz.validate("import.xlsx", Product.class);
System.out.printf("Valid: %d | Errors: %d%n", result.validCount(), result.errorCount());// Fine-grained read control
List<Product> products = sheetz.reader(Product.class)
.file("report.xlsx")
.sheet("Q4 Data")
.read();
// Fine-grained write control
sheetz.writer(Product.class)
.data(products)
.file("output.xlsx")
.sheet("Products")
.autoSize(true)
.freezeHeader(true)
.write();
// Multi-sheet workbook
sheetz.workbook()
.sheet("Products", products)
.sheet("Orders", orders)
.write("report.xlsx");Define a Converter<T> bean, and the starter auto-registers it:
@Component
public class MoneyConverter implements Converter<BigDecimal> {
@Override
public BigDecimal fromCell(Object value, ConvertContext ctx) {
return new BigDecimal(value.toString().replace("$", "").replace(",", "").trim());
}
@Override
public Object toCell(BigDecimal value) {
return "$" + value.setScale(2, RoundingMode.HALF_UP);
}
}All BigDecimal fields in your models will automatically use this converter — no manual registration needed.
Override the auto-configured SheetzTemplate if you need custom initialization:
@Configuration
public class SheetzConfig {
@Bean
public SheetzTemplate sheetzTemplate(SheetzProperties properties) {
SheetzTemplate template = new SheetzTemplate(properties);
template.register(Money.class, new MoneyConverter());
return template;
}
}- Java 11+
- Spring Boot 2.7+ (also compatible with Spring Boot 3.x)
- sheetz-core 1.0.2
- Sheetz — main library
- Sheetz Examples — 8 runnable demos
- Sheetz Benchmarks — performance comparisons
- Sheetz on Maven Central
Apache License 2.0 — free for commercial and personal use.
If Sheetz saved you time, consider giving the main repo a star.