An open API service indexing awesome lists of open source software.

https://github.com/chaoyangnz/ooxml-lite

Tired of bad performance of POI? time to try a new alternative! Templating + Data = Excel. Do right things with its native language: OOXML.
https://github.com/chaoyangnz/ooxml-lite

excel ooxml reporting spreadsheet spreadsheet-render spreadsheetml

Last synced: about 2 months ago
JSON representation

Tired of bad performance of POI? time to try a new alternative! Templating + Data = Excel. Do right things with its native language: OOXML.

Awesome Lists containing this project

README

        

# ooxml-lite

Generate Spreadsheet (Microsoft Excel or any OOXML compatible Spreadsheet) with templating.

Without the need to build from the scatch, the processing is in milliseconds 🚀.

Excel is related to OOXML, so we build with it.

## Get started

### Install

Gradle

```gradle
compile 'ooxml:ooxml-lite:0.0.1'
```

### Templating your worksheets

```xml





<#list data as row>
<#assign i = row?index>

<@c t="s" s="4" r="${i}" c="1">

${row.worker!}








${row.title!}
EID ${row.eid!}

@c>

<@c t="n" s="5" r="${i}" c="2">
${row.regularTime}
@c>

<@c t="n" s="5" r="${i}" c="3">
${row.overTime}
@c>

<@c t="n" s="5" r="${i}" c="4">
${row.doubleTime}
@c>

<@c t="str" s="5" r="${i}" c="5" f="SUM(B${i}:D${i})">
${row.total}
@c>

#list>

```

see more examples in [src/test/resources/](src/test/resources/).

### Start rendering

```java
Workbook workbook = new Workbook();
Worksheet worksheet1 = workbook.createSheet("sheet1.xml.ftl", "Summary");
worksheet1.setData(data1);

Worksheet worksheet2 = workbook.createSheet("sheet2.xml.ftl", "Detailed");
worksheet2.setData(data2);

File excel = workbook.render();
```

Open your Excel in temp directory.

## Extensions of SpreadML syntax

### render column

We defined `@c` directive which has the similar attributes of OOXML `..` cell tag.

```xml
<@c t="str" s="5" r="${i}" c="5" f="SUM(B1:D1)">
10
@c>
```
which is useful when you want to write the same way of inline string but automatically make them to shared strings

### write styles

Styles are defined within sheet templates by a custom directive `<@style> ... @style>`.
You can use the similar CSS style to define a named style then apply them to cells.

```xml
<@style>
header {
font-size: 14;
font-name: Robot;
border-left-color: red;
number-format-cod: '_ * #,##0_ ;_ * \-#,##0_ ;_ * "-"_ ;_ @_ ';
}
@style>
```

### merge cells

```xml
<@c colspan=2>@c>
```

```xml
<@c rowspan=4>@c>
```

### Hyperlink

// TODO

### Drawings and Images

// TODO