One , Basic environment

       1, my python The environment is 3.0 Above ,excel yes 2016 edition , For software pycharm

Two , Specific use

        1, You need to download it first openpyxl 

          pip install openpyxl 

          2, Some simple knowledge points

           a, Open what you need to open excel And instantiate one worksheet               
wb=load_workbook(r' Your catalogue ')
             b, Get current sheet page ( You can also specify )

               sheet=wb.active

              c,  Get the row range you need , Note that cell coordinates are always from the (1,1) start , non-existent (0,1) perhaps (1,0)

                    Otherwise, it will report an error 'ValueError: Row or column values must be at least 1'

                  The scope is guaranteed at  range(1,sheet.max_row+1) that will do

               d, Get one individually cell Value of

                   cell1=sheet.cell(row=row,column=1).value   
#value It's necessary , Otherwise, you get the cell object , Not the specific value

            The specific simple code is as follows :

                          
def getdata(baseurl,f): #list=[] wb=load_workbook(baseurl) sheet=wb.active
#sheet.values(row) for row in range(1,sheet.max_row+1): temp_list=[]
cell1=sheet.cell(row=row,column=1).value
cell2=sheet.cell(row=row,column=2).value temp_list=[cell1,cell2]
print('cell2=%s cell1=%s'%(cell2,cell1))
 

   

Technology
©2019-2020 Toolsou All rights reserved,
1190 Reverses the substring between each pair of parentheses leetcodemysql Joint index details You don't know ——HarmonyOS Create data mysql Library process Character recognition technology of vehicle license plate based on Neural Network A guess number of small games , use JavaScript realization Talking about uni-app Page value transfer problem pytorch of ResNet18( Yes cifar10 The accuracy of data classification is achieved 94%)C++ Method of detecting memory leak One is called “ Asking for the train ” A small village Finally got the train