Skip to main content

excel模板配置化导出模块

Project description

SKY-EXCEL Module

excel工具模块

Part 1. Introduce

介绍

如果你不希望每一次需要把接口返回的字典数据导出成excel表格而去设计表头、合并单元格,而进行一次一次重复大量的编程活动。那么你可以尝试一下这个模块。sky-excel把表头设计与单元格设计耦合到一起,你只需要创建一个excel模板即可,然后进行配置对应输入的字段就可以实现,把接口的数据导出单元格。

这个模块仅仅做了一件事情,就是把你写好的表头版本抄写一般,把字典数据按照键值对匹配填充进去即可。

Part 2. API Document

API 接口文档

export_instance = ExcelExport(
    input_dict=global_export_data, 
    excel_templet_path="./templet/templet.xlsx", 
    save_path="D:\\PySet/sky-excel/templet/"
)
参数介绍
input_dict输入的字典数据格式是[{..},{..}......]
excel_templet_path:保存模板的路径确保程序可以找到你的模板excel文件
excel_templet_title:当前仅仅可以导出一个sheet不可以实现批量的导出所以需要指定默认值Sheet1
save_path:保存的文件路径不传则返回文件流直接返回前端提供下载注意返回时候需要修改响应头协议

导出方法
data, err = export_instance.export()
data:返回文件地址或者文件流前提是没有异常的情况下否则返回空
err:返回的是异常提示

Django 返回流提供下载

templet_path = ROOT_DIR + "/excel_templates/templet.xlsx"
exporter = ExcelExport(input_dict=global_export_data, excel_templet_path=templet_path)
data, err = exporter.export()
if err:
    return JsonResponse({"err": 1000, "msg": err})
response = HttpResponse(
    content_type='application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
)
response['Content-Disposition'] = 'attachment;filename=export_overview.xlsx'
response.write(data)
return response

Part 3. 版本更新

1.0.5

1.支持python2.7与python3.0以上版本

2.增加边界判断

3.直接拷贝模板,避免了表头样式问题。

4.支持文字+表达式

5.使用规则,最后一行表示表达式行,所以模板应该清除掉多余不需要的单元格内容。

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sky_excel-1.0.5.tar.gz (8.5 kB view details)

Uploaded Source

Built Distribution

sky_excel-1.0.5-py3-none-any.whl (22.8 kB view details)

Uploaded Python 3

File details

Details for the file sky_excel-1.0.5.tar.gz.

File metadata

  • Download URL: sky_excel-1.0.5.tar.gz
  • Upload date:
  • Size: 8.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.7.5

File hashes

Hashes for sky_excel-1.0.5.tar.gz
Algorithm Hash digest
SHA256 291f3c8d523fd893e194eb7485f5ec096c45b21cf2ab5d8145e96fe2b135aed8
MD5 53a0f94ad67f14f0de0c84829802bc68
BLAKE2b-256 1b185ac4163ad62d6f51033c12339f575dade1e18af9e6fcdf89cdda73cfe2c1

See more details on using hashes here.

File details

Details for the file sky_excel-1.0.5-py3-none-any.whl.

File metadata

  • Download URL: sky_excel-1.0.5-py3-none-any.whl
  • Upload date:
  • Size: 22.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.7.5

File hashes

Hashes for sky_excel-1.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 a530a4834e2283d881fc981ba23de0b337bb09a9a946fd227977efb008ea5a7d
MD5 64e4459831c36f24072e0a6db7c77f06
BLAKE2b-256 e4d4572049508aa3a715169c3c0e075fa884dabbb19213be7fb35bb3115fc57b

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page