https://github.com/retheviper/excelweaver
A simple library for manipulate excel file in java.
https://github.com/retheviper/excelweaver
apache-poi excel gradle java
Last synced: 9 months ago
JSON representation
A simple library for manipulate excel file in java.
- Host: GitHub
- URL: https://github.com/retheviper/excelweaver
- Owner: retheviper
- License: mit
- Created: 2020-08-29T14:01:17.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2021-12-22T04:35:49.000Z (about 4 years ago)
- Last Synced: 2025-04-13T06:11:32.810Z (9 months ago)
- Topics: apache-poi, excel, gradle, java
- Language: Java
- Homepage:
- Size: 687 KB
- Stars: 0
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ExcelWeaver

A simple library for manipulate excel file in java.
And there is Kotlin version of this library. [Check this out](https://github.com/retheviper/ExcelWeaverKotlin).
## TL;DR
`*.xlsx` → `java.util.List`
`java.util.List` → `*.xlsx`
## To build
`./gradlew shadowJar`
(And Jar will be found in `build/libs`)
## To Use
### Make definition of sheet
```java
@Sheet(dataStartIndex = 2)
public class Contract { // Class name will be sheets name
@Column(position = "B")
private String name;
@Column(position = "C")
private String cellPhone;
@Column(position = "D")
private int postCode;
}
```
### Make definition of book
```java
// Create from array or list of SheetDef classes
BookDef bookDef = BookDef.of(Contract.class, Message.class);
// add more sheet
bookDef.addSheet(Salary.class);
```
### Read file
```java
List list;
try (BookWorker worker = bookDef.openBook(OUTPUT_FILE_PATH)) {
list = worker.read(Contract.class);
} catch (IOException e) {
// ...
}
```
### Write file
```java
List data = ...
try (BookWorker worker = bookDef.openBook(TEMPLATE_FILE_PATH, OUTPUT_FILE_PATH)) {
worker.write(data);
} catch (IOException e) {
// ...
}
```
