vgv-xls

Object-oriented java library for reading and writing Microsoft Office Excel spreadsheets

License

License

GroupId

GroupId

hr.com.vgv
ArtifactId

ArtifactId

vgv-xls
Last Version

Last Version

0.5
Release Date

Release Date

Type

Type

jar
Description

Description

vgv-xls
Object-oriented java library for reading and writing Microsoft Office Excel spreadsheets
Project URL

Project URL

http://github.com/Vatavuk/vgv-xls
Project Organization

Project Organization

jcabi.com
Source Code Management

Source Code Management

http://github.com/Vatavuk/vgv-xls/tree/master

Download vgv-xls

How to add to project

<!-- https://jarcasting.com/artifacts/hr.com.vgv/vgv-xls/ -->
<dependency>
    <groupId>hr.com.vgv</groupId>
    <artifactId>vgv-xls</artifactId>
    <version>0.5</version>
</dependency>
// https://jarcasting.com/artifacts/hr.com.vgv/vgv-xls/
implementation 'hr.com.vgv:vgv-xls:0.5'
// https://jarcasting.com/artifacts/hr.com.vgv/vgv-xls/
implementation ("hr.com.vgv:vgv-xls:0.5")
'hr.com.vgv:vgv-xls:jar:0.5'
<dependency org="hr.com.vgv" name="vgv-xls" rev="0.5">
  <artifact name="vgv-xls" type="jar" />
</dependency>
@Grapes(
@Grab(group='hr.com.vgv', module='vgv-xls', version='0.5')
)
libraryDependencies += "hr.com.vgv" % "vgv-xls" % "0.5"
[hr.com.vgv/vgv-xls "0.5"]

Dependencies

compile (3)

Group / Artifact Type Version
org.apache.poi : poi jar 3.17
org.apache.poi : poi-ooxml jar 3.17
com.jcabi : jcabi-immutable jar 1.4

provided (1)

Group / Artifact Type Version
org.hamcrest : hamcrest-core jar 1.3

Project Modules

There are no modules declared in this project.

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", "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.

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

Versions

Version
0.5
0.4
0.3
0.2