Supporter for export and import of excel file
Javaxcel is a supporter for exporting java.util.List
to spreadsheets and importing java.util.List
from spreadsheets
using Apache POI.
- javaxcel-core: Supporter for export and import of Excel file.
- javaxcel-styler: Configurer for decoration of
CellStyle
with simple usage.
<dependency>
<groupId>com.github.javaxcel</groupId>
<artifactId>javaxcel-core</artifactId>
<version>x.y.z</version>
</dependency>
<!-- Required dependency -->
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>a.b.c</version>
</dependency>
implementation 'com.github.javaxcel:javaxcel-core:x.y.z'
// Required dependency
implementation 'org.apache.poi:poi-ooxml:a.b.c'
// Creates an instance of Javaxcel.
Javaxcel javaxcel = Javaxcel.newInstance();
File src = new File("/data", "old-products.xls");
File dest = new File("/data", "new-products.xlsx");
try (InputStream in = Files.newInputStream(src.toPath());
OutputStream out = Files.newOutputStream(dest.toPath());
Workbook oldWorkbook = new HSSFWorkbook(in);
Workbook newWorkbook = new SXSSFWorkbook()) {
// Reads all the sheets and returns data as a list.
List<Product> products = javaxcel.reader(oldWorkbook, Product.class).read();
// Creates an Excel file and writes data to it.
javaxcel.writer(newWorkbook, Product.class).write(out, products);
} catch (IOException e) {
e.printStackTrace();
}
Use Apache POI with simple code.