def to_excel_reduction(self, request, queryset):
        path = MEDIA_ROOT + 'download_xls/' + request.user.username
        mkdir_p(MEDIA_ROOT + 'download_xls')
        os.popen('chmod 777 %s' % (MEDIA_ROOT + 'download_xls'))
        mkdir_p(path)
        os.popen('chmod 777 %s' % (path))

        w = Workbook()
        sheet = w.add_sheet('cost_reduction')
        sheet.write(0, 0, u'id')
        sheet.write(0, 1, u'商品编码')
        sheet.write(0, 2, u'商品名称')
        sheet.write(0, 3, u'原价')
        sheet.write(0, 4, u'现价')
        sheet.write(0, 5, u'申请人')
        sheet.write(0, 6, u'申请时间')

        row = 0
        for qs in queryset:
            cost_reduction = eval(qs.CostReduction) if qs.CostReduction else {}
            for key, val in cost_reduction.items():
                row = row + 1
                column = 0
                sheet.write(row, column, qs.id)

                column = column + 1
                sheet.write(row, column, key)

                column = column + 1
                sheet.write(row, column, qs.Name2)

                column = column + 1
                sheet.write(row, column, val['old_price'])

                column = column + 1
                sheet.write(row, column, val['new_price'])

                column = column + 1
                sheet.write(row, column, qs.SQStaffNameing)

                column = column + 1
                sheet.write(row, column, str(qs.SQTimeing))
        filename = request.user.username + '_' + datetime.now().strftime('%Y%m%d%H%M%S') + '.xls'
        w.save(path + '/' + filename)
        os.popen(r'chmod 777 %s' % (path + '/' + filename))

        # 上传oss对象
        auth = oss2.Auth(ACCESS_KEY_ID, ACCESS_KEY_SECRET)
        bucket = oss2.Bucket(auth, ENDPOINT, BUCKETNAME_XLS)
        bucket.create_bucket(oss2.BUCKET_ACL_PUBLIC_READ)
        # 删除现有的
        for object_info in oss2.ObjectIterator(bucket,prefix='%s/%s_' % (request.user.username, request.user.username)):
            bucket.delete_object(object_info.key)
        bucket.put_object(u'%s/%s' % (request.user.username, filename), open(path + '/' + filename))
        messages.error(request, u'%s%s.%s/%s/%s' % (PREFIX, BUCKETNAME_XLS, ENDPOINT_OUT, request.user.username,filename) + u':成功导出,可点击Download下载到本地............................。')
Beispiel #2
0
    def excel_operate(self, need_operate_list, username_en, status):
        from xlwt import *
        path = MEDIA_ROOT + 'download_xls/' + username_en
        mkdir_p(MEDIA_ROOT + 'download_xls')
        os.popen('chmod 777 %s' % (MEDIA_ROOT + 'download_xls'))
        mkdir_p(path)
        os.popen('chmod 777 %s' % (path))

        w = Workbook()
        sheet = w.add_sheet('shelf')

        # 写数据
        row = -1
        for sku in need_operate_list:
            online_info_objs = t_online_info.objects.filter(SKU=sku,
                                                            Status=status)
            if online_info_objs:
                for online_info_obj in online_info_objs:
                    row = row + 1
                    column = 0
                    sheet.write(row, column, online_info_obj.ShopSKU)

                    column = column + 1
                    sheet.write(row, column, online_info_obj.ShopName)

        if status == 'Enabled':
            ss = 'Disabled'
        else:
            ss = 'Enabled'
        filename = username_en + '_' + datetime.now().strftime(
            '%Y%m%d%H%M%S') + '_' + ss + '.xls'
        w.save(path + '/' + filename)
        os.popen(r'chmod 777 %s' % (path + '/' + filename))

        # 上传oss对象
        auth = oss2.Auth(ACCESS_KEY_ID, ACCESS_KEY_SECRET)
        bucket = oss2.Bucket(auth, ENDPOINT, BUCKETNAME_XLS)
        bucket.create_bucket(oss2.BUCKET_ACL_PUBLIC_READ)
        # 删除现有的
        for object_info in oss2.ObjectIterator(bucket,
                                               prefix='%s/%s_' %
                                               (username_en, username_en)):
            bucket.delete_object(object_info.key)
        bucket.put_object(u'%s/%s' % (username_en, filename),
                          open(path + '/' + filename))
        out_url = u'%s%s.%s/%s/%s' % (PREFIX, BUCKETNAME_XLS, ENDPOINT_OUT,
                                      username_en, filename)
        return out_url
    def to_excel_new(self, request, queryset):
        modify_details_list = []
        modify_sq_name_list = []
        merge_details_list = []
        merge_sq_name_list = []
        old_id_list = []
        for qs in queryset:
            details = eval(qs.Details) if qs.Details else {}
            if details:
                if qs.Select == '7':
                    merge_details_list.append(details)
                    merge_sq_name_list.append(qs.SQStaffNameing)
                else:
                    modify_details_list.append(details)
                    modify_sq_name_list.append(qs.SQStaffNameing)
            else:
                old_id_list.append(str(int(qs.id)))
        if old_id_list:
            old_id_str = ','.join(old_id_list)
            messages.error(request, '您当前使用的“新版导出Excel”功能,下列ID:%s 信息修改为旧版申请记录,已为您剔除。如果您仍想要导出这部分,请选择“导出Excel(旧版)”导出这部分' % old_id_str)
        path = MEDIA_ROOT + 'download_xls/' + request.user.username
        mkdir_p(MEDIA_ROOT + 'download_xls')
        os.popen('chmod 777 %s' % (MEDIA_ROOT + 'download_xls'))
        mkdir_p(path)
        os.popen('chmod 777 %s' % (path))
        w = Workbook()

        self.excel_modify(w, modify_details_list, modify_sq_name_list)
        self.excel_merge(w, merge_details_list, merge_sq_name_list)

        filename = request.user.username + '_' + datetime.now().strftime('%Y%m%d%H%M%S') + '.xls'
        w.save(path + '/' + filename)
        os.popen(r'chmod 777 %s' % (path + '/' + filename))
        # 上传oss对象
        auth = oss2.Auth(ACCESS_KEY_ID, ACCESS_KEY_SECRET)
        bucket = oss2.Bucket(auth, ENDPOINT, BUCKETNAME_XLS)
        bucket.create_bucket(oss2.BUCKET_ACL_PUBLIC_READ)
        # 删除现有的
        for object_info in oss2.ObjectIterator(bucket, prefix='%s/%s_' % (request.user.username, request.user.username)):
            bucket.delete_object(object_info.key)
        bucket.put_object(u'%s/%s' % (request.user.username, filename), open(path + '/' + filename))
        messages.error(request, u'%s%s.%s/%s/%s' % (PREFIX, BUCKETNAME_XLS, ENDPOINT_OUT, request.user.username, filename) + u':成功导出,可点击Download下载到本地............................。')
Beispiel #4
0
    def excel_shopname(self, request, queryset):
        path = MEDIA_ROOT + 'download_xls/' + request.user.username
        mkdir_p(MEDIA_ROOT + 'download_xls')
        os.popen('chmod 777 %s' % (MEDIA_ROOT + 'download_xls'))
        mkdir_p(path)
        os.popen('chmod 777 %s' % (path))

        w = Workbook()
        sheet = w.add_sheet(u'铺货店铺')
        sheet.write(0, 0, u'店铺名称')

        row = 0
        column = 0
        for qs in queryset:
            row = row + 1
            sheet.write(row, column, qs.ShopName)

        filename = request.user.username + '_' + datetime.now().strftime(
            '%Y%m%d%H%M%S') + '.xls'
        w.save(path + '/' + filename)
        os.popen(r'chmod 777 %s' % (path + '/' + filename))

        # 上传oss对象
        auth = oss2.Auth(ACCESS_KEY_ID, ACCESS_KEY_SECRET)
        bucket = oss2.Bucket(auth, ENDPOINT, BUCKETNAME_XLS)
        bucket.create_bucket(oss2.BUCKET_ACL_PUBLIC_READ)
        # 删除现有的
        for object_info in oss2.ObjectIterator(
                bucket,
                prefix='%s/%s_' %
            (request.user.username, request.user.username)):
            bucket.delete_object(object_info.key)
        bucket.put_object(u'%s/%s' % (request.user.username, filename),
                          open(path + '/' + filename))
        messages.error(
            request, u'%s%s.%s/%s/%s' % (PREFIX, BUCKETNAME_XLS, ENDPOINT_OUT,
                                         request.user.username, filename) +
            u':成功导出,可点击Download下载到本地............................。')
    def to_excel(self, request, queryset):
        # new_id_list = []
        # for qs in queryset:
            # xg_content = qs.XGcontext if qs.XGcontext else ''
            # if not xg_content:
            #     new_id_list.append(str(int(qs.id)))
        # if new_id_list:
        #     new_id_str = ','.join(new_id_list)
        #     messages.error(request, '您当前使用的“旧版导出Excel”功能,下列ID:%s 信息修改为新版申请记录,请剔除后再使用旧功能导出!!!' % new_id_str)
        # else:
        #     details = eval(qs.Details) if qs.Details else {}
        #     if not details:
        path = MEDIA_ROOT + 'download_xls/' + request.user.username
        mkdir_p(MEDIA_ROOT + 'download_xls')
        os.popen('chmod 777 %s' % (MEDIA_ROOT + 'download_xls'))
        mkdir_p(path)
        os.popen('chmod 777 %s' % (path))

        w = Workbook()
        sheet = w.add_sheet('information_modify')

        sheet.write(0, 0, u'id')
        sheet.write(0, 1, u'商品编码')
        sheet.write(0, 2, u'商品名称')
        sheet.write(0, 3, u'英文Keywords')
        sheet.write(0, 4, u'中文Keywords')
        sheet.write(0, 5, u'申请人')
        sheet.write(0, 6, u'申请时间')
        sheet.write(0, 7, u'修改类型')
        sheet.write(0, 8, u'修改描述')
        sheet.write(0, 9, u'旧值')
        sheet.write(0, 10, u'新值')

        sheet.write(0, 11, u'一部领用人')
        sheet.write(0, 12, u'一部领用日期')
        sheet.write(0, 13, u'一部领用状态')
        sheet.write(0, 14, u'二部领用人')
        sheet.write(0, 15, u'二部领用日期')
        sheet.write(0, 16, u'二部领用状态')
        sheet.write(0, 17, u'三部领用人')
        sheet.write(0, 18, u'三部领用日期')
        sheet.write(0, 19, u'三部领用状态')
        sheet.write(0, 20, u'四部领用人')
        sheet.write(0, 21, u'四部领用日期')
        sheet.write(0, 22, u'四部领用状态')
        sheet.write(0, 23, u'五部领用人')
        sheet.write(0, 24, u'五部领用日期')
        sheet.write(0, 25, u'五部领用状态')

        new_id_list = []
        # 写数据
        row = 0
        for qs in queryset:
            details = eval(qs.Details) if qs.Details else {}
            if details:
                new_id_list.append(str(int(qs.id)))
                continue

            InputBox_list_s = []
            if qs.InputBox is not None:
                InputBox_list_s = qs.InputBox.split(',')
            num = 0
            qs_id = ''
            for InputBox_list_l in InputBox_list_s:
                if InputBox_list_l.strip() != '':
                    row = row + 1
                    column = 0
                    sheet.write(row, column, qs.id)

                    column = column + 1
                    sheet.write(row, column, InputBox_list_l)

                    column = column + 1
                    sheet.write(row, column, qs.Name2)

                    column = column + 1
                    sheet.write(row, column, qs.Keywords)

                    column = column + 1
                    sheet.write(row, column, qs.Keywords2)

                    column = column + 1
                    sheet.write(row, column, qs.SQStaffNameing)

                    column = column + 1
                    rt = ''
                    rt = u'%s%s' % (rt, qs.SQTimeing)
                    sheet.write(row, column, u'%s' % rt)

                    column = column + 1
                    sheet.write(row, column, TYPE_DICT.get(qs.Select, ''))

                    column = column + 1
                    sheet.write(row, column, qs.XGcontext)

                    if qs.newvalue and qs.oldvalue:
                        oldvalues = qs.oldvalue.split(',')
                        newvalues = qs.newvalue.split(',')
                        if not qs_id or not qs_id == qs.id:
                            qs_id = qs.id
                            num = 0
                            oldvalue = oldvalues[num]
                            newvalue = newvalues[num]
                            num += 1
                        else:
                            try:
                                oldvalue = oldvalues[num]
                            except:
                                oldvalue = ''
                            try:
                                newvalue = newvalues[num]
                            except:
                                newvalue = ''
                            num += 1
                    else:
                        oldvalue = ''
                        newvalue = ''

                    column = column + 1
                    sheet.write(row, column, oldvalue)

                    column = column + 1
                    sheet.write(row, column, newvalue)

                    column = column + 1
                    sheet.write(row, column, qs.Dep1)

                    column = column + 1
                    sheet.write(row, column, u'%s' % qs.Dep1Date)

                    column = column + 1
                    sheet.write(row, column, qs.Dep1Sta)

                    column = column + 1
                    sheet.write(row, column, qs.Dep2)

                    column = column + 1
                    sheet.write(row, column, u'%s' % qs.Dep2Date)

                    column = column + 1
                    sheet.write(row, column, qs.Dep2Sta)

                    column = column + 1
                    sheet.write(row, column, qs.Dep3)

                    column = column + 1
                    sheet.write(row, column, u'%s' % qs.Dep3Date)

                    column = column + 1
                    sheet.write(row, column, qs.Dep3Sta)

                    column = column + 1
                    sheet.write(row, column, qs.Dep4)

                    column = column + 1
                    sheet.write(row, column, u'%s' % qs.Dep4Date)

                    column = column + 1
                    sheet.write(row, column, qs.Dep4Sta)

                    column = column + 1
                    sheet.write(row, column, qs.Dep5)

                    column = column + 1
                    sheet.write(row, column, u'%s' % qs.Dep5Date)

                    column = column + 1
                    sheet.write(row, column, qs.Dep5Sta)

        filename = request.user.username + '_' + datetime.now().strftime('%Y%m%d%H%M%S') + '.xls'
        w.save(path + '/' + filename)
        os.popen(r'chmod 777 %s' % (path + '/' + filename))

        # 上传oss对象
        auth = oss2.Auth(ACCESS_KEY_ID, ACCESS_KEY_SECRET)
        bucket = oss2.Bucket(auth, ENDPOINT, BUCKETNAME_XLS)
        bucket.create_bucket(oss2.BUCKET_ACL_PUBLIC_READ)
        # 删除现有的
        for object_info in oss2.ObjectIterator(bucket, prefix='%s/%s_' % (request.user.username, request.user.username)):
            bucket.delete_object(object_info.key)
        bucket.put_object(u'%s/%s' % (request.user.username, filename), open(path + '/' + filename))
        messages.error(request, u'%s%s.%s/%s/%s' % (PREFIX, BUCKETNAME_XLS, ENDPOINT_OUT, request.user.username, filename) + u':成功导出,可点击Download下载到本地............................。')
        if new_id_list:
            new_id_str = ','.join(new_id_list)
            messages.error(request, '您当前使用的“旧版导出Excel”功能,下列ID:%s 信息修改为新版申请记录,已为您剔除。如果您仍想要导出这部分,请选择“导出Excel(新版)”导出这部分' % new_id_str)
    def to_excel(self, request, queryset):
        from xlwt import *
        path = MEDIA_ROOT + 'download_xls/' + request.user.username
        mkdir_p(MEDIA_ROOT + 'download_xls')
        os.popen('chmod 777 %s' % (MEDIA_ROOT + 'download_xls'))

        mkdir_p(path)
        os.popen('chmod 777 %s' % (path))

        w = Workbook()
        sheet = w.add_sheet('store')
        sheet.write(0, 0, u'平台')
        sheet.write(0, 1, u'导出日期')
        sheet.write(0, 2, u'订单编号')
        sheet.write(0, 3, u'延迟天数')
        sheet.write(0, 4, u'卖家简称')
        sheet.write(0, 5, u'商品明细')
        sheet.write(0, 6, u'交易时间')
        sheet.write(0, 7, u'导入人')
        sheet.write(0, 8, u'导入Online时间')

        row = 0
        for qs in queryset:
            row = row + 1
            column = 0
            sheet.write(row, column, qs.Plateform)

            column = column + 1
            sheet.write(row, column, str(qs.ExportDate))

            column = column + 1
            sheet.write(row, column, str(qs.OrderId))

            column = column + 1
            sheet.write(row, column, str(qs.DelayDays))

            column = column + 1
            sheet.write(row, column, qs.Seller)

            column = column + 1
            sheet.write(row, column, qs.Details)

            column = column + 1
            sheet.write(row, column, str(qs.TradingTime))

            column = column + 1
            sheet.write(row, column, qs.CreateStaff)

            column = column + 1
            sheet.write(row, column, str(qs.CreateTime))
        filename = request.user.username + '_' + datetime.now().strftime(
            '%Y%m%d%H%M%S') + '.xls'
        w.save(path + '/' + filename)
        os.popen(r'chmod 777 %s' % (path + '/' + filename))

        # 上传oss对象
        auth = oss2.Auth(ACCESS_KEY_ID, ACCESS_KEY_SECRET)
        bucket = oss2.Bucket(auth, ENDPOINT, BUCKETNAME_XLS)
        bucket.create_bucket(oss2.BUCKET_ACL_PUBLIC_READ)
        # 删除现有的
        for object_info in oss2.ObjectIterator(
                bucket,
                prefix='%s/%s_' %
            (request.user.username, request.user.username)):
            bucket.delete_object(object_info.key)
        bucket.put_object(u'%s/%s' % (request.user.username, filename),
                          open(path + '/' + filename))
        messages.error(
            request, u'%s%s.%s/%s/%s' % (PREFIX, BUCKETNAME_XLS, ENDPOINT_OUT,
                                         request.user.username, filename) +
            u':成功导出,可点击Download下载到本地............................。')
    def to_export_excel(self, request, queryset):
        from xlwt import *
        from datetime import datetime
        from skuapp.modelsadminx.t_product_Admin import MEDIA_ROOT, mkdir_p, os, oss2, ACCESS_KEY_ID, ACCESS_KEY_SECRET, \
            ENDPOINT, BUCKETNAME_XLS, PREFIX, ENDPOINT_OUT

        path = MEDIA_ROOT + 'download_xls/' + request.user.username
        mkdir_p(MEDIA_ROOT + 'download_xls')
        os.popen('chmod 777 %s' % (MEDIA_ROOT + 'download_xls'))

        mkdir_p(path)
        os.popen('chmod 777 %s' % (path))

        w = Workbook()

        sheet = w.add_sheet(u'WISH广告财务报表')
        sheet.write(0, 0, u'店铺名称')
        sheet.write(0, 1, u'广告创建人')
        sheet.write(0, 2, u'仓库名称')
        sheet.write(0, 3, u'日期')
        sheet.write(0, 4, u'总曝光量')
        sheet.write(0, 5, u'付费曝光量')
        sheet.write(0, 6, u'花费')
        sheet.write(0, 7, u'订单数')
        sheet.write(0, 8, u'销售额')

        row = 0
        for qs in queryset:
            row = row + 1
            column = 0
            sheet.write(row, column, qs.shopname)

            column = column + 1
            sheet.write(row, column, qs.createuser)

            column = column + 1
            sheet.write(row, column, qs.storename)

            column = column + 1
            sheet.write(row, column, str(qs.p_date))

            column = column + 1
            sheet.write(row, column, qs.impressions)

            column = column + 1
            sheet.write(row, column, qs.paid_impressions)

            column = column + 1
            sheet.write(row, column, qs.spend)

            column = column + 1
            sheet.write(row, column, qs.sales)

            column = column + 1
            sheet.write(row, column, qs.gmv)

        filename = request.user.username + '_' + datetime.now().strftime(
            '%Y%m%d%H%M%S') + '.xls'
        w.save(path + '/' + filename)
        os.popen(r'chmod 777 %s' % (path + '/' + filename))

        # 上传oss对象
        auth = oss2.Auth(ACCESS_KEY_ID, ACCESS_KEY_SECRET)
        bucket = oss2.Bucket(auth, ENDPOINT, BUCKETNAME_XLS)
        bucket.create_bucket(oss2.BUCKET_ACL_PUBLIC_READ)
        # 删除现有的
        for object_info in oss2.ObjectIterator(
                bucket,
                prefix='%s/%s_' %
            (request.user.username, request.user.username)):
            bucket.delete_object(object_info.key)
        bucket.put_object(u'%s/%s' % (request.user.username, filename),
                          open(path + '/' + filename))

        messages.success(
            request, u'%s%s.%s/%s/%s' % (PREFIX, BUCKETNAME_XLS, ENDPOINT_OUT,
                                         request.user.username, filename) +
            u':成功导出,可点击Download下载到本地............................。')
Beispiel #8
0
    def to_excel(self, request, queryset):
        problem_type = {
            'fch': u'仓储部-发错货',
            'lfh': u'仓储部-漏发货',
            'dh': u'仓储部-点货',
            'zjwt': u'仓储部-质检问题',
            'scj': u'仓储部-上错架',
            'ccwt': u'产品部-尺寸问题',
            'zlwt': u'产品部-质量问题',
            'ybwt': u'产品部-预包问题',
            'qq': u'侵权',
            'cpyxj': u'产品已下架',
            'qt': u'其它'
        }

        from xlwt import *
        path = MEDIA_ROOT + 'download_xls/' + request.user.username
        mkdir_p(MEDIA_ROOT + 'download_xls')
        os.popen('chmod 777 %s' % (MEDIA_ROOT + 'download_xls'))

        mkdir_p(path)
        os.popen('chmod 777 %s' % (path))

        w = Workbook()
        sheet = w.add_sheet('price_check_1')
        sheet.write(0, 0, u'SKU')
        sheet.write(0, 1, u'平台')
        sheet.write(0, 2, u'浦沅订单号')
        sheet.write(0, 3, u'提交人')
        sheet.write(0, 4, u'提交日期')
        sheet.write(0, 5, u'问题类型')
        sheet.write(0, 6, u'具体反馈')
        sheet.write(0, 7, u'产品专员')
        sheet.write(0, 8, u'产品专员备注')
        sheet.write(0, 9, u'采购员')
        sheet.write(0, 10, u'采购员备注')
        sheet.write(0, 11, u'质检员')
        sheet.write(0, 12, u'质检员备注')
        sheet.write(0, 13, u'仓库员')
        sheet.write(0, 14, u'仓库备注')
        sheet.write(0, 15, u'最终审核人')
        sheet.write(0, 16, u'最终备注')
        sheet.write(0, 17, u'图片一')
        sheet.write(0, 18, u'图片一')
        sheet.write(0, 19, u'图片一')
        sheet.write(0, 20, u'图片一')
        sheet.write(0, 21, u'图片一')

        # 写数据
        row = 0

        for qs in queryset:

            row = row + 1
            column = 0
            sheet.write(row, column, qs.SKU)

            column = column + 1
            sheet.write(row, column, qs.Plateform)

            column = column + 1
            sheet.write(row, column, qs.OrderID)

            column = column + 1
            sheet.write(row, column, qs.Submitter)

            column = column + 1
            sheet.write(row, column, str(qs.SubmitTime))

            column = column + 1
            sheet.write(row, column, problem_type[qs.ProblemType])

            column = column + 1
            sheet.write(row, column, qs.Detail)

            column = column + 1
            sheet.write(row, column, qs.CPZY)

            column = column + 1
            sheet.write(row, column, qs.CPZY_Note)

            column = column + 1
            sheet.write(row, column, qs.CGY)

            column = column + 1
            sheet.write(row, column, qs.CGY_Note)

            column = column + 1
            sheet.write(row, column, qs.ZJY)

            column = column + 1
            sheet.write(row, column, qs.ZJY_Note)

            column = column + 1
            sheet.write(row, column, qs.CKY)

            column = column + 1
            sheet.write(row, column, qs.CK_Note)

            column = column + 1
            sheet.write(row, column, qs.ZJY_Final)

            column = column + 1
            sheet.write(row, column, qs.Final_Note)

            column = column + 1
            sheet.write(row, column, str(qs.Picture_1))

            column = column + 1
            sheet.write(row, column, str(qs.Picture_2))

            column = column + 1
            sheet.write(row, column, str(qs.Picture_3))

            column = column + 1
            sheet.write(row, column, str(qs.Picture_4))

            column = column + 1
            sheet.write(row, column, str(qs.Picture_5))

        filename = request.user.username + '_' + datetime.now().strftime(
            '%Y%m%d%H%M%S') + '.xls'
        w.save(path + '/' + filename)
        os.popen(r'chmod 777 %s' % (path + '/' + filename))

        # 上传oss对象
        auth = oss2.Auth(ACCESS_KEY_ID, ACCESS_KEY_SECRET)
        bucket = oss2.Bucket(auth, ENDPOINT, BUCKETNAME_XLS)
        bucket.create_bucket(oss2.BUCKET_ACL_PUBLIC_READ)
        # 删除现有的
        for object_info in oss2.ObjectIterator(
                bucket,
                prefix='%s/%s_' %
            (request.user.username, request.user.username)):
            bucket.delete_object(object_info.key)
        bucket.put_object(u'%s/%s' % (request.user.username, filename),
                          open(path + '/' + filename))

        messages.error(
            request, u'%s%s.%s/%s/%s' % (PREFIX, BUCKETNAME_XLS, ENDPOINT_OUT,
                                         request.user.username, filename) +
            u':成功导出,可点击Download下载到本地............................。')