Django包,可轻松呈现Excel电子表格

django-excel-response的Python项目详细描述


Latest VersionTest/build statusCode coverage

将转换QuerySet的HttpResponse的子类, 或序列,输入Excel电子表格或 为Excel格式化的CSV文件,具体取决于数据量

安装

pip install django-excel-response

提供的类

  • excel_response.response.ExcelResponse

    Accepted arguments:

    • ^{tt2}$ - A queryset or list of lists from which to construct the output
    • ^{tt3}$ - The filename which should be suggested in the http response, minus the file extension (default: excel_data)
    • ^{tt4}$ - The name of the worksheet inside the spreadsheet into which the data will be inserted (default: None)
    • ^{tt5}$ - A boolean stating whether to force CSV output (default: False)
    • ^{tt6}$ - The font to be applied to the header row of the spreadsheet; must be an instance of ^{tt7}$ (default: None)
    • ^{tt8}$ - The font to be applied to all data cells in the spreadsheet; must be an instance of ^{tt7}$ (default: None)
  • excel_response.views.ExcelMixin

  • excel_response.views.ExcelView

示例

基于功能的视图

您可以从queryset构造数据

fromexcel_responseimportExcelResponsedefexcelview(request):objs=SomeModel.objects.all()returnExcelResponse(objs)

或者可以手动构造数据。

fromexcel_responseimportExcelResponsedefexcelview(request):data=[['Column 1','Column 2'],[1,2][23,67]]returnExcelResponse(data,'my_data')

基于类的视图

这些都是简单的进口和去

fromexcel_responseimportExcelViewclassModelExportView(ExcelView):model=SomeModel

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java搜索按钮不适用于我   java制作一个应用程序来打开您自己的文件扩展名   XMemcached中的java异步集   java无法在Android上使用HTML5 canvas touch   java是否可以用PHP为Restlet创建客户端?   java在主题中添加图标。AppCompat。光   java Safari错误,无法打开浏览器   java gson解析json值中commaseparatedvalue字符串中的项   java如何使用Quarkus在卡夫卡的同一主题中设置多个使用者   java组织。json。JSONException:在{main}()的第6个字符处的main后面应该是“:”   windowbuilder如何将Java文件导出到GATE developer   java这与安卓 studio ide问题有关,在更新我们的ide之后   java Android将活动加载到类中<?>对象   java如何在springdatajpa中使用DISTINCT、GROUP BY和ORDER BY?   使用jlink的java可复制构建