All Projects → zhangyu836 → xltpl

zhangyu836 / xltpl

Licence: MIT license
A python module to generate xls/x files from a xls/x template.

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to xltpl

Test files
📚 SheetJS Test Files (XLS/XLSX/XLSB and other spreadsheet formats)
Stars: ✭ 150 (+226.09%)
Mutual labels:  excel, xlsx, xls, spreadsheet
Desktopeditors
An office suite that combines text, spreadsheet and presentation editors allowing to create, view and edit local documents
Stars: ✭ 1,008 (+2091.3%)
Mutual labels:  excel, xlsx, xls, spreadsheet
Documentbuilder
ONLYOFFICE Document Builder is powerful text, spreadsheet, presentation and PDF generating tool
Stars: ✭ 61 (+32.61%)
Mutual labels:  excel, xlsx, xls, spreadsheet
Readxl
Read excel files (.xls and .xlsx) into R 🖇
Stars: ✭ 585 (+1171.74%)
Mutual labels:  excel, xlsx, xls, spreadsheet
Documentserver
ONLYOFFICE Document Server is an online office suite comprising viewers and editors for texts, spreadsheets and presentations, fully compatible with Office Open XML formats: .docx, .xlsx, .pptx and enabling collaborative editing in real time.
Stars: ✭ 2,335 (+4976.09%)
Mutual labels:  excel, xlsx, xls, spreadsheet
spreadsheet
Yii2 extension for export to Excel
Stars: ✭ 79 (+71.74%)
Mutual labels:  excel, xlsx, xls, spreadsheet
Phpspreadsheet
A pure PHP library for reading and writing spreadsheet files
Stars: ✭ 10,627 (+23002.17%)
Mutual labels:  excel, xlsx, xls, spreadsheet
J
❌ Multi-format spreadsheet CLI (now merged in http://github.com/sheetjs/js-xlsx )
Stars: ✭ 343 (+645.65%)
Mutual labels:  excel, xlsx, xls, spreadsheet
Docjure
Read and write Office documents from Clojure
Stars: ✭ 510 (+1008.7%)
Mutual labels:  excel, xlsx, xls, spreadsheet
Sheetjs
📗 SheetJS Community Edition -- Spreadsheet Data Toolkit
Stars: ✭ 28,479 (+61810.87%)
Mutual labels:  excel, xlsx, xls, spreadsheet
Excelize
Golang library for reading and writing Microsoft Excel™ (XLSX) files.
Stars: ✭ 10,286 (+22260.87%)
Mutual labels:  excel, xlsx, spreadsheet
Myexcel
MyExcel, a new way to operate excel!
Stars: ✭ 1,198 (+2504.35%)
Mutual labels:  excel, xlsx, xls
xlsx-reader
xlsx-reader is a PHP library for fast and efficient reading of XLSX spreadsheet files. Its focus is on reading the data contained within XLSX files, disregarding all document styling beyond that which is strictly necessary for data type recognition. It is built to be usable for very big XLSX files in the magnitude of multiple GBs.
Stars: ✭ 40 (-13.04%)
Mutual labels:  excel, xlsx, spreadsheet
Spreadsheet
The Ruby Spreadsheet by ywesee GmbH
Stars: ✭ 1,033 (+2145.65%)
Mutual labels:  excel, xls, spreadsheet
spreadcheetah
SpreadCheetah is a high-performance .NET library for generating spreadsheet (Microsoft Excel XLSX) files.
Stars: ✭ 107 (+132.61%)
Mutual labels:  excel, xlsx, spreadsheet
Luckysheet
Luckysheet is an online spreadsheet like excel that is powerful, simple to configure, and completely open source.
Stars: ✭ 9,772 (+21143.48%)
Mutual labels:  excel, xlsx, spreadsheet
Xlsx
Fast and reliable way to work with Microsoft Excel™ [xlsx] files in Golang
Stars: ✭ 132 (+186.96%)
Mutual labels:  excel, xlsx, spreadsheet
Xresloader
跨平台Excel导表工具(Excel=>protobuf/msgpack/lua/javascript/json/xml)
Stars: ✭ 161 (+250%)
Mutual labels:  excel, xlsx, xls
laravel-xlswriter
an excel export/import tool for laravel based on php-xlswriter
Stars: ✭ 54 (+17.39%)
Mutual labels:  excel, xlsx, xls
Sylvan.Data.Excel
The fastest .NET library for reading Excel data files.
Stars: ✭ 65 (+41.3%)
Mutual labels:  excel, xlsx, xls

xltpl

使用 xls/x 文件作为模板来生成 xls/x 文件。 English

实现方法

xls/x 文件的每个工作表会被转换为一棵树。
树会被转换为带有自定义 tag 的 jinja2 模板。
渲染模板时,自定义 tag 所对应的 jinja2 扩展调用相应的树节点来写入 xls/x 文件。

安装

pip install xltpl

使用

  • 要使用 xltpl,需要了解 jinja2 模板的语法
  • 选择一个 xls/x 文件作为模板。
  • 在单元格中插入变量:
{{name}}
  • 在单元格的批注中插入控制语句(使用 beforerow、beforecell 和 aftercell 指定其位置):
beforerow{% for item in items %}
beforerow{% endfor %}
  • 或在单元格中插入控制语句(v0.9):
{%- for row in rows %}
{% set outer_loop = loop %}{% for row in rows %}
Cell
{{outer_loop.index}}{{loop.index}}
{%+ endfor%}{%+ endfor%}
  • 运行代码
from xltpl.writerx import BookWriter
writer = BookWriter('tpl.xlsx')
person_info = {'name': u'Hello Wizard'}
items = ['1', '1', '1', '1', '1', '1', '1', '1', ]
person_info['items'] = items
payloads = [person_info]
writer.render_book(payloads)
writer.save('result.xlsx')

支持的特性

  • 合并单元格 (MergedCell)
  • 单元格非字符串值 (使用 {% xv variable %} 来表示变量)
  • 对于 xlsx
    图片 (使用 {% img variable %})
    数据有效性(DataValidation)
    筛选 (AutoFilter)

相关

说明

xlrd

xlrd 不会读入打印设置。
如果需要一致的打印设置,可以使用这里的 xlrd

xlwt

xlwt 总是将默认字体设置为 'Arial'。
Excel 基于默认字体来设置单元格宽度。
如果需要一致的单元格宽度,可以使用这里的 xlwt

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].