simter-jxls-ext

Simter Jxls Extension

License

License

MIT
GroupId

GroupId

tech.simter
ArtifactId

ArtifactId

simter-jxls-ext
Last Version

Last Version

1.1.0
Release Date

Release Date

Type

Type

jar
Description

Description

simter-jxls-ext
Simter Jxls Extension
Project URL

Project URL

https://github.com/simter/simter-jxls-ext
Project Organization

Project Organization

simter
Source Code Management

Source Code Management

https://github.com/simter/simter-jxls-ext.git

Download simter-jxls-ext

How to add to project

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

Dependencies

compile (4)

Group / Artifact Type Version
org.jxls : jxls jar 2.6.0
org.jxls : jxls-poi jar 1.2.0
javax.ws.rs : javax.ws.rs-api Optional jar 2.1.1
org.slf4j : slf4j-api jar

test (5)

Group / Artifact Type Version
org.junit.jupiter : junit-jupiter jar
org.assertj : assertj-core jar 3.12.2
org.slf4j : jcl-over-slf4j jar
ch.qos.logback : logback-classic jar
org.springframework.boot : spring-boot jar

Project Modules

There are no modules declared in this project.

simter-jxls-ext [中文]

Simter Jxls Extensions. Includes:

  • Common Functions

    • Format number: fn.format(1123456789.456, '#,###.00') > 1,123,456,789.56
    • Round number: fn.round(45.678, 2) > 45.68
    • Convert string to int: fn.toInt('123') > 123
    • Concat multipul strings: fn.concat('ab', 'c', ...) > 'abc'
    • Format java8 date/time: fn.format(LocalDateTime.now(), 'yyyy-MM-dd HH:mm:ss') > 2017-01-01 12:30:50
  • EachMergeCommand: jx:each-merge, for auto merge cells

See the usage code bellow.

Installation

<dependency>
  <groupId>tech.simter</groupId>
  <artifactId>simter-jxls-ext</artifactId>
  <version>1.0.0</version>
</dependency>

Requirement

Usage

Common Functions

Context context = new Context();

// inject common-functions
context.putVar("fn", CommonFunctions.getSingleton());

// other data
context.putVar("num", new BigDecimal("123.456"));
context.putVar("datetime", LocalDateTime.now());
context.putVar("date", LocalDate.now());
context.putVar("time", LocalTime.now());
context.putVar("str", "123");

// render template
InputStream template = ...;
OutputStream output = ...;
JxlsHelper.getInstance().processTemplate(template, output, context);

Check the unit test code from CommonFunctionsTest.java. The template and render result show bellow:

common-functions.png

EachMergeCommand - Auto merge cells

// global add custom each-merge command to XlsCommentAreaBuilder
XlsCommentAreaBuilder.addCommandMapping(EachMergeCommand.COMMAND_NAME, EachMergeCommand.class);

// generate a main-sub structure data
Context context = new Context();
context.putVar("rows", generateRowsData());

// render template
InputStream template = ...;
OutputStream output = ...;
JxlsHelper.getInstance().processTemplate(template, output, context);

The generateRowsData() method generates the bellow structure data:

[
  {
    sn: 1, 
    name: 'row1',
    subs: [
      {sn: '1-1', name: 'row1sub1'},
      ...
    ]
  },
  ...
]

Check the unit test code from EachMergeCommandTest.java. The template and render result show bellow:

each-merge.png

Build

mvn clean package

Deploy

First take a look at simter-parent deploy config.

Deploy to LAN Nexus Repository

mvn clean deploy -P lan

Deploy to Sonatype Repository

mvn clean deploy -P sonatype

After deployed, login into https://oss.sonatype.org. Through Staging Repositories, search this package, then close and release it. After couple hours, it will be synced to Maven Central Repository.

Deploy to Bintray Repository

mvn clean deploy -P bintray

Will deploy to https://api.bintray.com/maven/simter/maven/tech.simter:simter-jxls-ext/;publish=1. So first create a package https://bintray.com/simter/maven/tech.simter:simter-jxls-ext on Bintray. After deployed, check it from https://jcenter.bintray.com/tech/simter/simter-jxls-ext.

tech.simter

Versions

Version
1.1.0
1.0.0
0.4.0
0.3.0