final-poi

Simple excel generate tool.

License

License

GroupId

GroupId

org.ifinal.finalframework
ArtifactId

ArtifactId

final-poi
Last Version

Last Version

1.1.3
Release Date

Release Date

Type

Type

jar
Description

Description

final-poi
Simple excel generate tool.
Project URL

Project URL

https://github.com/final-projects/final-poi
Source Code Management

Source Code Management

http://github.com/final-projects/final-poi/tree/master

Download final-poi

How to add to project

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

Dependencies

compile (5)

Group / Artifact Type Version
org.apache.poi : poi jar 5.0.0
org.apache.poi : poi-ooxml jar 5.0.0
org.springframework : spring-core jar
org.springframework : spring-context jar
org.springframework.boot : spring-boot-starter-test jar

provided (1)

Group / Artifact Type Version
org.projectlombok : lombok Optional jar 1.18.16

test (1)

Group / Artifact Type Version
com.fasterxml.jackson.core : jackson-databind Optional jar

Project Modules

There are no modules declared in this project.

Final Poi

Final Poi

GitHub Workflow Status LICENSE Maven Central CODECOV RELEASE SNAPSHOT

Simple excel generate tool

Feature

  • 动态列
  • 表达式,支持Excel原生函数
  • 多级表头或表尾
  • 自定义样式,如背景颜色、字体等

Usage

Import Dependency

<dependency>
    <groupId>org.ifinal.finalframework</groupId>
    <artifactId>final-poi</artifactId>
    <version>${latest.version}</version>
</dependency>

Configure Excel

{
  "version": "XLSX",
  "styles": [
    {
      "title": "标题",
      "locked": true,
      "horizontalAlignment": "CENTER",
      "verticalAlignment": "CENTER",
      "foregroundColor": "RED",
      "font": {
        "name": "楷体",
        "size": 24,
        "color": "#00FF00"
      }
    }
  ],
  "sheets": [
    {
      "name": "SHEET NAME",
      "defaultRowHeight": 30,
      "defaultColumnWidth": -1,
      "headers": [
        {
          "cells": [
            {
              "style": "标题",
              "value": "姓名"
            },
            {
              "style": "标题",
              "value": "生日"
            },
            {
              "style": "标题",
              "value": "年龄"
            },
            {
              "style": "标题",
              "value": "生日/2"
            }
          ]
        }
      ],
      "body": {
        "cells": [
          {
            "columnWidth": 30,
            "value": "#{name}"
          },
          {
            "value": "#{age}"
          },
          {
            "columnWidth": 30,
            "value": "#{new java.text.SimpleDateFormat('yyyy-MM-dd hh:mm:ss').format(birthday)}"
          },
          {
            "value": "=B#{#cell.rowIndex + 1}/2"
          }
        ]
      },
      "footers": [
        {
          "cells": [
            {
              "value": "平均年龄:"
            },
            {
              "value": "=AVERAGE(B2:B#{#cell.rowIndex})"
            }
          ]
        }
      ]
    }
  ]
}

Write

package org.ifinal.finalframework.poi;

class ExcelsTest {

    private List<Person> persons() {
        return Arrays.asList(
            new Person("xiaoMing", 12, new Date()),
            new Person("xiaoHong", 18, new Date())
        );
    }

    @Test
    void testJson() throws IOException {

        final String json = "...";

        Excel excel = objectMapper.readValue(json, Excel.class);

        Excels.newWriter(excel).append(persons())
            .append(persons())
            .write("test3.xlsx");

    }

}

excel generate

Maven Repositories

因Maven发布存在延迟,若从Maven中心下载不到,可添加以下配置从OSS仓库下载:

<repositories>
    <repository>
        <id>oss</id>
        <name>oss-releases</name>
        <url>https://oss.sonatype.org/content/repositories/releases/</url>
        <releases>
            <enabled>true</enabled>
        </releases>
        <snapshots>
            <enabled>false</enabled>
        </snapshots>
    </repository>
    <repository>
        <id>oss-snapshots</id>
        <name>oss-snapshots</name>
        <url>https://oss.sonatype.org/content/repositories/snapshots/</url>
        <releases>
            <enabled>false</enabled>
        </releases>
        <snapshots>
            <enabled>true</enabled>
        </snapshots>
    </repository>
</repositories>
org.ifinal.finalframework

Final

简单、易用的开发脚手架

Versions

Version
1.1.3