在'str'和'int'的实例之间不支持'>'。我在excel中编写时出错

2024-04-25 14:04:26 发布

您现在位置:Python中文网/ 问答频道 /正文

    import openpyxl
    import getpass
    import os
    import shutil
    import sys
    from openpyxl.utils import get_column_letter
    from openpyxl.styles import Border, Side, NamedStyle, Color, PatternFill, Font, Alignment
    from openpyxl.styles import colors
    from openpyxl import Workbook
    import win32com.client as win32
    import xlwings as xw


  REMOVE: All counters that are no longer being used. Check on raw_input, row deletion, and pandas.




 curr_row = 2
    detections = 0
    detections_rem_tmfrm = 0
    pias_needed = 0
    pias_comp = 0
    web_num = "Null"
    int_end_analysis = 0
    int_ptch_analysis = 0


    print(e)



 op = input('\nDo you want to continue? Y/N\n\n').upper()

    if op != "Y":
        sys.exit("\nExiting program.")
    else:
        print("\nContinuing process.")

    #get user name
    dirpath = os.getcwd()
    print("current directory is : " + dirpath)
    foldername = os.path.basename(dirpath)
    print("Directory name is : " + foldername)
    #get current directory
    #os.chdir(foldername % username)
    #os.path.join(foldername,username)
    #Loads Excel sheet with all of the companies' responses recorded. 
    data_file = openpyxl.load_workbook('_Dash_Da.xlsx')

for row in range (2, q1_sheet.max_row+1):

获取列A行中单元格的值[变量“Row”当前表示的int值] 当前opco=q1\U表[B'+str(行)]。值

    shutil.copy("_Dash_tem.xlsx", "%s Dash.xlsx" % curr_opco)

print("\nCreated Oco Dash Tem")
col_num_left = 6 
col_num_right = 13 

对于季度中的季度_arr:

    #Keep a placeholder number for the column where this all gets written.
    #This will deprecate through the loop

    print("\n.......Beginning work on %s...\n" % quarter)

    #Iterate through each Op
    for row in range (2, 20):

        print("Current Op: " + curr_op)

        #Gets value of cell in Column A, Row[whatever int the variable "row" is currently representing]
        curr_op = quarter['B' + str(row)].value

        #print(quarter)
        #print(curr_op)

        qtr_title = quarter.title

        #Load current Op's template file
        dashboard = openpyxl.load_workbook('%s Das.xlsx' % curr_op)
        exec_summary = dashboard.worksheets[0]
        endpt_details = dashboard.worksheets[1]
        patching_details = dashboard.worksheets[2]
        privacy_details = dashboard.worksheets[3]
        cloudmon_details = dashboard.worksheets[4]
        critasset_details = dashboard.worksheets[5]
        #Add any new worksheet up here

        #Collect End sey de
        ser_sc_A = quarter['E' + str(row)].value
        cl_sc_A = quarter['F' + str(row)].value
        dev_A_co = quarter['G' + str(row)].value
        ser_sc_S = quarter['I' + str(row)].value
        c_s_S = quarter['J' + str(row)].value
        ds_S_in = quarter['K' + str(row)].value

在这行代码中,我遇到了一个错误('str'和'int'实例之间不支持'>;'),在这里我试图进行一些计算并将其写入excel文件,但在这里我遇到了一个错误

AVd = (quarter['E' + str(row)].value +quarter['F' + str(row)].value)
                if AVd > 0:
                    AVvalue = (dev_A_co/ AVd)*100
                elif AVd==0:
                    AVvalue = 100
                #Get current column letters:


    left_col_ltr = (get_column_letter(co

l_num_left))
                        right_col_ltr = (get_column_letter(col_num_right))


                        dashboard.save('%s Dash.xlsx' % curr_op)

Tags: importgetvalueoscolumnnumdashboardrow