diff --git a/README.md b/README.md
index e415258..169e315 100644
--- a/README.md
+++ b/README.md
@@ -6,7 +6,7 @@
[](LICENSE)
[](https://github.com/chitralabs/sheetz)
-**8 runnable examples** demonstrating every feature of the [Sheetz](https://github.com/chitralabs/sheetz) library — read, write, stream, and validate Excel and CSV files in Java with minimal code.
+**9 runnable examples** demonstrating every feature of the [Sheetz](https://github.com/chitralabs/sheetz) library — read, write, stream, and validate Excel and CSV files in Java with minimal code.
```java
// This is all it takes to read an Excel file into Java objects
@@ -191,7 +191,7 @@ Sheetz.register(BigDecimal.class, new MoneyConverter());
### 08 — Format Conversion
-Convert between XLSX, XLS, and CSV formats. Sheetz auto-detects the format from the file extension — converting is just read + write.
+Convert between XLSX, XLS, ODS, and CSV formats. Sheetz auto-detects the format from the file extension — converting is just read + write.
```java
// XLSX → CSV
@@ -207,6 +207,32 @@ Sheetz.write(data, "products.xls");
---
+### 09 — Cell Styling
+
+Apply cell formatting with `@Style` annotations and `CellStyleBuilder`. Supports bold, colors, alignment, data formats, hyperlinks, and auto-filter. New in Sheetz 1.1.0.
+
+```java
+// Annotation-based styling
+@Column("Price")
+@Style(backgroundColor = "#FFFF00", horizontalAlignment = "CENTER", dataFormat = "#,##0.00")
+public Double price;
+
+// Programmatic header style
+CellStyleDef headerStyle = CellStyleBuilder.create()
+ .bold(true).backgroundColor("#003366").fontColor("#FFFFFF").build();
+
+Sheetz.writer(StyledProduct.class)
+ .data(products)
+ .file("styled.xlsx")
+ .headerStyle(headerStyle)
+ .autoFilter(true)
+ .write();
+```
+
+[View source](src/main/java/io/github/chitralabs/sheetz/examples/E09_CellStyling.java)
+
+---
+
## Running Examples
```bash
@@ -217,7 +243,7 @@ mvn compile exec:java -Dexec.mainClass="io.github.chitralabs.sheetz.examples.E01
mvn compile exec:java -Dexec.mainClass="io.github.chitralabs.sheetz.examples.E03_StreamingLargeFiles"
# Run all examples in sequence
-for i in 01 02 03 04 05 06 07 08; do
+for i in 01 02 03 04 05 06 07 08 09; do
echo "--- Running E${i} ---"
mvn -q compile exec:java -Dexec.mainClass="io.github.chitralabs.sheetz.examples.E${i}_$(ls src/main/java/io/github/chitralabs/sheetz/examples/E${i}_*.java | xargs basename | sed 's/.java//')"
done
@@ -237,13 +263,13 @@ done
io.github.chitralabs.sheetz
sheetz-core
- 1.0.2
+ 1.1.0
```
**Gradle:**
```groovy
-implementation 'io.github.chitralabs.sheetz:sheetz-core:1.0.2'
+implementation 'io.github.chitralabs.sheetz:sheetz-core:1.1.0'
```
## 🤝 Add Your Own Example
@@ -251,16 +277,16 @@ implementation 'io.github.chitralabs.sheetz:sheetz-core:1.0.2'
Have a use case not covered here? **We want your example!**
Ideas we'd love PRs for:
-- [ ] E09 — Spring Boot REST endpoint that exports data to Excel
-- [ ] E10 — Database import pipeline (read Excel → save to JPA/Hibernate)
-- [ ] E11 — Concurrent multi-file processing with ExecutorService
-- [ ] E12 — Error recovery — partial import with validation report
-- [ ] E13 — Dynamic headers — read files where column order is unknown
-- [ ] E14 — Large file memory benchmark — heap usage comparison
+- [ ] E10 — Spring Boot REST endpoint that exports data to Excel
+- [ ] E11 — Database import pipeline (read Excel → save to JPA/Hibernate)
+- [ ] E12 — Concurrent multi-file processing with ExecutorService
+- [ ] E13 — Error recovery — partial import with validation report
+- [ ] E14 — Dynamic headers — read files where column order is unknown
+- [ ] E15 — Large file memory benchmark — heap usage comparison
**How to contribute an example:**
1. Copy an existing example file (e.g. `E01_BasicReadWrite.java`) as a template
-2. Name it `E09_YourExampleName.java`
+2. Name it `E10_YourExampleName.java`
3. Add it to `README.md` following the existing format
4. Open a PR — your name goes in the changelog!
diff --git a/pom.xml b/pom.xml
index 1367cf4..b2a0475 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
io.github.chitralabs.sheetz
sheetz-examples
- 1.0.0
+ 1.1.0
jar
Sheetz Examples
@@ -24,7 +24,7 @@
io.github.chitralabs.sheetz
sheetz-core
- 1.0.2
+ 1.1.0
diff --git a/src/main/java/io/github/chitralabs/sheetz/examples/E08_FormatConversion.java b/src/main/java/io/github/chitralabs/sheetz/examples/E08_FormatConversion.java
index d15bf02..ee40d16 100644
--- a/src/main/java/io/github/chitralabs/sheetz/examples/E08_FormatConversion.java
+++ b/src/main/java/io/github/chitralabs/sheetz/examples/E08_FormatConversion.java
@@ -13,6 +13,7 @@
* Demonstrates converting between Excel and CSV formats:
* - XLSX → CSV
* - CSV → XLSX
+ * - XLSX → ODS (OpenDocument)
* - XLSX → XLS (legacy format)
* - Read and write with format auto-detection from file extension
*/
@@ -49,6 +50,12 @@ public static void main(String[] args) {
Sheetz.write(fromCsv, newXlsxPath);
System.out.println("Converted " + csvPath + " → " + newXlsxPath);
+ // --- XLSX → ODS ---
+ System.out.println("\n--- XLSX → ODS (OpenDocument) ---");
+ String odsPath = "output/converted.ods";
+ Sheetz.write(fromXlsx, odsPath);
+ System.out.println("Converted " + xlsxPath + " → " + odsPath);
+
// --- XLSX → XLS ---
System.out.println("\n--- XLSX → XLS (legacy format) ---");
String xlsPath = "output/legacy.xls";
@@ -59,15 +66,18 @@ public static void main(String[] args) {
System.out.println("\n--- Verification: all formats contain same data ---");
List verifyXlsx = Sheetz.read(newXlsxPath, Product.class);
List verifyCsv = Sheetz.read(csvPath, Product.class);
+ List verifyOds = Sheetz.read(odsPath, Product.class);
List verifyXls = Sheetz.read(xlsPath, Product.class);
System.out.println("XLSX rows: " + verifyXlsx.size());
System.out.println("CSV rows: " + verifyCsv.size());
+ System.out.println("ODS rows: " + verifyOds.size());
System.out.println("XLS rows: " + verifyXls.size());
System.out.println("\nFirst product from each format:");
System.out.println(" XLSX: " + verifyXlsx.get(0));
System.out.println(" CSV: " + verifyCsv.get(0));
+ System.out.println(" ODS: " + verifyOds.get(0));
System.out.println(" XLS: " + verifyXls.get(0));
System.out.println("\nDone!");
diff --git a/src/main/java/io/github/chitralabs/sheetz/examples/E09_CellStyling.java b/src/main/java/io/github/chitralabs/sheetz/examples/E09_CellStyling.java
new file mode 100644
index 0000000..55c400f
--- /dev/null
+++ b/src/main/java/io/github/chitralabs/sheetz/examples/E09_CellStyling.java
@@ -0,0 +1,80 @@
+package io.github.chitralabs.sheetz.examples;
+
+import io.github.chitralabs.sheetz.Sheetz;
+import io.github.chitralabs.sheetz.annotation.Column;
+import io.github.chitralabs.sheetz.annotation.Style;
+import io.github.chitralabs.sheetz.style.CellStyleBuilder;
+import io.github.chitralabs.sheetz.style.CellStyleDef;
+import io.github.chitralabs.sheetz.style.HyperlinkValue;
+
+import java.util.List;
+
+/**
+ * E09: Cell Styling — @Style annotation, programmatic styles, and hyperlinks.
+ *
+ * Demonstrates the cell formatting API added in Sheetz 1.1.0.
+ */
+public class E09_CellStyling {
+
+ // --- Model with @Style annotation ---
+ public static class StyledProduct {
+ @Column("Product Name")
+ @Style(bold = true, fontColor = "#0000FF")
+ public String name;
+
+ @Column("Price")
+ @Style(backgroundColor = "#FFFF00", horizontalAlignment = "CENTER", dataFormat = "#,##0.00")
+ public Double price;
+
+ @Column("Website")
+ @Style(hyperlink = true)
+ public HyperlinkValue website;
+
+ public StyledProduct() {}
+
+ public StyledProduct(String name, Double price, String url) {
+ this.name = name;
+ this.price = price;
+ this.website = new HyperlinkValue(name + " site", url);
+ }
+ }
+
+ public static void main(String[] args) {
+ System.out.println("=== E09: Cell Styling ===\n");
+
+ // 1. Write with @Style annotations
+ List products = List.of(
+ new StyledProduct("Widget", 29.99, "https://example.com/widget"),
+ new StyledProduct("Gadget", 49.99, "https://example.com/gadget"),
+ new StyledProduct("Gizmo", 19.99, "https://example.com/gizmo")
+ );
+
+ Sheetz.write(products, "styled-products.xlsx");
+ System.out.println("Wrote styled-products.xlsx with @Style annotations");
+
+ // 2. Programmatic header style with CellStyleBuilder
+ CellStyleDef headerStyle = CellStyleBuilder.create()
+ .bold(true)
+ .backgroundColor("#003366")
+ .fontColor("#FFFFFF")
+ .horizontalAlignment("CENTER")
+ .build();
+
+ Sheetz.writer(StyledProduct.class)
+ .data(products)
+ .file("styled-with-header.xlsx")
+ .headerStyle(headerStyle)
+ .autoFilter(true)
+ .write();
+
+ System.out.println("Wrote styled-with-header.xlsx with programmatic header style and auto-filter");
+
+ // 3. Read back
+ List readBack = Sheetz.read("styled-products.xlsx", StyledProduct.class);
+ for (StyledProduct p : readBack) {
+ System.out.printf(" %s — $%.2f%n", p.name, p.price);
+ }
+
+ System.out.println("\nDone!");
+ }
+}