Git Product home page Git Product logo

excel-io's Introduction

Excel-io

Java excel library (Apache POI inside)

EO principles respected here DevOps By Rultor.com

Build Status Javadocs Maven Central License

Test Coverage SonarQube

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

<dependency>
    <groupId>hr.com.vgv</groupId>
    <artifactId>excel-io</artifactId>
</dependency>

Java version required: 1.8+.

Create spreadsheet

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", "[email protected]"))
            .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.

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:

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:

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

excel-io's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

excel-io's Issues

Add Font style

Add new class Font() to styles package that calls setFont() in CellStyle

Cactoos

Use cactoos iterableOf primitives instead of Array

Refactor tests

Statements like MatcherAssert.assertThat can be changed to assertThat by using import static to improve readability and reduce line width.

Add badges

Add badges for build status/codecov/devops/javadoc/maven/license

XsColumn

Create new XsColumn object similar to XsRow that will group cells into a column instead of a row.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.