def json2excel(items, keys, filename, page_size=60000):
    """ max_page_size is 65000 because we output old excel .xls format
    """
    wb = xlwt.Workbook()
    rowindex = 0
    sheetindex = 0
    for item in items:
        if rowindex % page_size == 0:
            sheetname = "%02d" % sheetindex
            ws = wb.add_sheet(sheetname)
            rowindex = 0
            sheetindex += 1

            colindex = 0
            for key in keys:
                ws.write(rowindex, colindex, key)
                colindex += 1
            rowindex += 1

        colindex = 0
        for key in keys:
            v = item.get(key, "")
            if type(v) == list:
                v = ','.join(v)
            if type(v) == set:
                v = ','.join(v)
            ws.write(rowindex, colindex, v)
            colindex += 1
        rowindex += 1

    logging.debug(filename)
    wb.save(filename)