Beispiel #1
0
def export_xls(directory, filehandle, language, as_template):
    wb = xlwt.Workbook(encoding='utf-8')
    ws = wb.add_sheet(directory.title[:30])

    fieldmap = get_map(directory)

    write_title(fieldmap, ws, language, directory)

    if not as_template:
        items = catalog.children(directory, fieldmap.typename)
        write_objects(items, fieldmap, ws, 1)

    wb.save(filehandle)
Beispiel #2
0
def export_xls(directory, filehandle, language, as_template, fieldmap=None):
    wb = xlwt.Workbook(encoding='utf-8')
    ws = wb.add_sheet(directory.title[:30])

    fieldmap = fieldmap or get_map(directory)

    write_title(fieldmap, ws, language, directory)

    if not as_template:
        items = catalog.children(directory, fieldmap.typename)
        write_objects(items, fieldmap, ws, 1)

    wb.save(filehandle)
Beispiel #3
0
def write_objects(objects, fieldmap, worksheet, row, writeparent=None):
    ws = worksheet

    startrow = row
    for obj in objects:

        write = lambda r: write_object(obj, fieldmap, worksheet, r, writeparent)

        for childmap in fieldmap.children:
            children = catalog.children(obj, childmap.typename)
            if children:
                row += write_objects(children, childmap, ws, row, write)
            else:
                write(row)
                row += 1

        if not fieldmap.children:
            write(row)
            row += 1

    return row - startrow
Beispiel #4
0
def write_objects(objects, fieldmap, worksheet, row, writeparent=None):
    ws = worksheet

    startrow = row
    for obj in objects:

        write = lambda r: write_object(
            obj, fieldmap, worksheet, r, writeparent
        )

        for childmap in fieldmap.children:
            children = catalog.children(obj, childmap.typename)
            if children:
                row += write_objects(children, childmap, ws, row, write)
            else:
                write(row)
                row += 1

        if not fieldmap.children:
            write(row)
            row += 1

    return row - startrow