Skip to content

javaxcel/javaxcel

Repository files navigation

Javaxcel Core

Javaxcel

Supporter for export and import of excel file

GitHub Workflow Status (branch) Codecov branch Maven Central
Sonarcloud Quality Gate Status Sonarcloud Maintainability Rating Codacy grade jdk8

Table of Contents



What is Javaxcel?

Javaxcel is a supporter for exporting java.util.List to spreadsheets and importing java.util.List from spreadsheets using Apache POI.



Modules



Getting started

Maven

<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>

Gradle

implementation 'com.github.javaxcel:javaxcel-core:x.y.z'

// Required dependency
implementation 'org.apache.poi:poi-ooxml:a.b.c'

Usage

// 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.