예제 #1
0
def write_excel(list_param, excel_path):
    rb = xlrd.open_workbook(excel_path, formatting_info=True)
    wb = xl_copy(rb)
    # sheet_name=str(datetime.datetime.now().strftime('%Y-%m-%d__%H-%M-%S'))
    sheet_name = str(
        datetime.datetime.fromtimestamp(
            list_param[1][5]).strftime('%Y-%m-%d__%H-%M-%S'))
    ws = wb.add_sheet(sheet_name)
    ws_row = 0
    for i in list_param:
        for j in range(6):
            if ws_row > 0:
                if j == 0:
                    try:
                        i[j] = dict_item[str(i[j])]
                    except:
                        with open(r'D:\TSM_Export_2\tmp_data.txt', 'a') as f:
                            print(i[j], file=f)

                if j in range(1, 3):
                    i[j] = i[j] / 10000
            if ws_row > 0 and j == 5:
                i[j] = str(datetime.datetime.fromtimestamp(i[j]))

            ws.write(ws_row, j, i[j])
        ws_row += 1
    wb.save(excel_path)
예제 #2
0
def sss(a, url):
    html = requests.post(url)
    # info = json.loads(eval("u" + "\'" + html.text + "\'"))
    info = json.loads(html.text)
    rb = xlrd.open_workbook('all.xls', formatting_info=True)
    # make a copy of it
    wb = xl_copy(rb)
    sheet = wb.add_sheet(a)  # 在打开的excel中添加一个sheet
    n = 0

    for i in range(len(info['more_city'])):
        sheet.write(i, 0, info['more_city'][i]['province'])
        sheet.write(i, 1, info['more_city'][i]['num'])
        n += 1
    n += 1

    for i in info['content']:
        sheet.write(n, 0, i['name'])
        sheet.write(n, 1, i['num'])
        n += 1
    n += 1
    for i in range(len(info['more_city'])):
        print(info['more_city'][i]['province'], info['more_city'][i]['num'])
        sheet.write(n, 0, info['more_city'][i]['province'])
        sheet.write(n, 1, info['more_city'][i]['num'])
        n += 1
        for j in info['more_city'][i]['city']:
            sheet.write(n, 0, j['name'])
            sheet.write(n, 1, j['num'])
            n += 1
            print('   ', end='')
            print(j['name'], j['num'])
        n += 1
        print('\n')
    wb.save('all.xls')
예제 #3
0
def write_excel_issue(sheet_name, *infos):
    cur_day = datetime.datetime.now().strftime('%Y%m%d')
    excel_file_name = 'issues_count_%s.xls' % cur_day
    if os.path.exists(excel_file_name):
        wb = xlrd.open_workbook(excel_file_name)
        excel = xl_copy(wb)
    else:
        excel = xlwt.Workbook(encoding='utf-8')
    sheet = excel.add_sheet(sheet_name)
    item_list = [
        "版本", "No.", "类型", "名称", "提交人", "解决人", "回归人", "更新时间", "回归结果",
        "是否ReOpen", "标签"
    ]
    for i in range(len(item_list)):
        sheet.write(0, i, item_list[i])
    for i in range(len(infos)):
        value_list = [
            infos[i]['milestone'], infos[i]['issue_id'], infos[i]['type'],
            infos[i]['title'], infos[i]['author'], infos[i]['assignee'],
            infos[i]['author'], infos[i]['updated'], infos[i]['result'],
            infos[i]['ReOpen'], infos[i]['lables']
        ]
        for j in range(len(value_list)):
            sheet.write(i + 1, j, value_list[j])
    excel.save(excel_file_name)
예제 #4
0
파일: excel.py 프로젝트: bopopescu/TestMgmt
 def write_testplan(self, sheet_name, *infos):
     if os.path.exists(self.file_name):
         wb = xlrd.open_workbook(self.file_name)
         excel = xl_copy(wb)
     else:
         excel = xlwt.Workbook(encoding='utf-8')
     sheet = excel.add_sheet(sheet_name)
     item_list = ["版本", "任务名称", "优先级", "计划开始时间", "计划结束时间", "实际开始时间", "时间结束时间", "完成进度","执行人员", "备注"]
     for i in range(len(item_list)):
         sheet.write(0, i, item_list[i])
     for i in range(len(infos)):
         # print("infos[%s]: %s"%(i, infos[i]))
         if infos[i]['p_start_time'] is not None:
             p_start_time = infos[i]['p_start_time'].strftime("%Y/%m/%d")
         else:
             p_start_time = ""
         if infos[i]['a_start_time'] is not None:
             a_start_time = infos[i]['a_start_time'].strftime("%Y/%m/%d")
         else:
             a_start_time = ""
         if infos[i]['p_finish_time'] is not None:
            p_finish_time = infos[i]['p_finish_time'].strftime("%Y/%m/%d")
         else:
             p_finish_time = ""
         if infos[i]['a_finish_time'] is not None:
             a_finish_time = infos[i]['a_finish_time'].strftime("%Y/%m/%d")
         else:
             a_finish_time = ""
         value_list = [infos[i]['milestone'], infos[i]['task_id'], infos[i]['priority'], p_start_time, p_finish_time, a_start_time, a_finish_time, infos[i]['progress'], infos[i]['executor'], infos[i]['remark']]
         for j in range(len(value_list)):
             sheet.write(i+1, j, value_list[j])
     excel.save(self.file_name)
     return True
예제 #5
0
def GetXLSBookWithNewSheetAtEnd(path, sheetName = None):
	isNew = not isfile(path)
	book = xlwt.Workbook(encoding="utf-8") if isNew else xl_copy(xlrd.open_workbook(path, formatting_info=True))
	if sheetName is None and not isNew: sheetName = IncrementString(book.get_sheet(-1).name)
	if sheetName is None: sheetName = "Sheet 1"
	book.add_sheet(sheetName)
	return book
예제 #6
0
 def addSheet(self, filename, sheetName):
     rb = xlrd.open_workbook(filename, formatting_info=True)
     # make a copy of it
     from xlutils.copy import copy as xl_copy
     if sheetName not in rb.sheet_names():
         wb = xl_copy(rb)
         Sheet1 = wb.add_sheet(sheetName)
         wb.save(filename)
예제 #7
0
def create_sheet(sheet_name):
    # Insere regras e headers da planilha
    book1 = xlrd.open_workbook('base.xlsx', formatting_info=True)
    book = xl_copy(book1)
    sheet = book.add_sheet(sheet_name)
    #print(book1.sheet_names())
    #fill_sheet(book1)
    fill_sheet(sheet, book)
예제 #8
0
def write_excel_count(sheet_name, **info):
    cur_day = datetime.datetime.now().strftime('%Y%m%d')
    excel_file_name = 'issues_count_%s.xls' % cur_day
    #初始化一个excel
    # print(sheet_name)
    if os.path.exists(excel_file_name):
        wb = xlrd.open_workbook(excel_file_name)
        excel = xl_copy(wb)
    else:
        excel = xlwt.Workbook(encoding='utf-8')
    #新建一个sheet
    sheet = excel.add_sheet(sheet_name)
    #设置样式
    # style = xlwt.XFStyle()#初始化样式
    # font = xlwt.Font()#创建字体
    # font.name = u'微软雅黑' #字体类型
    # font.colour_index = 6   #字体颜色
    # font.underline = True #下划线
    # font.italic = True #斜体
    # font.bold= True
    # font.height = 600    #字体大小   200等于excel字体大小中的10
    # style.font = font   #设定样式
    # pattern = xlwt.Pattern()  # Create the pattern
    # pattern.pattern = xlwt.Pattern.SOLID_PATTERN  # May be: NO_PATTERN, SOLID_PATTERN, or 0x00 through 0x12
    # pattern.pattern_fore_colour = 4  # May be: 8 through 63. 0 = Black, 1 = White, 2 = Red, 3 = Green, 4 = Blue, 5 = Yellow, 6 = Magenta, 7 = Cyan, 16 = Maroon, 17 = Dark Green, 18 = Dark Blue, 19 = Dark Yellow , almost brown), 20 = Dark Magenta, 21 = Teal, 22 = Light Gray, 23 = Dark Gray, the list goes on...
    # # sheet.col(0).width = 300 #设置某列的单元格宽度
    # print(info)
    p_keys = list(info.keys())
    # print(p_keys)
    # print(type(p_keys))
    # print("p_keys: %s" %p_keys)
    c_keys = []
    for p_key in p_keys:
        c_keys = c_keys + list(info[p_key].keys())
    c_keys = list(set(c_keys))
    # c_keys = list(info[p_keys[0]].keys())
    # print("c_keys: %s" %c_keys)
    # print(len(c_keys))
    for p_key in p_keys:
        for c_key in c_keys:
            if not c_key in info[p_key]:
                info[p_key][c_key] = ""
    primary_type = sheet_name.split("_")[1]
    sheet.write(0, 0, "%s\\lable" % primary_type)
    for i in range(len(p_keys)):
        sheet.write(i + 1, 0, p_keys[i])

    for j in range(len(c_keys)):
        #print(c_keys[j])
        sheet.write(0, j + 1, c_keys[j])

    for i in range(len(p_keys)):
        # c_keys = list(info[p_keys[i]].keys())
        for j in range(len(c_keys)):
            sheet.write(i + 1, j + 1, info[p_keys[i]][c_keys[j]])
    #sheet.write(1,0,'test',style)   #写入带字体样式的内容
    excel.save(excel_file_name)
예제 #9
0
    def addXlsSheet(self, xlsfile, addSheet):
        # open existing workbook
        rb = xlrd.open_workbook(xlsfile, formatting_info=True)
        # make a copy of it
        wb = xl_copy(rb)
        # add sheet to workbook with existing sheets

        Sheet1 = wb.add_sheet(addSheet)
        wb.save(xlsfile)
예제 #10
0
 def get_excel(self):
     # 添加新sheet
     rb = self.open_workbook()
     wb = xl_copy(rb)
     [
         self.add_new_sheet(name, wb) for name in self.sheet_names
         if name not in rb.sheet_names()
     ]
     wb.save(self.base_path)
     return wb
예제 #11
0
def insert_sheet(category, timestamp, value, entity):
    book1 = xlrd.open_workbook('base.xlsx', formatting_info=True)
    #copia formatacao da planilha
    book = xl_copy(book1)
    sheet = get_sheet_by_name(book)
    #insere entidade numa coluna fixa
    setOutCell(sheet, 0, get_entity_index(entity), entity)
    #insere valor
    setOutCell(sheet, timestamp.month, get_entity_index(entity), value)
    fill_sheet_totals(sheet)
    book.save("base.xlsx")
예제 #12
0
파일: app.py 프로젝트: dmarcelinobr/MaxDiff
def makeQuota(n):
    rb = xlrd.open_workbook(quota, formatting_info=True)
    wb = xl_copy(rb)
    sheetName = n + "_Maxdiff"
    # add_sheet is used to create sheet.
    sheet1 = wb.add_sheet(sheetName)
    sheet1.write(0, 0, "#=" + sheetName)
    for x in range(tot):
        sheet1.write(x + 1, 0, 'ver_' + str(x + 1))
        sheet1.write(x + 1, 1, 'inf')
    wb.save(quota)
예제 #13
0
def formast(ADD):
    all_file = os_file.open(self=ADD, all=1)
    try:
        for per_file in all_file:
            if per_file[-4:] == ".xls":
                rb = xlrd.open_workbook(filename=per_file)
                wb = xl_copy(rb)
                wb.save(per_file + "x")
                logging.info(per_file + "--转换成功")
                os.remove(per_file)
    except Exception as e:
        raise e
예제 #14
0
 def write_to_excel(self, file_path, sheet_id, row, col, value):
     """
     写入excel
     """
     work_book = xlrd.open_workbook(file_path, formatting_info=False)
     # 先通过xlutils.copy下copy复制Excel
     write_to_work = xl_copy(work_book)
     # 通过sheet_by_index没有write方法 而get_sheet有write方法
     sheet_data = write_to_work.get_sheet(sheet_id)
     sheet_data.write(row, col, str(value))
     # 这里要注意保存 可是会将原来的Excel覆盖 样式消失
     write_to_work.save(file_path)
예제 #15
0
def add_sheet(os_path,file_name,sheet_name,start_mun,insert_info):
    wb=xlrd.open_workbook(os_path+file_name+".xls")
    work_book = xl_copy(wb)
    sheet=work_book.add_sheet(sheet_name) #sheet名称
    #写入title数据
    for i in range(int(start_mun)-1,len(insert_info[0])):
        sheet.write(0,i,insert_info[0][i])
    #写入数据
        for j in range(int(start_mun),len(insert_info)):
            sheet.write(j,i,insert_info[j][insert_info[0][i]])
    #数据保存到excel   
    work_book.save(os_path+file_name+".xls")
    print("数据写入Excel-{}:sheet-{},执行完成!~".format(file_name,sheet_name))
예제 #16
0
파일: excel.py 프로젝트: bopopescu/TestMgmt
 def add_row_data(self, sheet_name, info_list):
     table_obj = xlrd.open_workbook(self.file_name)
     sheet = table_obj.sheet_by_name(sheet_name)
     nrows = sheet.nrows
     new_wb = xl_copy(table_obj)  # 将原有的Excel,拷贝一个新的副本
     status, sheet_index = self.get_sheet_index(sheet_name)
     if not status:
         return False, sheet_index
     new_sheet = new_wb.get_sheet(sheet_index) # 重新在新的Excel中获取
     for i in range(len(info_list)):
         new_sheet.write(nrows,i,info_list[i])
     new_wb.save(self.file_name)
     return True, 'Add %s Success……' %info_list[0]
예제 #17
0
def output(filename, sheet, list0, list1, list2, list3, list4, list5):
    if os.path.isfile(filename):
        rb = open_workbook(filename, formatting_info=True)
        book = xl_copy(rb)
        sh = book.add_sheet(sheet)

    else:
        book = xlwt.Workbook()
        sh = book.add_sheet(sheet)

    col0_name = 't'
    col1_name = 'Eha(t)'
    col2_name = 'Ehb(t)'
    col3_name = 'Dis_a(t)'
    col4_name = 'Dis_b(t)'
    col5_name = 'Die(t)'
    col6_name = 'Ehe(t)'

    sh.write(0, 0, col0_name)
    sh.write(0, 1, col1_name)
    sh.write(0, 2, col2_name)
    sh.write(0, 3, col3_name)
    sh.write(0, 4, col4_name)
    sh.write(0, 5, col5_name)
    sh.write(0, 6, col6_name)

    for m, e0 in enumerate(list0):
        sh.write(m + 1, 0, e0)

    for m, e1 in enumerate(list1):
        sh.write(m + 1, 1, e1)

    for m, e2 in enumerate(list2):
        sh.write(m + 1, 2, e2)

    for m, e3 in enumerate(list3):
        sh.write(m + 1, 3, e3)

    for m, e4 in enumerate(list4):
        sh.write(m + 1, 4, e4)

    for m, e5 in enumerate(list5):
        sh.write(m + 1, 5, e5)

    for m in range(0, len(list1)):
        sh.write(
            m + 1, 6,
            xlwt.Formula("'" + sheet + "'!B" + str(m + 2) + "+'" + sheet +
                         "'!C" + str(m + 2)))

    book.save(filename)
예제 #18
0
    def clean_file(self, file_path):
        """Clean file using xlrd."""
        result = "Файл очищен!"

        try:
            rb = xlrd.open_workbook(file_path)
        except Exception as e:
            print(e)
            result = "Файл не может быть очищен! :"
            result += str(e)
        else:
            wb = xl_copy(rb)
            wb.save(file_path)
        return result
예제 #19
0
def output(filename, wb, years, NPV, period):
    new_wb = xl_copy(wb)
    sheet1 = new_wb.add_sheet('Results')

    sheet1.write(0, 0, 'Year')
    sheet1.write(0, 1, 'NPV')
    sheet1.write(0, 2, 'Payback')

    for i in range(0, len(years)):
        sheet1.write(i + 1, 0, years[i])
        sheet1.write(i + 1, 1, NPV[i])
        sheet1.write(i + 1, 2, period[i])

    new_wb.save(filename)
예제 #20
0
def csv_to_xlsx():
    with open(csvName, 'r', encoding='utf-8') as f:
        read = csv.reader(f)
        rb = xlrd.open_workbook(workbookPath)
        wb = xl_copy(rb)
        sheet = wb.add_sheet(sheetName)  # 创建一个sheet表格
        l = 0
        for line in read:
            #print(line)
            r = 0
            for i in line:
                # print(i)
                sheet.write(l, r, i)  # 一个一个将单元格数据写入
                r = r + 1
            l = l + 1
        wb.save('PSCloud0830BUG优先级列表.xls')  # 保存Excel
예제 #21
0
def New_Sheet(ADD, sheetname):
    """
    :param add: 地址
    :param sheetname: 工作页的命名
    :return:
    """
    all_file = os_file.open(self=ADD, all=1)
    for per_file in all_file:
        print("分析结果", per_file)

        rb = xlrd.open_workbook(filename=per_file)
        wb = xl_copy(rb)
        wb.add_sheet(sheetname=sheetname)
        wb.save(per_file + "x")

        print('succeed')
예제 #22
0
def get_workbook(file_path):
    """为了向同一个wb对象里添加sheet,
    另一种做法更tricky:打开生成的host_info_xxxx.xls, xlutil.copy 一份,然后往里加入新的sheet
    http://stackoverflow.com/questions/38081658/adding-a-sheet-to-an-existing-excel-worksheet-without-deleting-other-sheet
    这里为了简单,但是会耦合严重。
    """
    if not os.path.exists(file_path):
        # 路径不存在,重新创建一个
        return xlwt.Workbook(encoding="utf-8")
    else:
        try:
            rb = xlrd.open_workbook(file_path, formatting_info=True)
            return xl_copy(rb)
        except Exception as ex:
            # 如果读取失败需要记录
            LOGGER.exception("打开excel文件[%s]失败,尝试重新创建全新的. Exception: %s",
                             file_path, ex)
예제 #23
0
파일: weekly.py 프로젝트: yeleman/snisi
def nutrition_weekly_as_xls(report):
    """ Export les données d'un rapport en xls """

    template_path = os.path.join(get_domain().module_path,
                                 'fixtures', 'template-nutrition-weekly.xls')

    template = open_workbook(template_path, formatting_info=True)
    wb = xl_copy(template)
    sheet = wb.get_sheet(0)
    del(template)

    xls_update_value_only(sheet, 1, 2,
                          report.entity.display_short_health_hierarchy())
    xls_update_value_only(sheet, 1, 4, report.entity.slug)

    xls_update_value_only(sheet, 5, 2, report.period.casted().strid())
    xls_update_value_only(sheet, 5, 4,
                          report.created_by.get_title_full_name())

    xls_update_value_only(sheet, 1, 7, report.urenam_screening)
    xls_update_value_only(sheet, 3, 7, report.urenam_cases)
    xls_update_value_only(sheet, 5, 7, report.urenam_deaths)
    sheet.write(7, 7, xlwt.Formula("SUM(B{r}:F{r})".format(r=8)),
                style_value_sum)

    xls_update_value_only(sheet, 1, 8, report.urenas_screening)
    xls_update_value_only(sheet, 3, 8, report.urenas_cases)
    xls_update_value_only(sheet, 5, 8, report.urenas_deaths)
    sheet.write(8, 7, xlwt.Formula("SUM(B{r}:F{r})".format(r=9)),
                style_value_sum)

    xls_update_value_only(sheet, 1, 9, report.ureni_screening)
    xls_update_value_only(sheet, 3, 9, report.ureni_cases)
    xls_update_value_only(sheet, 5, 9, report.ureni_deaths)
    sheet.write(9, 7, xlwt.Formula("SUM(B{r}:F{r})".format(r=10)),
                style_value_sum)

    sheet.write(10, 1, xlwt.Formula("SUM(B8:C10)"), style_value_sum)
    sheet.write(10, 3, xlwt.Formula("SUM(D8:E10)"), style_value_sum)
    sheet.write(10, 5, xlwt.Formula("SUM(F8:G10)"), style_value_sum)
    sheet.write(10, 7, xlwt.Formula("SUM(H8:I10)"), style_value_sum)

    stream = StringIO.StringIO()
    wb.save(stream)

    return stream
예제 #24
0
def build_waybill():
    ADD = "E:/HUMEI/Excel_shunxu/检测1/"
    ADD_none = r"E:\HUMEI\Excel_shunxu\空表\none.xls"
    ADD_waybill = "E:/HUMEI/Excel_shunxu/顺序模板/waybill_0.xlsx"

    all_file = os_file.open(self=ADD, all=1)
    #print("正在分析", all_file)
    row_waybill = OpenExcel.open_excel_row(ADD_waybill, sheet=0, row=0)
    #print("row_waybill", row_waybill)
    logging.info("生成运单OK")

    p = 0
    for per_file in all_file:

        #print("waybill.py", p, per_file)

        # workbook = xlrd.open_workbook(filename=per_file)
        workbook_none = xlrd.open_workbook(filename=ADD_none)
        wb = xl_copy(workbook_none)
        # wb.add_sheet("waybill")

        try:
            s = wb.get_sheet(0)


        except:
            print("错误:请新建Sheet")

        sheet_0 = OpenExcel.open_excel_sheet(per_file, sheet=0)
        row_1 = OpenExcel.open_excel_row(per_file, sheet=0, row=0)
        #print(row_1)

        for i in range(23):

            a = 0
            for x in RowData.row_name(row_waybill[i], row_1, sheet_0):
                s.write(a, i, x)
                a = a + 1
        new_name = re.findall("/检测1/(.+)_20", per_file)
        #print(new_name)
        nowTime = datetime.datetime.now().strftime('%Y-%m-%d_%H:%M:%S')
        #print(nowTime)
        p = p + 1
        wb.save("E:/HUMEI/Excel_shunxu/检测3/" + "%s waybill_%s.xls" % (new_name[0], p))
        # wb.save("E:/HUMEI/Excel_shunxu/检测3/" + "%s.xls" % new_name)
        wb.save("E:/HUMEI/Excel_shunxu/转发1/" + "%s waybill_%s.xls" % (new_name[0], p))
예제 #25
0
파일: excel.py 프로젝트: bopopescu/TestMgmt
 def write_issue(self, sheet_name, *infos):
     if os.path.exists(self.file_name):
         wb = xlrd.open_workbook(self.file_name)
         excel = xl_copy(wb)
     else:
         excel = xlwt.Workbook(encoding='utf-8')
     sheet = excel.add_sheet(sheet_name)
     item_list = ["版本", "No.", "类型", "名称", "提交人", "解决人", "回归人", "更新时间", "回归结果", "是否ReOpen", "标签"]
     for i in range(len(item_list)):
         sheet.write(0, i, item_list[i])
     for i in range(len(infos)):
         # print("infos[%s]: %s"%(i, infos[i]))
         value_list = [infos[i]['milestone'], infos[i]['issue_id'], infos[i]['issue_type'], infos[i]['name'], infos[i]['author'], infos[i]['assignees'], infos[i]['test'], infos[i]['updated'], infos[i]['result'], infos[i]['reopen'], infos[i]['tag']]
         for j in range(len(value_list)):
             sheet.write(i+1, j, value_list[j])
     excel.save(self.file_name)
     return True
예제 #26
0
    def write_to_excel(self):
        wb = open_workbook("Pricing.xls")
        # Create new wb with same data
        wb_copy = xl_copy(wb)
        # Add new sheet on new wb
        ws = wb_copy.add_sheet(
            self.time.strftime("%m" + "." + "%d" + "." + "%Y"))
        # Starts from (1,0), then shifts down by column, then shifts row
        i = 2
        ws.write(0, 0, self.time.strftime("%X"))
        ws.write(1, 0, "Stock Name")
        ws.write(1, 1, "Stock Price")
        for name, price in zip(self.names, self.prices):
            ws.write(i, 0, name)
            ws.write(i, 1, price)
            i += 1

        wb_copy.save('Pricing.xls')
예제 #27
0
def sss(result):
    rb = xlrd.open_workbook('all.xls', formatting_info=True)
    # make a copy of it
    wb = xl_copy(rb)
    sheet = wb.add_sheet('全家便利店')
    n = 0
    for i in result2:
        sheet.write(n, 0, i)
        n += 1
    n = 0
    for i in result:
        parms = {'cid': i}
        html = requests.post(url, parms)
        info = json.loads(html.text)
        # print(info)
        sheet.write(n, 1, len(info['mapmsg']))
        n += 1

    wb.save('all.xls')
예제 #28
0
파일: excel.py 프로젝트: bopopescu/TestMgmt
 def delete_all_case(self, sheet_name):
     table_obj = xlrd.open_workbook(self.file_name)
     sheet = table_obj.sheet_by_name(sheet_name)
     read_all = self.read_sheet_all_content(sheet_name)
     length = len(read_all)
     if length > 6:
         for i in range(length-1, 5, -1):
             read_all.pop(i)
     status, sheet_index = self.get_sheet_index(sheet_name)
     if not status:
         return False, sheet_index
     new_wb = xl_copy(table_obj)
     new_sheet = new_wb.get_sheet(sheet_index)
     # print("read_all: ", read_all)
     for m in range(len(read_all)):
         for n in range(len(read_all[m])):
             new_sheet.write(m, n, read_all[m][n])
     new_wb.save(self.file_name)
     return True, "Delete Data Success …… "
예제 #29
0
파일: excel.py 프로젝트: bopopescu/TestMgmt
 def write_case(self, sheet_name, *infos):
     if os.path.exists(self.file_name):
         wb = xlrd.open_workbook(self.file_name)
         excel = xl_copy(wb)
     else:
         excel = xlwt.Workbook(encoding='utf-8')
         sheet_sum_up = excel.add_sheet(self.sum_up_sheet)
         items_sum_up = ["模块名称", "用例总数", "未合入/未测试", "PASS数", "FAIL数", "PASS率", "备注"]
         for i in range(len(items_sum_up)):
             sheet_sum_up.write(0, i, items_sum_up[i])
     sheet = excel.add_sheet(sheet_name)
     item_list = ["用例编号", "用例名称", "测试类型", "优先级", "预置条件", "测试范围", "测试步骤",  "预期结果", "自动化", "关联API", "功能开发者", "用例设计者", "测试执行者", "测试日期", "测试结果", "备注"]
     for i in range(len(item_list)):
         sheet.write(0, i, item_list[i])
     for i in range(len(infos)):
         # print("infos[%s]: %s"%(i, infos[i]))
         value_list = [infos[i]['case_number'], infos[i]['case_name'], infos[i]['case_type'], infos[i]['priority'], infos[i]['pre_condition'], infos[i]['test_range'], infos[i]['test_steps'], infos[i]['expect_result'], infos[i]['auto'], str(infos[i]['case_id']), infos[i]['fun_developer'], infos[i]['case_designer'],infos[i]['case_executor'],str(infos[i]['test_time']),infos[i]['test_result'],infos[i]['remark']]
         for j in range(len(value_list)):
             sheet.write(i+1, j, value_list[j])
     excel.save(self.file_name)
     return True
예제 #30
0
def csv_to_xlsx():
    with open(csvName, 'r', encoding='utf-8') as f:
        read = csv.reader(f)
        rb = xlrd.open_workbook(workbookPath)
        if sheetName in rb.sheet_names():
            print('该Sheet名称已存在,请换名字!')
            return False
        else:
            print(rb.sheet_names())
            wb = xl_copy(rb)
            sheet = wb.add_sheet(sheetName)  # 创建一个sheet表格
            l = 0
            for line in read:
                r = 0
                for i in line:
                    sheet.write(l, r, i)  # 一个一个将单元格数据写入
                    r = r + 1
                l = l + 1
            print('CSV转换Excel成功!')
            wb.save(workbookPath)  # 保存Excel
            return True
예제 #31
0
파일: excel.py 프로젝트: bopopescu/TestMgmt
 def modify_excel_row(self, sheet_name, case_info):
     table_obj = xlrd.open_workbook(self.file_name)
     sheet = table_obj.sheet_by_name(sheet_name)
     col_val=sheet.col_values(0)#第一列的值
     count = 0
     for item in col_val:
         if item == case_info[0]:
             row_index = count
             break
         count = count + 1
         if count == len(col_val):
             return False, "Not Fount %s Case, Please Check it ~ " %case_info[0]
     status, sheet_index = self.get_sheet_index(sheet_name)
     if not status:
         return False, sheet_index
     new_wb = xl_copy(table_obj)
     new_sheet = new_wb.get_sheet(sheet_index)
     for i in range(len(case_info)):
         new_sheet.write(row_index, i, case_info[i])
     new_wb.save(self.file_name)
     return True, "Modify %s Success……" %case_info[0]
예제 #32
0
파일: monthly.py 프로젝트: yeleman/snisi
def nutrition_monthly_as_xls(report):
    """ Export les données d'un rapport en xls """

    template_path = os.path.join(get_domain().module_path,
                                 'fixtures', 'template-nutrition.xls')

    template = open_workbook(template_path, formatting_info=True)
    copy_week_b = xl_copy(template)
    sheet_STOCKS = copy_week_b.get_sheet(0)
    sheet_STOCKS.portrait = False
    sheet_URENAMURENAS = copy_week_b.get_sheet(1)
    sheet_URENAMURENAS.portrait = False
    sheet_URENI = copy_week_b.get_sheet(2)
    sheet_URENI.portrait = False
    del(template)

    entity = report.entity.casted()

    meta_map = [
        (sheet_STOCKS, 1, 5),
        (sheet_URENAMURENAS, 5, 14),
        (sheet_URENI, 5, 14),
    ]

    for sheet, colA, colB in meta_map:
        xls_update_value_only(sheet, colB, 2, report.period.middle().month)
        xls_update_value_only(sheet, colB, 3, report.period.middle().year)
        xls_update_value_only(sheet, colA, 3,
                              report.entity.display_short_health_hierarchy())
        xls_update_value_only(sheet, colA, 4, report.entity.slug)
        xls_update_value_only(sheet, colB, 4,
                              report.created_by.get_title_full_name())

    # STOCKS
    xls_update_value_only(sheet_STOCKS, 3, 7,
                          report.stocks_report.plumpy_nut_initial)
    xls_update_value_only(sheet_STOCKS, 5, 7,
                          report.stocks_report.plumpy_nut_received)
    xls_update_value_only(sheet_STOCKS, 7, 7,
                          report.stocks_report.plumpy_nut_used)
    xls_update_value_only(sheet_STOCKS, 9, 7,
                          report.stocks_report.plumpy_nut_lost)
    xls_update_value_only(sheet_STOCKS, 11, 7,
                          report.stocks_report.plumpy_nut_balance)
    xls_update_value_only(sheet_STOCKS, 3, 8,
                          report.stocks_report.milk_f75_initial)
    xls_update_value_only(sheet_STOCKS, 5, 8,
                          report.stocks_report.milk_f75_received)
    xls_update_value_only(sheet_STOCKS, 7, 8,
                          report.stocks_report.milk_f75_used)
    xls_update_value_only(sheet_STOCKS, 9, 8,
                          report.stocks_report.milk_f75_lost)
    xls_update_value_only(sheet_STOCKS, 11, 8,
                          report.stocks_report.milk_f75_balance)
    xls_update_value_only(sheet_STOCKS, 3, 9,
                          report.stocks_report.milk_f100_initial)
    xls_update_value_only(sheet_STOCKS, 5, 9,
                          report.stocks_report.milk_f100_received)
    xls_update_value_only(sheet_STOCKS, 7, 9,
                          report.stocks_report.milk_f100_used)
    xls_update_value_only(sheet_STOCKS, 9, 9,
                          report.stocks_report.milk_f100_lost)
    xls_update_value_only(sheet_STOCKS, 11, 9,
                          report.stocks_report.milk_f100_balance)
    xls_update_value_only(sheet_STOCKS, 3, 10,
                          report.stocks_report.resomal_initial)
    xls_update_value_only(sheet_STOCKS, 5, 10,
                          report.stocks_report.resomal_received)
    xls_update_value_only(sheet_STOCKS, 7, 10,
                          report.stocks_report.resomal_used)
    xls_update_value_only(sheet_STOCKS, 9, 10,
                          report.stocks_report.resomal_lost)
    xls_update_value_only(sheet_STOCKS, 11, 10,
                          report.stocks_report.resomal_balance)
    xls_update_value_only(sheet_STOCKS, 3, 11,
                          report.stocks_report.plumpy_sup_initial)
    xls_update_value_only(sheet_STOCKS, 5, 11,
                          report.stocks_report.plumpy_sup_received)
    xls_update_value_only(sheet_STOCKS, 7, 11,
                          report.stocks_report.plumpy_sup_used)
    xls_update_value_only(sheet_STOCKS, 9, 11,
                          report.stocks_report.plumpy_sup_lost)
    xls_update_value_only(sheet_STOCKS, 11, 11,
                          report.stocks_report.plumpy_sup_balance)
    xls_update_value_only(sheet_STOCKS, 3, 12,
                          report.stocks_report.supercereal_initial)
    xls_update_value_only(sheet_STOCKS, 5, 12,
                          report.stocks_report.supercereal_received)
    xls_update_value_only(sheet_STOCKS, 7, 12,
                          report.stocks_report.supercereal_used)
    xls_update_value_only(sheet_STOCKS, 9, 12,
                          report.stocks_report.supercereal_lost)
    xls_update_value_only(sheet_STOCKS, 11, 12,
                          report.stocks_report.supercereal_balance)
    xls_update_value_only(sheet_STOCKS, 3, 13,
                          report.stocks_report.supercereal_plus_initial)
    xls_update_value_only(sheet_STOCKS, 5, 13,
                          report.stocks_report.supercereal_plus_received)
    xls_update_value_only(sheet_STOCKS, 7, 13,
                          report.stocks_report.supercereal_plus_used)
    xls_update_value_only(sheet_STOCKS, 9, 13,
                          report.stocks_report.supercereal_plus_lost)
    xls_update_value_only(sheet_STOCKS, 11, 13,
                          report.stocks_report.supercereal_plus_balance)
    xls_update_value_only(sheet_STOCKS, 3, 14,
                          report.stocks_report.oil_initial)
    xls_update_value_only(sheet_STOCKS, 5, 14,
                          report.stocks_report.oil_received)
    xls_update_value_only(sheet_STOCKS, 7, 14,
                          report.stocks_report.oil_used)
    xls_update_value_only(sheet_STOCKS, 9, 14,
                          report.stocks_report.oil_lost)
    xls_update_value_only(sheet_STOCKS, 11, 14,
                          report.stocks_report.oil_balance)
    xls_update_value_only(sheet_STOCKS, 3, 15,
                          report.stocks_report.amoxycilline_125_vials_initial)
    xls_update_value_only(sheet_STOCKS, 5, 15,
                          report.stocks_report.amoxycilline_125_vials_received)
    xls_update_value_only(sheet_STOCKS, 7, 15,
                          report.stocks_report.amoxycilline_125_vials_used)
    xls_update_value_only(sheet_STOCKS, 9, 15,
                          report.stocks_report.amoxycilline_125_vials_lost)
    xls_update_value_only(sheet_STOCKS, 11, 15,
                          report.stocks_report.amoxycilline_125_vials_balance)
    xls_update_value_only(sheet_STOCKS, 3, 16,
                          report.stocks_report.amoxycilline_250_caps_initial)
    xls_update_value_only(sheet_STOCKS, 5, 16,
                          report.stocks_report.amoxycilline_250_caps_received)
    xls_update_value_only(sheet_STOCKS, 7, 16,
                          report.stocks_report.amoxycilline_250_caps_used)
    xls_update_value_only(sheet_STOCKS, 9, 16,
                          report.stocks_report.amoxycilline_250_caps_lost)
    xls_update_value_only(sheet_STOCKS, 11, 16,
                          report.stocks_report.amoxycilline_250_caps_balance)
    xls_update_value_only(sheet_STOCKS, 3, 17,
                          report.stocks_report.albendazole_400_initial)
    xls_update_value_only(sheet_STOCKS, 5, 17,
                          report.stocks_report.albendazole_400_received)
    xls_update_value_only(sheet_STOCKS, 7, 17,
                          report.stocks_report.albendazole_400_used)
    xls_update_value_only(sheet_STOCKS, 9, 17,
                          report.stocks_report.albendazole_400_lost)
    xls_update_value_only(sheet_STOCKS, 11, 17,
                          report.stocks_report.albendazole_400_balance)
    xls_update_value_only(sheet_STOCKS, 3, 18,
                          report.stocks_report.vita_100_injectable_initial)
    xls_update_value_only(sheet_STOCKS, 5, 18,
                          report.stocks_report.vita_100_injectable_received)
    xls_update_value_only(sheet_STOCKS, 7, 18,
                          report.stocks_report.vita_100_injectable_used)
    xls_update_value_only(sheet_STOCKS, 9, 18,
                          report.stocks_report.vita_100_injectable_lost)
    xls_update_value_only(sheet_STOCKS, 11, 18,
                          report.stocks_report.vita_100_injectable_balance)
    xls_update_value_only(sheet_STOCKS, 3, 19,
                          report.stocks_report.vita_200_injectable_initial)
    xls_update_value_only(sheet_STOCKS, 5, 19,
                          report.stocks_report.vita_200_injectable_received)
    xls_update_value_only(sheet_STOCKS, 7, 19,
                          report.stocks_report.vita_200_injectable_used)
    xls_update_value_only(sheet_STOCKS, 9, 19,
                          report.stocks_report.vita_200_injectable_lost)
    xls_update_value_only(sheet_STOCKS, 11, 19,
                          report.stocks_report.vita_200_injectable_balance)
    xls_update_value_only(sheet_STOCKS, 3, 20,
                          report.stocks_report.iron_folic_acid_initial)
    xls_update_value_only(sheet_STOCKS, 5, 20,
                          report.stocks_report.iron_folic_acid_received)
    xls_update_value_only(sheet_STOCKS, 7, 20,
                          report.stocks_report.iron_folic_acid_used)
    xls_update_value_only(sheet_STOCKS, 9, 20,
                          report.stocks_report.iron_folic_acid_lost)
    xls_update_value_only(sheet_STOCKS, 11, 20,
                          report.stocks_report.iron_folic_acid_balance)

    # URENAM
    if report.urenam_report:
        xls_update_value_only(sheet_URENAMURENAS, 1, 14,
                              report.urenam_report.u23o6_total_start)
        xls_update_value_only(sheet_URENAMURENAS, 2, 14,
                              report.urenam_report.u23o6_total_start_m)
        xls_update_value_only(sheet_URENAMURENAS, 3, 14,
                              report.urenam_report.u23o6_total_start_f)
        xls_update_value_only(sheet_URENAMURENAS, 4, 14,
                              report.urenam_report.u23o6_new_cases)
        xls_update_value_only(sheet_URENAMURENAS, 7, 14,
                              report.urenam_report.u23o6_returned)
        xls_update_value_only(sheet_URENAMURENAS, 10, 14,
                              report.urenam_report.u23o6_total_in)
        xls_update_value_only(sheet_URENAMURENAS, 11, 14,
                              report.urenam_report.u23o6_total_in_m)
        xls_update_value_only(sheet_URENAMURENAS, 12, 14,
                              report.urenam_report.u23o6_total_in_f)
        xls_update_value_only(sheet_URENAMURENAS, 14, 14,
                              report.urenam_report.u23o6_grand_total_in)
        xls_update_value_only(sheet_URENAMURENAS, 1, 29,
                              report.urenam_report.u23o6_healed)
        xls_update_value_only(sheet_URENAMURENAS, 3, 29,
                              report.urenam_report.u23o6_deceased)
        xls_update_value_only(sheet_URENAMURENAS, 5, 29,
                              report.urenam_report.u23o6_abandon)
        xls_update_value_only(sheet_URENAMURENAS, 7, 29,
                              report.urenam_report.u23o6_not_responding)
        xls_update_value_only(sheet_URENAMURENAS, 8, 29,
                              report.urenam_report.u23o6_total_out)
        xls_update_value_only(sheet_URENAMURENAS, 10, 29,
                              report.urenam_report.u23o6_total_out_m)
        xls_update_value_only(sheet_URENAMURENAS, 11, 29,
                              report.urenam_report.u23o6_total_out_f)
        xls_update_value_only(sheet_URENAMURENAS, 12, 29,
                              report.urenam_report.u23o6_referred)
        xls_update_value_only(sheet_URENAMURENAS, 14, 29,
                              report.urenam_report.u23o6_grand_total_out)
        xls_update_value_only(sheet_URENAMURENAS, 15, 29,
                              report.urenam_report.u23o6_total_end)
        xls_update_value_only(sheet_URENAMURENAS, 14, 29,
                              report.urenam_report.u23o6_grand_total_out)
        xls_update_value_only(sheet_URENAMURENAS, 16, 29,
                              report.urenam_report.u23o6_total_end_m)
        xls_update_value_only(sheet_URENAMURENAS, 14, 29,
                              report.urenam_report.u23o6_grand_total_out)
        xls_update_value_only(sheet_URENAMURENAS, 17, 29,
                              report.urenam_report.u23o6_total_end_f)
        xls_update_value_only(sheet_URENAMURENAS, 1, 15,
                              report.urenam_report.u59o23_total_start)
        xls_update_value_only(sheet_URENAMURENAS, 2, 15,
                              report.urenam_report.u59o23_total_start_m)
        xls_update_value_only(sheet_URENAMURENAS, 3, 15,
                              report.urenam_report.u59o23_total_start_f)
        xls_update_value_only(sheet_URENAMURENAS, 4, 15,
                              report.urenam_report.u59o23_new_cases)
        xls_update_value_only(sheet_URENAMURENAS, 7, 15,
                              report.urenam_report.u59o23_returned)
        xls_update_value_only(sheet_URENAMURENAS, 10, 15,
                              report.urenam_report.u59o23_total_in)
        xls_update_value_only(sheet_URENAMURENAS, 11, 15,
                              report.urenam_report.u59o23_total_in_m)
        xls_update_value_only(sheet_URENAMURENAS, 12, 15,
                              report.urenam_report.u59o23_total_in_f)
        xls_update_value_only(sheet_URENAMURENAS, 14, 15,
                              report.urenam_report.u59o23_grand_total_in)
        xls_update_value_only(sheet_URENAMURENAS, 1, 30,
                              report.urenam_report.u59o23_healed)
        xls_update_value_only(sheet_URENAMURENAS, 3, 30,
                              report.urenam_report.u59o23_deceased)
        xls_update_value_only(sheet_URENAMURENAS, 5, 30,
                              report.urenam_report.u59o23_abandon)
        xls_update_value_only(sheet_URENAMURENAS, 7, 30,
                              report.urenam_report.u59o23_not_responding)
        xls_update_value_only(sheet_URENAMURENAS, 8, 30,
                              report.urenam_report.u59o23_total_out)
        xls_update_value_only(sheet_URENAMURENAS, 10, 30,
                              report.urenam_report.u59o23_total_out_m)
        xls_update_value_only(sheet_URENAMURENAS, 11, 30,
                              report.urenam_report.u59o23_total_out_f)
        xls_update_value_only(sheet_URENAMURENAS, 12, 30,
                              report.urenam_report.u59o23_referred)
        xls_update_value_only(sheet_URENAMURENAS, 14, 30,
                              report.urenam_report.u59o23_grand_total_out)
        xls_update_value_only(sheet_URENAMURENAS, 15, 30,
                              report.urenam_report.u59o23_total_end)
        xls_update_value_only(sheet_URENAMURENAS, 14, 30,
                              report.urenam_report.u59o23_grand_total_out)
        xls_update_value_only(sheet_URENAMURENAS, 16, 30,
                              report.urenam_report.u59o23_total_end_m)
        xls_update_value_only(sheet_URENAMURENAS, 14, 30,
                              report.urenam_report.u59o23_grand_total_out)
        xls_update_value_only(sheet_URENAMURENAS, 17, 30,
                              report.urenam_report.u59o23_total_end_f)
        xls_update_value_only(sheet_URENAMURENAS, 1, 16,
                              report.urenam_report.o59_total_start)
        xls_update_value_only(sheet_URENAMURENAS, 2, 16,
                              report.urenam_report.o59_total_start_m)
        xls_update_value_only(sheet_URENAMURENAS, 3, 16,
                              report.urenam_report.o59_total_start_f)
        xls_update_value_only(sheet_URENAMURENAS, 4, 16,
                              report.urenam_report.o59_new_cases)
        xls_update_value_only(sheet_URENAMURENAS, 7, 16,
                              report.urenam_report.o59_returned)
        xls_update_value_only(sheet_URENAMURENAS, 10, 16,
                              report.urenam_report.o59_total_in)
        xls_update_value_only(sheet_URENAMURENAS, 11, 16,
                              report.urenam_report.o59_total_in_m)
        xls_update_value_only(sheet_URENAMURENAS, 12, 16,
                              report.urenam_report.o59_total_in_f)
        xls_update_value_only(sheet_URENAMURENAS, 14, 16,
                              report.urenam_report.o59_grand_total_in)
        xls_update_value_only(sheet_URENAMURENAS, 1, 31,
                              report.urenam_report.o59_healed)
        xls_update_value_only(sheet_URENAMURENAS, 3, 31,
                              report.urenam_report.o59_deceased)
        xls_update_value_only(sheet_URENAMURENAS, 5, 31,
                              report.urenam_report.o59_abandon)
        xls_update_value_only(sheet_URENAMURENAS, 7, 31,
                              report.urenam_report.o59_not_responding)
        xls_update_value_only(sheet_URENAMURENAS, 8, 31,
                              report.urenam_report.o59_total_out)
        xls_update_value_only(sheet_URENAMURENAS, 10, 31,
                              report.urenam_report.o59_total_out_m)
        xls_update_value_only(sheet_URENAMURENAS, 11, 31,
                              report.urenam_report.o59_total_out_f)
        xls_update_value_only(sheet_URENAMURENAS, 12, 31,
                              report.urenam_report.o59_referred)
        xls_update_value_only(sheet_URENAMURENAS, 14, 31,
                              report.urenam_report.o59_grand_total_out)
        xls_update_value_only(sheet_URENAMURENAS, 15, 31,
                              report.urenam_report.o59_total_end)
        xls_update_value_only(sheet_URENAMURENAS, 14, 31,
                              report.urenam_report.o59_grand_total_out)
        xls_update_value_only(sheet_URENAMURENAS, 16, 31,
                              report.urenam_report.o59_total_end_m)
        xls_update_value_only(sheet_URENAMURENAS, 14, 31,
                              report.urenam_report.o59_grand_total_out)
        xls_update_value_only(sheet_URENAMURENAS, 17, 31,
                              report.urenam_report.o59_total_end_f)
        xls_update_value_only(sheet_URENAMURENAS, 1, 17,
                              report.urenam_report.pw_total_start)
        xls_update_value_only(sheet_URENAMURENAS, 3, 17,
                              report.urenam_report.pw_total_start_f)
        xls_update_value_only(sheet_URENAMURENAS, 4, 17,
                              report.urenam_report.pw_new_cases)
        xls_update_value_only(sheet_URENAMURENAS, 7, 17,
                              report.urenam_report.pw_returned)
        xls_update_value_only(sheet_URENAMURENAS, 10, 17,
                              report.urenam_report.pw_total_in)
        xls_update_value_only(sheet_URENAMURENAS, 12, 17,
                              report.urenam_report.pw_total_in_f)
        xls_update_value_only(sheet_URENAMURENAS, 14, 17,
                              report.urenam_report.pw_grand_total_in)
        xls_update_value_only(sheet_URENAMURENAS, 1, 32,
                              report.urenam_report.pw_healed)
        xls_update_value_only(sheet_URENAMURENAS, 3, 32,
                              report.urenam_report.pw_deceased)
        xls_update_value_only(sheet_URENAMURENAS, 5, 32,
                              report.urenam_report.pw_abandon)
        xls_update_value_only(sheet_URENAMURENAS, 7, 32,
                              report.urenam_report.pw_not_responding)
        xls_update_value_only(sheet_URENAMURENAS, 8, 32,
                              report.urenam_report.pw_total_out)
        xls_update_value_only(sheet_URENAMURENAS, 11, 32,
                              report.urenam_report.pw_total_out_f)
        xls_update_value_only(sheet_URENAMURENAS, 12, 32,
                              report.urenam_report.pw_referred)
        xls_update_value_only(sheet_URENAMURENAS, 14, 32,
                              report.urenam_report.pw_grand_total_out)
        xls_update_value_only(sheet_URENAMURENAS, 15, 32,
                              report.urenam_report.pw_total_end)
        xls_update_value_only(sheet_URENAMURENAS, 14, 32,
                              report.urenam_report.pw_grand_total_out)
        xls_update_value_only(sheet_URENAMURENAS, 17, 32,
                              report.urenam_report.pw_total_end_f)
        xls_update_value_only(sheet_URENAMURENAS, 1, 18,
                              report.urenam_report.exsam_total_start)
        xls_update_value_only(sheet_URENAMURENAS, 2, 18,
                              report.urenam_report.exsam_total_start_m)
        xls_update_value_only(sheet_URENAMURENAS, 3, 18,
                              report.urenam_report.exsam_total_start_f)
        xls_update_value_only(sheet_URENAMURENAS, 14, 18,
                              report.urenam_report.exsam_grand_total_in)
        xls_update_value_only(sheet_URENAMURENAS, 12, 33,
                              report.urenam_report.exsam_referred)
        xls_update_value_only(sheet_URENAMURENAS, 14, 33,
                              report.urenam_report.exsam_grand_total_out)
        xls_update_value_only(sheet_URENAMURENAS, 15, 33,
                              report.urenam_report.exsam_total_end)
        xls_update_value_only(sheet_URENAMURENAS, 14, 33,
                              report.urenam_report.exsam_grand_total_out)
        xls_update_value_only(sheet_URENAMURENAS, 16, 33,
                              report.urenam_report.exsam_total_end_m)
        xls_update_value_only(sheet_URENAMURENAS, 14, 33,
                              report.urenam_report.exsam_grand_total_out)
        xls_update_value_only(sheet_URENAMURENAS, 17, 33,
                              report.urenam_report.exsam_total_end_f)
        #####
        xls_update_value_only(sheet_URENAMURENAS, 1, 19,
                              report.urenam_report.total_start)
        xls_update_value_only(sheet_URENAMURENAS, 2, 19,
                              report.urenam_report.total_start_m)
        xls_update_value_only(sheet_URENAMURENAS, 3, 19,
                              report.urenam_report.total_start_f)
        xls_update_value_only(sheet_URENAMURENAS, 4, 19,
                              report.urenam_report.new_cases)
        xls_update_value_only(sheet_URENAMURENAS, 7, 19,
                              report.urenam_report.returned)
        xls_update_value_only(sheet_URENAMURENAS, 10, 19,
                              report.urenam_report.total_in)
        xls_update_value_only(sheet_URENAMURENAS, 11, 19,
                              report.urenam_report.total_in_m)
        xls_update_value_only(sheet_URENAMURENAS, 12, 19,
                              report.urenam_report.total_in_f)
        xls_update_value_only(sheet_URENAMURENAS, 14, 19,
                              report.urenam_report.grand_total_in)
        xls_update_value_only(sheet_URENAMURENAS, 1, 34,
                              report.urenam_report.healed)
        xls_update_value_only(sheet_URENAMURENAS, 3, 34,
                              report.urenam_report.deceased)
        xls_update_value_only(sheet_URENAMURENAS, 5, 34,
                              report.urenam_report.abandon)
        xls_update_value_only(sheet_URENAMURENAS, 7, 34,
                              report.urenam_report.not_responding)
        xls_update_value_only(sheet_URENAMURENAS, 8, 34,
                              report.urenam_report.total_out)
        xls_update_value_only(sheet_URENAMURENAS, 10, 34,
                              report.urenam_report.total_out_m)
        xls_update_value_only(sheet_URENAMURENAS, 11, 34,
                              report.urenam_report.total_out_f)
        xls_update_value_only(sheet_URENAMURENAS, 12, 34,
                              report.urenam_report.referred)
        xls_update_value_only(sheet_URENAMURENAS, 14, 34,
                              report.urenam_report.grand_total_out)
        xls_update_value_only(sheet_URENAMURENAS, 15, 34,
                              report.urenam_report.total_end)
        xls_update_value_only(sheet_URENAMURENAS, 14, 34,
                              report.urenam_report.grand_total_out)
        xls_update_value_only(sheet_URENAMURENAS, 16, 34,
                              report.urenam_report.total_end_m)
        xls_update_value_only(sheet_URENAMURENAS, 14, 34,
                              report.urenam_report.grand_total_out)
        xls_update_value_only(sheet_URENAMURENAS, 17, 34,
                              report.urenam_report.total_end_f)

    # URENAS
    if report.urenas_report:
        xls_update_value_only(sheet_URENAMURENAS, 1, 10,
                              report.urenas_report.u59o6_total_start)
        xls_update_value_only(sheet_URENAMURENAS, 2, 10,
                              report.urenas_report.u59o6_total_start_m)
        xls_update_value_only(sheet_URENAMURENAS, 3, 10,
                              report.urenas_report.u59o6_total_start_f)
        xls_update_value_only(sheet_URENAMURENAS, 4, 10,
                              report.urenas_report.u59o6_new_cases)
        xls_update_value_only(sheet_URENAMURENAS, 7, 10,
                              report.urenas_report.u59o6_returned)
        xls_update_value_only(sheet_URENAMURENAS, 10, 10,
                              report.urenas_report.u59o6_total_in)
        xls_update_value_only(sheet_URENAMURENAS, 11, 10,
                              report.urenas_report.u59o6_total_in_m)
        xls_update_value_only(sheet_URENAMURENAS, 12, 10,
                              report.urenas_report.u59o6_total_in_f)
        xls_update_value_only(sheet_URENAMURENAS, 13, 10,
                              report.urenas_report.u59o6_transferred)
        xls_update_value_only(sheet_URENAMURENAS, 14, 10,
                              report.urenas_report.u59o6_grand_total_in)
        xls_update_value_only(sheet_URENAMURENAS, 1, 25,
                              report.urenas_report.u59o6_healed)
        xls_update_value_only(sheet_URENAMURENAS, 3, 25,
                              report.urenas_report.u59o6_deceased)
        xls_update_value_only(sheet_URENAMURENAS, 5, 25,
                              report.urenas_report.u59o6_abandon)
        xls_update_value_only(sheet_URENAMURENAS, 7, 25,
                              report.urenas_report.u59o6_not_responding)
        xls_update_value_only(sheet_URENAMURENAS, 8, 25,
                              report.urenas_report.u59o6_total_out)
        xls_update_value_only(sheet_URENAMURENAS, 10, 25,
                              report.urenas_report.u59o6_total_out_m)
        xls_update_value_only(sheet_URENAMURENAS, 11, 25,
                              report.urenas_report.u59o6_total_out_f)
        xls_update_value_only(sheet_URENAMURENAS, 12, 25,
                              report.urenas_report.u59o6_referred)
        xls_update_value_only(sheet_URENAMURENAS, 14, 25,
                              report.urenas_report.u59o6_grand_total_out)
        xls_update_value_only(sheet_URENAMURENAS, 15, 25,
                              report.urenas_report.u59o6_total_end)
        xls_update_value_only(sheet_URENAMURENAS, 14, 25,
                              report.urenas_report.u59o6_grand_total_out)
        xls_update_value_only(sheet_URENAMURENAS, 16, 25,
                              report.urenas_report.u59o6_total_end_m)
        xls_update_value_only(sheet_URENAMURENAS, 14, 25,
                              report.urenas_report.u59o6_grand_total_out)
        xls_update_value_only(sheet_URENAMURENAS, 17, 25,
                              report.urenas_report.u59o6_total_end_f)
        xls_update_value_only(sheet_URENAMURENAS, 1, 11,
                              report.urenas_report.o59_total_start)
        xls_update_value_only(sheet_URENAMURENAS, 2, 11,
                              report.urenas_report.o59_total_start_m)
        xls_update_value_only(sheet_URENAMURENAS, 3, 11,
                              report.urenas_report.o59_total_start_f)
        xls_update_value_only(sheet_URENAMURENAS, 4, 11,
                              report.urenas_report.o59_new_cases)
        xls_update_value_only(sheet_URENAMURENAS, 7, 11,
                              report.urenas_report.o59_returned)
        xls_update_value_only(sheet_URENAMURENAS, 10, 11,
                              report.urenas_report.o59_total_in)
        xls_update_value_only(sheet_URENAMURENAS, 11, 11,
                              report.urenas_report.o59_total_in_m)
        xls_update_value_only(sheet_URENAMURENAS, 12, 11,
                              report.urenas_report.o59_total_in_f)
        xls_update_value_only(sheet_URENAMURENAS, 13, 11,
                              report.urenas_report.o59_transferred)
        xls_update_value_only(sheet_URENAMURENAS, 14, 11,
                              report.urenas_report.o59_grand_total_in)
        xls_update_value_only(sheet_URENAMURENAS, 1, 26,
                              report.urenas_report.o59_healed)
        xls_update_value_only(sheet_URENAMURENAS, 3, 26,
                              report.urenas_report.o59_deceased)
        xls_update_value_only(sheet_URENAMURENAS, 5, 26,
                              report.urenas_report.o59_abandon)
        xls_update_value_only(sheet_URENAMURENAS, 7, 26,
                              report.urenas_report.o59_not_responding)
        xls_update_value_only(sheet_URENAMURENAS, 8, 26,
                              report.urenas_report.o59_total_out)
        xls_update_value_only(sheet_URENAMURENAS, 10, 26,
                              report.urenas_report.o59_total_out_m)
        xls_update_value_only(sheet_URENAMURENAS, 11, 26,
                              report.urenas_report.o59_total_out_f)
        xls_update_value_only(sheet_URENAMURENAS, 12, 26,
                              report.urenas_report.o59_referred)
        xls_update_value_only(sheet_URENAMURENAS, 14, 26,
                              report.urenas_report.o59_grand_total_out)
        xls_update_value_only(sheet_URENAMURENAS, 15, 26,
                              report.urenas_report.o59_total_end)
        xls_update_value_only(sheet_URENAMURENAS, 14, 26,
                              report.urenas_report.o59_grand_total_out)
        xls_update_value_only(sheet_URENAMURENAS, 16, 26,
                              report.urenas_report.o59_total_end_m)
        xls_update_value_only(sheet_URENAMURENAS, 14, 26,
                              report.urenas_report.o59_grand_total_out)
        xls_update_value_only(sheet_URENAMURENAS, 17, 26,
                              report.urenas_report.o59_total_end_f)
        xls_update_value_only(sheet_URENAMURENAS, 1, 12,
                              report.urenas_report.total_start)
        xls_update_value_only(sheet_URENAMURENAS, 2, 12,
                              report.urenas_report.total_start_m)
        xls_update_value_only(sheet_URENAMURENAS, 3, 12,
                              report.urenas_report.total_start_f)
        xls_update_value_only(sheet_URENAMURENAS, 4, 12,
                              report.urenas_report.new_cases)
        xls_update_value_only(sheet_URENAMURENAS, 7, 12,
                              report.urenas_report.returned)
        xls_update_value_only(sheet_URENAMURENAS, 10, 12,
                              report.urenas_report.total_in)
        xls_update_value_only(sheet_URENAMURENAS, 11, 12,
                              report.urenas_report.total_in_m)
        xls_update_value_only(sheet_URENAMURENAS, 12, 12,
                              report.urenas_report.total_in_f)
        xls_update_value_only(sheet_URENAMURENAS, 14, 12,
                              report.urenas_report.grand_total_in)
        xls_update_value_only(sheet_URENAMURENAS, 1, 27,
                              report.urenas_report.healed)
        xls_update_value_only(sheet_URENAMURENAS, 3, 27,
                              report.urenas_report.deceased)
        xls_update_value_only(sheet_URENAMURENAS, 5, 27,
                              report.urenas_report.abandon)
        xls_update_value_only(sheet_URENAMURENAS, 7, 27,
                              report.urenas_report.not_responding)
        xls_update_value_only(sheet_URENAMURENAS, 8, 27,
                              report.urenas_report.total_out)
        xls_update_value_only(sheet_URENAMURENAS, 10, 27,
                              report.urenas_report.total_out_m)
        xls_update_value_only(sheet_URENAMURENAS, 11, 27,
                              report.urenas_report.total_out_f)
        xls_update_value_only(sheet_URENAMURENAS, 12, 27,
                              report.urenas_report.referred)
        xls_update_value_only(sheet_URENAMURENAS, 14, 27,
                              report.urenas_report.grand_total_out)
        xls_update_value_only(sheet_URENAMURENAS, 15, 27,
                              report.urenas_report.total_end)
        xls_update_value_only(sheet_URENAMURENAS, 14, 27,
                              report.urenas_report.grand_total_out)
        xls_update_value_only(sheet_URENAMURENAS, 16, 27,
                              report.urenas_report.total_end_m)
        xls_update_value_only(sheet_URENAMURENAS, 14, 27,
                              report.urenas_report.grand_total_out)
        xls_update_value_only(sheet_URENAMURENAS, 17, 27,
                              report.urenas_report.total_end_f)

    # URENI
    if report.ureni_report:
        xls_update_value_only(sheet_URENI, 1, 10,
                              report.ureni_report.u6_total_start)
        xls_update_value_only(sheet_URENI, 2, 10,
                              report.ureni_report.u6_total_start_m)
        xls_update_value_only(sheet_URENI, 3, 10,
                              report.ureni_report.u6_total_start_f)
        xls_update_value_only(sheet_URENI, 4, 10,
                              report.ureni_report.u6_new_cases)
        xls_update_value_only(sheet_URENI, 7, 10,
                              report.ureni_report.u6_returned)
        xls_update_value_only(sheet_URENI, 10, 10,
                              report.ureni_report.u6_total_in)
        xls_update_value_only(sheet_URENI, 11, 10,
                              report.ureni_report.u6_total_in_m)
        xls_update_value_only(sheet_URENI, 12, 10,
                              report.ureni_report.u6_total_in_f)
        xls_update_value_only(sheet_URENI, 13, 10,
                              report.ureni_report.u6_transferred)
        xls_update_value_only(sheet_URENI, 14, 10,
                              report.ureni_report.u6_grand_total_in)
        xls_update_value_only(sheet_URENI, 1, 19,
                              report.ureni_report.u6_healed)
        xls_update_value_only(sheet_URENI, 3, 19,
                              report.ureni_report.u6_deceased)
        xls_update_value_only(sheet_URENI, 5, 19,
                              report.ureni_report.u6_abandon)
        xls_update_value_only(sheet_URENI, 7, 19,
                              report.ureni_report.u6_not_responding)
        xls_update_value_only(sheet_URENI, 8, 19,
                              report.ureni_report.u6_total_out)
        xls_update_value_only(sheet_URENI, 10, 19,
                              report.ureni_report.u6_total_out_m)
        xls_update_value_only(sheet_URENI, 11, 19,
                              report.ureni_report.u6_total_out_f)
        xls_update_value_only(sheet_URENI, 12, 19,
                              report.ureni_report.u6_referred)
        xls_update_value_only(sheet_URENI, 14, 19,
                              report.ureni_report.u6_grand_total_out)
        xls_update_value_only(sheet_URENI, 15, 19,
                              report.ureni_report.u6_total_end)
        xls_update_value_only(sheet_URENI, 14, 19,
                              report.ureni_report.u6_grand_total_out)
        xls_update_value_only(sheet_URENI, 16, 19,
                              report.ureni_report.u6_total_end_m)
        xls_update_value_only(sheet_URENI, 14, 19,
                              report.ureni_report.u6_grand_total_out)
        xls_update_value_only(sheet_URENI, 17, 19,
                              report.ureni_report.u6_total_end_f)
        xls_update_value_only(sheet_URENI, 1, 11,
                              report.ureni_report.u59o6_total_start)
        xls_update_value_only(sheet_URENI, 2, 11,
                              report.ureni_report.u59o6_total_start_m)
        xls_update_value_only(sheet_URENI, 3, 11,
                              report.ureni_report.u59o6_total_start_f)
        xls_update_value_only(sheet_URENI, 4, 11,
                              report.ureni_report.u59o6_new_cases)
        xls_update_value_only(sheet_URENI, 7, 11,
                              report.ureni_report.u59o6_returned)
        xls_update_value_only(sheet_URENI, 10, 11,
                              report.ureni_report.u59o6_total_in)
        xls_update_value_only(sheet_URENI, 11, 11,
                              report.ureni_report.u59o6_total_in_m)
        xls_update_value_only(sheet_URENI, 12, 11,
                              report.ureni_report.u59o6_total_in_f)
        xls_update_value_only(sheet_URENI, 13, 11,
                              report.ureni_report.u59o6_transferred)
        xls_update_value_only(sheet_URENI, 14, 11,
                              report.ureni_report.u59o6_grand_total_in)
        xls_update_value_only(sheet_URENI, 1, 20,
                              report.ureni_report.u59o6_healed)
        xls_update_value_only(sheet_URENI, 3, 20,
                              report.ureni_report.u59o6_deceased)
        xls_update_value_only(sheet_URENI, 5, 20,
                              report.ureni_report.u59o6_abandon)
        xls_update_value_only(sheet_URENI, 7, 20,
                              report.ureni_report.u59o6_not_responding)
        xls_update_value_only(sheet_URENI, 8, 20,
                              report.ureni_report.u59o6_total_out)
        xls_update_value_only(sheet_URENI, 10, 20,
                              report.ureni_report.u59o6_total_out_m)
        xls_update_value_only(sheet_URENI, 11, 20,
                              report.ureni_report.u59o6_total_out_f)
        xls_update_value_only(sheet_URENI, 12, 20,
                              report.ureni_report.u59o6_referred)
        xls_update_value_only(sheet_URENI, 14, 20,
                              report.ureni_report.u59o6_grand_total_out)
        xls_update_value_only(sheet_URENI, 15, 20,
                              report.ureni_report.u59o6_total_end)
        xls_update_value_only(sheet_URENI, 14, 20,
                              report.ureni_report.u59o6_grand_total_out)
        xls_update_value_only(sheet_URENI, 16, 20,
                              report.ureni_report.u59o6_total_end_m)
        xls_update_value_only(sheet_URENI, 14, 20,
                              report.ureni_report.u59o6_grand_total_out)
        xls_update_value_only(sheet_URENI, 17, 20,
                              report.ureni_report.u59o6_total_end_f)
        xls_update_value_only(sheet_URENI, 1, 12,
                              report.ureni_report.o59_total_start)
        xls_update_value_only(sheet_URENI, 2, 12,
                              report.ureni_report.o59_total_start_m)
        xls_update_value_only(sheet_URENI, 3, 12,
                              report.ureni_report.o59_total_start_f)
        xls_update_value_only(sheet_URENI, 4, 12,
                              report.ureni_report.o59_new_cases)
        xls_update_value_only(sheet_URENI, 7, 12,
                              report.ureni_report.o59_returned)
        xls_update_value_only(sheet_URENI, 10, 12,
                              report.ureni_report.o59_total_in)
        xls_update_value_only(sheet_URENI, 11, 12,
                              report.ureni_report.o59_total_in_m)
        xls_update_value_only(sheet_URENI, 12, 12,
                              report.ureni_report.o59_total_in_f)
        xls_update_value_only(sheet_URENI, 13, 12,
                              report.ureni_report.o59_transferred)
        xls_update_value_only(sheet_URENI, 14, 12,
                              report.ureni_report.o59_grand_total_in)
        xls_update_value_only(sheet_URENI, 1, 21,
                              report.ureni_report.o59_healed)
        xls_update_value_only(sheet_URENI, 3, 21,
                              report.ureni_report.o59_deceased)
        xls_update_value_only(sheet_URENI, 5, 21,
                              report.ureni_report.o59_abandon)
        xls_update_value_only(sheet_URENI, 7, 21,
                              report.ureni_report.o59_not_responding)
        xls_update_value_only(sheet_URENI, 8, 21,
                              report.ureni_report.o59_total_out)
        xls_update_value_only(sheet_URENI, 10, 21,
                              report.ureni_report.o59_total_out_m)
        xls_update_value_only(sheet_URENI, 11, 21,
                              report.ureni_report.o59_total_out_f)
        xls_update_value_only(sheet_URENI, 12, 21,
                              report.ureni_report.o59_referred)
        xls_update_value_only(sheet_URENI, 14, 21,
                              report.ureni_report.o59_grand_total_out)
        xls_update_value_only(sheet_URENI, 15, 21,
                              report.ureni_report.o59_total_end)
        xls_update_value_only(sheet_URENI, 14, 21,
                              report.ureni_report.o59_grand_total_out)
        xls_update_value_only(sheet_URENI, 16, 21,
                              report.ureni_report.o59_total_end_m)
        xls_update_value_only(sheet_URENI, 14, 21,
                              report.ureni_report.o59_grand_total_out)
        xls_update_value_only(sheet_URENI, 17, 21,
                              report.ureni_report.o59_total_end_f)
        xls_update_value_only(sheet_URENI, 1, 13,
                              report.ureni_report.total_start)
        xls_update_value_only(sheet_URENI, 2, 13,
                              report.ureni_report.total_start_m)
        xls_update_value_only(sheet_URENI, 3, 13,
                              report.ureni_report.total_start_f)
        xls_update_value_only(sheet_URENI, 4, 13,
                              report.ureni_report.new_cases)
        xls_update_value_only(sheet_URENI, 7, 13,
                              report.ureni_report.returned)
        xls_update_value_only(sheet_URENI, 10, 13,
                              report.ureni_report.total_in)
        xls_update_value_only(sheet_URENI, 11, 13,
                              report.ureni_report.total_in_m)
        xls_update_value_only(sheet_URENI, 12, 13,
                              report.ureni_report.total_in_f)
        xls_update_value_only(sheet_URENI, 14, 13,
                              report.ureni_report.grand_total_in)
        xls_update_value_only(sheet_URENI, 1, 22,
                              report.ureni_report.healed)
        xls_update_value_only(sheet_URENI, 3, 22,
                              report.ureni_report.deceased)
        xls_update_value_only(sheet_URENI, 5, 22,
                              report.ureni_report.abandon)
        xls_update_value_only(sheet_URENI, 7, 22,
                              report.ureni_report.not_responding)
        xls_update_value_only(sheet_URENI, 8, 22,
                              report.ureni_report.total_out)
        xls_update_value_only(sheet_URENI, 10, 22,
                              report.ureni_report.total_out_m)
        xls_update_value_only(sheet_URENI, 11, 22,
                              report.ureni_report.total_out_f)
        xls_update_value_only(sheet_URENI, 12, 22,
                              report.ureni_report.referred)
        xls_update_value_only(sheet_URENI, 14, 22,
                              report.ureni_report.grand_total_out)
        xls_update_value_only(sheet_URENI, 15, 22,
                              report.ureni_report.total_end)
        xls_update_value_only(sheet_URENI, 14, 22,
                              report.ureni_report.grand_total_out)
        xls_update_value_only(sheet_URENI, 16, 22,
                              report.ureni_report.total_end_m)
        xls_update_value_only(sheet_URENI, 14, 22,
                              report.ureni_report.grand_total_out)
        xls_update_value_only(sheet_URENI, 17, 22,
                              report.ureni_report.total_end_f)

    stream = StringIO.StringIO()
    copy_week_b.save(stream)

    return stream