Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/braisdom/templatedexcel
Defining Excel styles with HTML and CSS. It's a templated language, as same as HTML
https://github.com/braisdom/templatedexcel
css excel export html java template xml
Last synced: 3 months ago
JSON representation
Defining Excel styles with HTML and CSS. It's a templated language, as same as HTML
- Host: GitHub
- URL: https://github.com/braisdom/templatedexcel
- Owner: braisdom
- License: apache-2.0
- Created: 2019-04-24T05:13:03.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2022-06-29T17:19:58.000Z (over 2 years ago)
- Last Synced: 2023-07-26T21:55:57.903Z (over 1 year ago)
- Topics: css, excel, export, html, java, template, xml
- Language: Java
- Homepage:
- Size: 244 KB
- Stars: 10
- Watchers: 3
- Forks: 5
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# TemplatedExcel
Defining Excel styles with HTML and CSS. It's a templated language, as same as HTML.
# News and noteworthy
- V1.1.0 release 2019-10-04
- Adjust the 'autoColumnSize' after the content generated.
- Create the style of cell lazyly.
- V1.0.1 release 2019-04-28
- Providing the basic capbility for excel generating, includes CSS defined cell style, dynamic template with Java objects which can be a getter method or Hash.
- Interface abstracted for various Excel adapter# Template language tags
|Tag Name |Attribute |Description |
| ------------ | ------------ | ------------ |
|workbook |--|The root element |
|sheet |name |The name of sheet, it will be displayed in Excel |
|row |height |The height of row |
| |style |The style of the row will apply to all cells included it |
|cell |fit-content |Adjusts the column width to fit the contents. |
| |quote-prefixed |Let numbers appear as non-numeric |
| |colspan |Allows a single excel cell to span the width of more than one cell or column. |
| |rowspan |Allows a single excel cell to span the height of more than one cell or row. |
| |style |The style of cell which describes Excel cell style ||# CSS properties supported
`Not supported by all CSS standards, all color is hex color definition only.`
- ***background-color***: Hex color definition supported only. eg: #FFFFFF.
- ***text-color***: Hex color definition supported only. eg: #FFFFFF.
- ***horizontal-alignment***: left, right, center supported only.
- ***vertical-aligment***: top, bottom, center supported only.
- ***border***: eg: 1px thin #000000, The border-style supported is thin, medium, dashed, dotted, thick, double and hair only.
- ***border-top-style***: as same as border.
- ***border-bottom-style***: as same as border.
- ***border-left-style***: as same as border.
- ***border-right-style***: as same as border.
- ***border-top-color***: as same as border.
- ***border-bottom-color***: as same as border.
- ***border-left-color***: as same as border.
- ***border-right-color***: as same as border.
- ***font-weight***: bold or others.
- ***font-family***: eg: Microsoft YaHei, the font name in excel.
- ***font-size***: eg: 12px, the font size in excel.
- ***font-style***: italic or others.
- ***text-decoration***: underline or others.
# Reference
[ph-css](https://github.com/phax/ph-css "ph-css") For parsing CSS text,[thymeleaf](https://github.com/thymeleaf/thymeleaf "thymeleaf") For dynamic template file.# Quick Start
## Maven dependency
```xmlcom.github.braisdom
templated-excel
1.1.0```
To build TemplatedExcel from source, Maven 3.0.4 is required. Any Maven version below does NOT work!## Example
Java Code:
```java
public class Sample {public static void main(String[] args) throws Exception {
InputStreamReader inputStreamReader = new InputStreamReader(Sample
.class.getResourceAsStream("/template.xml"));
File excelFile = new File("./sample.xls");
WorkbookTemplate workbookTemplate = new WorkbookTemplate(inputStreamReader);
workbookTemplate.process(new SampleTemplateDataSource(), new PoiWorkBookWriter(), excelFile);
}
}
```
Template Code:
```xml
00000000012344
Merged Column, Text Align Center, Vertical Align Center
Color Text
Background Color
Cell Border
Font Style
Row Height
Employee Table
Name
Gender
Occupation
```
![](https://raw.githubusercontent.com/braisdom/TemplatedExcel/master/images/style.png)
![](https://github.com/braisdom/TemplatedExcel/blob/master/images/data-table.png?raw=true)