https://github.com/vatavuk/excel-io
Object-oriented java Excel library
https://github.com/vatavuk/excel-io
apache-poi excel excelwriter java oop oop-principles xlsx
Last synced: 26 days ago
JSON representation
Object-oriented java Excel library
- Host: GitHub
- URL: https://github.com/vatavuk/excel-io
- Owner: Vatavuk
- License: mit
- Created: 2018-01-23T19:34:16.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2018-03-27T16:23:30.000Z (about 8 years ago)
- Last Synced: 2026-02-24T14:23:53.723Z (2 months ago)
- Topics: apache-poi, excel, excelwriter, java, oop, oop-principles, xlsx
- Language: Java
- Homepage:
- Size: 220 KB
- Stars: 82
- Watchers: 3
- Forks: 8
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# Excel-io
### Java excel library (Apache POI inside)

[](http://www.elegantobjects.org)
[](http://www.rultor.com/p/Vatavuk/excel-io)
[](https://travis-ci.org/Vatavuk/excel-io)
[](http://javadoc.io/doc/hr.com.vgv/excel-io)
[](https://maven-badges.herokuapp.com/maven-central/hr.com.vgv/excel-io)
[](https://github.com/Vatavuk/excel-io/blob/master/LICENSE.txt)
[](https://codecov.io/gh/Vatavuk/excel-io)
[](https://sonarcloud.io/dashboard/index/hr.com.vgv:excel-io)
This is an object-oriented java library for reading and writing Microsoft Office Excel spreadsheets.
It is a wrapper around Apache POI that provides elegant and user friendly interface for creating Excel documents.
**How to use**.
Latest version [here](https://github.com/Vatavuk/excel-io/releases)
```xml
hr.com.vgv
excel-io
```
Java version required: 1.8+.
## Create spreadsheet
```java
new XsWorkbook(
new XsSheet(
new XsRow()
.with(new TextCells("name", "email", "salary", "bonus", "total"))
.with(
new XsStyle(
new ForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex()),
new FillPattern(FillPatternType.SOLID_FOREGROUND)
)
),
new XsRow()
.with(new TextCells("Steve Hook", "steve.hook@gmail.com"))
.with(new NumberCells(160000.0, 35337.6))
.with(new FormulaCell("SUM(C3:D3)")
.with(
new XsStyle(
new ForegroundColor(IndexedColors.RED.getIndex()),
new FillPattern(FillPatternType.SOLID_FOREGROUND)
)
)
)
.with(new XsProps<>(new Height((short) 500)))
)
).saveTo("Test.xlsx");
```
This is how the result looks like:

## Read and modify spreadsheet
Read from "Test.xlsx" file and modify cell int the second row/first column.
```java
new XsWorkbook("Test.xlsx")
.with(new XsSheet.ReadFrom(0)
.with(
new XsRow(2,
new TextCell(1, "UPDATED")
)
)
).saveTo("Updated.xlsx");
```
## Custom styles
You can create custom cells/rows/sheets:
```java
new XsWorkbook(
new XsSheet(
new MyCustomRow("Boris", "Miksic", "ID:2450"),
new MyCustomRow("Mirko", "Mirkic", "ID:1690")
)
).saveTo("Test.xlsx");
```
Just extend appropriate template class and pass custom row/cell object to its constructor:
```java
private static class MyCustomRow extends RowTemplate {
public MyCustomRow(final String name, final String surname, final String id) {
super(
new XsRow()
.with(new TextCells(name, surname))
.with(new MyGreyCell(new TextCell(id)))
);
}
}
private static class MyGreyCell extends CellTemplate {
public MyGreyCell(final ECell cell) {
super(cell.with(
new XsStyle(
new ForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex()),
new FillPattern(FillPatternType.SOLID_FOREGROUND)
)
));
}
}
```
The result:

## Contribution
You can contribute by forking the repo and sending a pull request.
Make sure your branch builds without any warnings/issues:
```
mvn clean install -Pqulice
```