需要理解 Django_Excel 函数里面参数的意义 ,仔细阅读下面的 文章
链接 :http://django-excel.readthedocs.io/en/latest/
明天需要 处理的是 1 日本那边的数据 是怎么分的 ,下载的数据类型是什么样子的
2 数据列 确定以后做成 policy 形式 ,这个 我觉得参考 auth 那个会比较好!!,分层进行表示
3 view 里面import 的数据 需要不同的列名称 ,所以 应该还要 把对应 列名传到 view 里面
def export_datas(request,atype):
if atype == "sheet":def choice_func(row):
print row[0]
q = Question.objects.filter(slug=row[0])[0]
row[0] = q
return row
models=[
(Question, ['question_text', 'pub_date', 'slug'], None, 0),
(Choice, ['question_happp', 'choice_text', 'votes'], choice_func, 0)
]
#这边 Model涉及到Model层的改动吧?,Choice和 Question 分别 代表 sheet 的名字
return excel.make_response_from_a_table(
Question, 'xls', file_name="sheet_test")
elif atype == "book":
return excel.make_response_from_tables(
[Property], 'xls', file_name="book")
elif atype == "custom":
Propertys = Property.objects.get(slug='ide')
column_names = ['NameUnicode','Latitude','Longitude','ProjectArea','YearBuilt','LandArea','PropertyTypeName','RecordStartDate','RecordEndDate','view_flag','control_flag']
return excel.make_response_from_query_sets(
Propertys,
column_names,
'xls',
file_name="custom"
)
else :
message_for_add_result = "fail"
return render_to_response('property/view.html',{'message_for_add_result': message_for_add_result}, context_instance = RequestContext(request))