Esempio n. 1
0
def download_excel(req, header, data):
    if "delete" in data:
        return excel([[]])
    try:
        klass, title, func = header.split(";")
        data = [[h for h in header.split("|")]] + [[l for l in evalFunc(klass, func)]]
    except:
        data = [[h]] + [[l] for l in eval(data)]

    return excel(data)
Esempio n. 2
0
def question_xls(req, section_pk, question_pk):
    sect = get_object_or_404(Section, pk=section_pk)
    ques = get_object_or_404(Question, pk=question_pk)

    def __row(answer):
        sub = answer.submission

        return [
            answer.normalized, sub.reported_by, sub.location, sub.submitted
        ]

    return excel([["Answer", "Reporter", "Location", "Date"]] +
                 [__row(ans) for ans in ques.answers.all()])
Esempio n. 3
0
def question_xls(req, section_pk, question_pk):
    sect = get_object_or_404(Section, pk=section_pk)
    ques = get_object_or_404(Question, pk=question_pk)
    
    def __row(answer):
        sub = answer.submission
        
        return [
            answer.normalized,
            sub.reported_by,
            sub.location,
            sub.submitted
        ]
    
    return excel(
        [["Answer", "Reporter", "Location", "Date"]] +
        [__row(ans) for ans in ques.answers.all()])
Esempio n. 4
0
def CreateResultSet(req,header,data,exceldata,title,breadcrumbs):
    resultset = {}
    dataset_count = len(data)

    
    object_data = {}
    list_data = [] #list-i-fy excel data
        

    for c in  object_data:
        od = object_data[c]
        h = header[c]
        for i in range(0,len(od)):
            resultset["header_col%s_%s"%(c,i)] = h[i]
            resultset["data_col%s_%s"%(c,i)] = paginated(req,od[i],prefix="data_col%s_%s"%(c,i)),
        resultset["column_count%s_%s"] = (c,len(od))

    resultset["column_count"] = len(object_data)
    resultset["excel"] = excel(list_data)
    resultset["title"] = title
    resultset["breadcrumbs"] = breadcrumbs
    return resultset
Esempio n. 5
0
def export_xls(req, type):
    header = Nutrition.header()
    data = parsedata(Nutrition.objects.all(),header)
   
    return excel(
        [header] + data)