本文整理汇总了Python中export.Exporter.xls_exporter方法的典型用法代码示例。如果您正苦于以下问题:Python Exporter.xls_exporter方法的具体用法?Python Exporter.xls_exporter怎么用?Python Exporter.xls_exporter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类export.Exporter
的用法示例。
在下文中一共展示了Exporter.xls_exporter方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ExporterView
# 需要导入模块: from export import Exporter [as 别名]
# 或者: from export.Exporter import xls_exporter [as 别名]
def ExporterView(request):
# check if request is post if not raise Forbidden error
if not request.method == 'POST':
return HttpResponseForbidden()
# try:
# set legal types to export
types = ['csv', 'xls', 'pdf']
# pass all POST params
export_type = request.POST['type']
export_model = signing.loads(request.POST['model'])
export_app = signing.loads(request.POST['app'])
export_filters = request.POST['filters']
# check if export type is on legal list
if export_type not in types:
return HttpResponseNotAllowed()
# get model object
model = get_model(export_app, export_model)
filters = json.loads(export_filters)
# check if model is exportable
if not model._meta.exportable:
return HttpResponseNotAllowed()
exporter = Exporter(model, filters, request)
if export_type == 'xls':
response = exporter.xls_exporter()
elif export_type == 'pdf':
response = exporter.pdf_exporter()
elif export_type == 'csv':
response = exporter.csv_exporter()
return response